velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Dekany <ddek...@freemail.hu>
Subject Re: Autoreload and WebappLoader
Date Sun, 17 Aug 2003 21:26:51 GMT
Sunday, August 17, 2003, 10:29:57 AM, Claude Brisson wrote:

>> isSourceModified and getLastModified are basically no-ops for the WebappLoader
>
> the main problem here is that the WebappLoader accesses resources via
> the servlet api (to work as well with exploded resources as with war
> files), and that the actual servlet api doesn't give us any date/time
> information on files. Maybe that would be the kind of feedack to give
> to w3c folks.

It's possible to get the last modification time of servlet resources:
You can get an java.net.URL with ServletContext.getResource(path). Then,
you can create an java.net.URLConnection with URL.openConnection(), and
URLConnection has a getLastModified() method.

> A potential workaround would be to reload all resources in dev mode, and not to reload
any one in production mode (except on some
> 'reload' signal manually generated, to avoid restarting ?)

BTW, this reminds me of a practical issue with the method I said above.
At least Tomcat 4.1 is lazy about monitoring the changes of the
resources. That is, you change the file, but then if you access it
through the servlet resource API, it will sometimes pretend *forever*
that the file was not changed... quite annoying. The workaround I did
for this is that I try to access the resource as File: Use
ServletContext.getRealPath(path), and if it is successful, then use the
File directly, rather than the servlet resource API.

-- 
Best regards,
 Daniel Dekany



Mime
View raw message