You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Serge Knystautas <se...@lokitech.com> on 2004/10/10 02:29:03 UTC

Layered resource caching

I've defined 2 resource loaders, basically a set of customized templates 
with a set of default templates underneath it.  Most of the time it 
works great... if I ask for "foo.vm", it first checks the customized 
template folder, and if not there, it falls through to the default 
template folder.

My one problem is when the template has already been loaded from the 
default template folder, and I add one to the customized template 
folder.  The default template loader does not refresh the resource, 
since that file timestamp has not changed.

What I'd like is the resource manager to check the customized template 
folder first before turning to the default template folder, and ideally 
still use a cached version for that.  Is the only way to do this to 
write my own ResourceManager implementation, or is there another way to 
do this?

-- 
Serge Knystautas
Lokitech >> software . strategy . design >> http://www.lokitech.com
p. 301.656.5501
e. sergek@lokitech.com

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


Re: Layered resource caching

Posted by Shinobu Kawai <sh...@gmail.com>.
Hi Serge,

> resource.loader=file1,file2
> file1.resource.loader.class=org.apache.velocity.runtime.resource.loader.FileResourceLoader
> file1.resource.loader.path=foo
> file1.resource.loader.cache=true
> file2.resource.loader.class=org.apache.velocity.runtime.resource.loader.FileResourceLoader
> file2.resource.loader.path=bar
> file2.resource.loader.cache=true
## snip

> I guess you're saying that the file loader has this ability built-in,
> but I'm using a mixture of resource loaders and am using the multiple
> loader feature, so I need the resource manager to handle this.
Are you using any loader other than the FileResourceLoader?  If not, I
think you can do

resource.loader=file
file.resource.loader.class=org.apache.velocity.runtime.resource.loader.FileResourceLoader
file.resource.loader.path=foo,bar
file.resource.loader.cache=true


> Again, it seems like I need my own ResourceManager impl, but just
> wondering if anybody hit this before, had a better suggestion, or a
> planned work around.
Making a composite ResourceLoader might do it as well.  :)

Best regards,
-- Shinobu Kawai

-- 
Shinobu Kawai <sh...@gmail.com>

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


Re: Layered resource caching

Posted by Serge Knystautas <se...@lokitech.com>.
Shinobu Kawai wrote:
>>What I'd like is the resource manager to check the customized template
>>folder first before turning to the default template folder, and ideally
>>still use a cached version for that.  Is the only way to do this to
>>write my own ResourceManager implementation, or is there another way to
>>do this?
> 
> Which loaders are you using, and how are you configuring them?  I
> think one FileResourceLoader with multiple paths should do the trick. 
> (Haven't tried, though)

resource.loader=file1,file2
file1.resource.loader.class=org.apache.velocity.runtime.resource.loader.FileResourceLoader
file1.resource.loader.path=foo
file1.resource.loader.cache=true
file2.resource.loader.class=org.apache.velocity.runtime.resource.loader.FileResourceLoader
file2.resource.loader.path=bar
file2.resource.loader.cache=true

Put a template into "bar" and have Velocity try to render that template. 
  Then put a template with the same name into the "foo" directory, and 
you'll continue to get a copy of the "bar" version.  If you restart 
Velocity, you'll then see the "foo" version since that appears earlier 
in the resource loader.

I guess you're saying that the file loader has this ability built-in, 
but I'm using a mixture of resource loaders and am using the multiple 
loader feature, so I need the resource manager to handle this.

Again, it seems like I need my own ResourceManager impl, but just 
wondering if anybody hit this before, had a better suggestion, or a 
planned work around.

-- 
Serge Knystautas
Lokitech >>> software . strategy . design >> http://www.lokitech.com
p. 301.656.5501
e. sergek@lokitech.com

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


Re: Layered resource caching

Posted by Shinobu Kawai <sh...@gmail.com>.
Hi Serge,

> What I'd like is the resource manager to check the customized template
> folder first before turning to the default template folder, and ideally
> still use a cached version for that.  Is the only way to do this to
> write my own ResourceManager implementation, or is there another way to
> do this?
Which loaders are you using, and how are you configuring them?  I
think one FileResourceLoader with multiple paths should do the trick. 
(Haven't tried, though)

Best regards,
-- Shinobu Kawai

-- 
Shinobu Kawai <sh...@gmail.com>

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