velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Milo <msimp...@kikkoman.org>
Subject JBoss3.0/Tomcat & Velocity works; template caching question
Date Wed, 10 Jul 2002 07:06:37 GMT

I would like to verify that in a servlet environment, if your servlet 
runner does not expand your war/jar file during deployment *cough* 
Tomcat 4.0 *cough*, then you cannot use the "file resource loader" 
because "String root = getServletContext().getRealPath(value)" returns 
null as there is to RealPath war file uwrapped in memory.  Correct?

Secondly, the classpath and WebappLoaders do not cache templates. 
 Correct?   Both of them return 0 for getLastModified(Resource).  This 
means that if you use the classpath loader, then every time your 
template is accessed it has to be reparsed by the engine, Correct?

I don't mind reloading on every access during development (great for 
editing templates, see below), but what do I do for deployment?  Note I 
can't ditch JBoss and use a standalone servlet runner that will unpack 
the war file as I will be talking to ejbs, and I'd like to keep 
everything in one vm for speed.


JBoss 3.0 with Tomcat and Velocity:
Using the classpath loader, putting my template files in jar, and then 
placing that jar in the WEB-INF/lib dir, I can access the template files 
from my servlet.   My war file thus looks like this:
mysite.war
    +---WEB-INF
    |      +---lib
    |      |     +---templates.jar  <--- all the .vm files
    |      |     |...jar
    |      |
    |      +---classes
    |            +---myServlet.class
    |            |...
    |           
This works, but is a pain wrt template development, eg you need to 
jar/war & redeploy everytime you want to see a template change.

So, for development what I do is I deploy my templates.jar into JBoss 
separately, eg remove templates.jar from mysite.war and deploy both of 
them into JBoss.  JBoss puts everything in the same "class-space" so it 
works nicely.  Thus to "deploy" I put mysite.war and templates.jar in my 
jboss/server/default/deploy dir.  Then all I need to do during 
development is rejar and redrop the templates.
I can actually go a step further and avoid having to jar the templates 
at all, by building a jar structure in the JBoss deploy directory.  Eg 
"mkdir server/default/deploy/templates.jar ; cp *.vm 
server/default/deploy/templates.jar".  Then I can just updated/edit 
individual tempates without having to package or restart anything.   
That is what made be start to wonder about velocity's cacheing  wrt to 
the classpath loader.

Note that I tried deploying my war file unpacked into jboss using the 
"mkdir mysite.war" that doesn't work as Tomcat will slurps the 
.jar,.class,.jsp files over to a work dir that ends up being the "RealPath".

Thanks.

Milo S.







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