velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nathan Bubna" <nat...@esha.com>
Subject Re: Autoreload and WebappLoader
Date Thu, 14 Aug 2003 05:33:56 GMT
Bill Boland said:
> I was migrating a web application to Velocity 1.3.1 and Velocity Tools 1.0
> this weekend and was unable to get the autoreload of libraries to work. I
> looked into the source and it seems to always return zero for the
> modification time for the WebappLoader which is used by default from the
> VelocityViewServlet. I didn't see a bug report on this...so it could just be
> me or something stupid I've done. I'm not using a war file. This does not
> seem to be a problem with templates that are not libraries so I'm not sure
> if the modification time is a problem or there is something else going on.
>
> Could someone verify that this does or doesn't work? Thanks.

hmm.  i haven't got the time to test this out or develop a fix at the moment.
too much else on my plate.  i haven't used the autoreloading of libraries
much, but i suspect that if it really doesn't work, then the problem is
related to the fact that isSourceModified and getLastModified are basically
no-ops for the WebappLoader.  in fact, i think the FileResourceLoader is the
only standard velocity resource loader that these methods are relevant for
(someone correct me if i'm wrong).

so, here's my suggestion once you've followed the docs on the relevant
velocity.properties keys and values and tested it all out and the reloading
still doesn't work:

1.  enter a bug report.  explain what you're trying to do, what resource
loaders and velocity.properties you've tried and what, if anything, happened
for them.

2. try and fix it yourself.  if it turns out that you need to have real,
working isSourceModified() and getLastModified() methods for the WebappLoader,
then you will probably want to look into the ServletContext.getResource()
method (returns a java.net.URL), and the URL.openConnection() method.  once
you have the URLConnection object, you can ask it for the file modification
info.  i don't know if there's any guarantee that those methods will return
it, but it's your best bet.  use the isSourceModified() and getLastModified()
methods in FileResourceLoader as models of how to use the info you get from
the URLConnection.

3. if you succeed in fixing it, attach a patch for the WebappLoader to the bug
report and add the "PatchAvailable" keyword to the report.

Nathan Bubna
nathan@esha.com


Mime
View raw message