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 09:58:26 GMT
On 9/22/02 5:15 AM, "Petr Toman" <Petr.Toman@pinknet.cz> wrote:

> Hello,
> I would like to ask a question originally posted by Mark to
> actionframework-users list.
> 
> There seems to be a problem when there are deployed multiple .war apps
> not including velocity-1.2*.jar in the WEB-INF\lib folder. Only the
> first subclass of VelocityServlet find its tempates (under
> WEB-INF\classes), because...
> 
> "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."
> 
> Is there a standard way to pass an RuntimeInstance object to
> VelocityServlet - in loadConfiguration()? - or do we need to override
> getTemplate() methods to call runtimeInstance.getTemplate()?


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.

The downside to this is that if you have multiples servlets in the same
.war, then you have multiple engines and multiple copies (maybe) of the
cached templates.



> 
> Thank you.
> Petr

-- 
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