velocity-user mailing list archives

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

> Geir Magnusson Jr. skrev:
>> On 9/22/02 5:15 AM, "Petr Toman" <Petr.Toman@pinknet.cz> 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 VelocityServlet.java 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.
geirm@adeptra.com
+1-203-247-1713



--
To unsubscribe, e-mail:   <mailto:velocity-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:velocity-user-help@jakarta.apache.org>


Mime
View raw message