velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Geir Magnusson Jr." <>
Subject Re: Initializing multiple VelocityServlets
Date Sun, 22 Sep 2002 12:52:21 GMT
On 9/22/02 7:49 AM, "Anders Lindback" <> wrote:

> Geir Magnusson Jr. skrev:
>> On 9/22/02 5:15 AM, "Petr Toman" <> wrote:
>>> "RuntimeInstance is the thing that holds the ResourceManagerImpl which
>>> holds the FileResourceLoader which holds the search path for templates.
>>> Since it is initialized in VelocityInOutVariable in a static clause, no
>>> servlet after the first one will ever get its own FileResourceLoader for
>>> finding templates.
>>> So far as I can make out, fixing this will require changes in a number
>>> of places. actionframework's cannot just call its
>>> base class's getTemplate() method as that relies on velocity's
>>> RuntimeSingleton, which would introduce the same problem."
>> The singleton used by VelocityServlet is the problem.
>> I think the safest way out of this that requires little change is to simply
>> do roll your own version of velocityservlet that uses the 'separate
>> instance' runtime, using the VelocityEngine class rather than Velocity,
>> which is a singleton.
>> Then each of your servlets will have their own instance of the velocity
>> engine.
> Actually it trivial to let the servlets share the velocity engine -
> make it a static class member and a singletion in a base class
> that all servlets inherits from.

Indeed, that would work too. :)

You just have to make the choice.

> Anders Lindb├Ąck
> PS VelocityServlet REALLY need to rewritten to be of any use
> for enything else but toy servlets.

It really wasn't meant to be used for anything but toy servlets...  Of
course, we all tend to use it for everything...

Geir Magnusson Jr. 
Research & Development, Adeptra Inc.

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message