Well, hopefully you're running on a system where you control the
security permissions.  You'll have to use reflection to get the
RuntimeInstance out of the VelocityEngine, which is private.  Either
that or use a custom build of Velocity that gives access to the
RuntimeInstance.

On Wed, Jan 6, 2010 at 9:42 AM, George, Nixon <[email protected]> wrote:
> This is VelocityEngine 1.6.2. I am using a custom cache implementation that 
> also has a custom way of loading the template. The RuntimeInstance is then 
> attached to the template which I now realize is the wrong runtimeinstance and 
> instead should be the VelocityViewServlet's runtiminstance. Here is the code:
>
> <code>---------------------
> public static Template convertStringToTemplate(String input) throws 
> ParseException, Exception {
>        Template template = new Template();
>        RuntimeServices runtimeServices =                                      
>  RuntimeSingleton.getRuntimeServices();
>      StringReader reader = new StringReader(input);
>      SimpleNode node = runtimeServices.parse(reader, "UnusedTemplateName");
>      template.setRuntimeServices(runtimeServices);
>      template.setData(node);
>      template.initDocument();
>      return template;
> }
> ------------------</code>
>
> -----Original Message-----
> From: Nathan Bubna [mailto:[email protected]]
> Sent: Tuesday, January 05, 2010 7:49 PM
> To: Velocity Users List
> Subject: Re: Get hold of RuntimeInstance
>
> subclasses have access to the getVelocityEngine() method.  though, it
> returns the VelocityEngine wrapper instance, not the RuntimeInstance.
> If that's not enough, then what version of Velocity Engine are you
> using and what are you trying to do that needs RuntimeInstance
> directly?
>
> On Tue, Jan 5, 2010 at 5:00 PM, George, Nixon <[email protected]> 
> wrote:
>> I am using the 1.4 version of the tool.
>>
>> I am trying to access the RuntimeInstance from a subclass of 
>> VelocityViewServlet.
>>
>> -----Original Message-----
>> From: Nathan Bubna [mailto:[email protected]]
>> Sent: Tuesday, January 05, 2010 1:16 PM
>> To: Velocity Users List
>> Subject: Re: Get hold of RuntimeInstance
>>
>> Yeah, the VelocityViewServlet uses a VelocityEngine instance, not the 
>> singleton.
>>
>> What version of VelocityTools are you using?  And, in what class are
>> you trying to do this retrieval?  A subclass of VelocityViewServlet?
>> A tool class?  A template?  An "action" class in a framework?  Your
>> answers to these questions can greatly change the answer.
>>
>> On Tue, Jan 5, 2010 at 9:42 AM, George, Nixon <[email protected]> 
>> wrote:
>>> Some comments in addition to my question:
>>>
>>> Strangely enough the command RuntimeSingleton.getRuntimeServices() gives me 
>>> a different RuntimeInstance than that held by the VelocityViewServlet.
>>>
>>> -----Original Message-----
>>> From: George, Nixon [mailto:[email protected]]
>>> Sent: Monday, January 04, 2010 5:26 PM
>>> To: '[email protected]'
>>> Subject: Get hold of RuntimeInstance
>>>
>>> I am using VelocityViewServlet and need to get hold of its RuntimeInstance 
>>> object. How do I get to it? Thanks
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [email protected]
>>> For additional commands, e-mail: [email protected]
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to