You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by ChadDavis <ch...@gmail.com> on 2009/02/17 01:16:15 UTC

caching with multiple resource loaders

I've got an app where I use a file resource loader followed by a
classpath resource loader.  I want the templates in the file location
to override the templates on the classpath.  This works partially.  If
a template with the same name is in both locations, it definitely
picks up the one in the file system.  If I remove the filesystem
template, during run time, the template on the classpath is then
found.  So far, so good.  If I then, however, try to put the template
back in the file system location, it is NOT picked up.

Note, this is all during run time.  If I restart my app ( a web
application -- not using the velocity servlet ), the filesystem
template is again picked up.


Here is my configuration:

#resource.loader=class
 resource.loader=file, class

# File resource loader information
#
file.resource.loader.description=Velocity File Resource Loader
file.resource.loader.class=org.apache.velocity.runtime.resource.loader.FileResourceLoader
file.resource.loader.cache=true
file.resource.loader.modificationCheckInterval=1
file.resource.loader.path=/home/readyportal/Desktop/machineOneWorkspaces/bipSpace/BIP/src/wego/velocity/templates/

#file.resource.loader.path=/home/readyportal/ReadyPortal/conf/velocity/templates/

#
# Class resource loader information
#
class.resource.loader.description=Velocity Classpath Resource Loader
class.resource.loader.class=org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
class.resource.loader.cache=true
class.resource.loader.modificationCheckInterval=1


Other notes:

If I turn the caching off on the classpath resource loader ( i.e.
change only the class.resource.loader.cache to false in the above
config ), everything works at runtime.

What am I doing wrong?

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


Re: caching with multiple resource loaders

Posted by ChadDavis <ch...@gmail.com>.
I'd be happy to share the fix.

On Tue, Feb 17, 2009 at 10:04 AM, Nathan Bubna <nb...@gmail.com> wrote:
> Sure,  the default implementation class is:
> http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/ResourceManagerImpl.java?revision=729843&view=markup
>
> You can change that using this property:
> resource.manager.class =
> org.apache.velocity.runtime.resource.ResourceManagerImpl
>
> The ResourceManager sits atop the ResourceCache and the
> ResourceLoaders, coordinating their activity.  I think the basic
> problem is that when multiple loaders are configured, the
> ResourceManager is not paying attention to which loader a cached
> resource came from.   I imagine changing the refreshResource method to
> check if a cached resource that came from a lower-rung resource loader
> can be found in a higher one should do the trick.
>
> If you do get around to fixing this for yourself, would you consider
> sharing the fix?
>
> On Tue, Feb 17, 2009 at 8:51 AM, ChadDavis <ch...@gmail.com> wrote:
>> Can you give me a little low down on how the ResourceManager works
>> with the ResourceLoaders?  Maybe I can do a little fix and build for
>> my own needs.
>>
>> On Mon, Feb 16, 2009 at 10:30 PM, Nathan Bubna <nb...@gmail.com> wrote:
>>> I don't think you're doing anything wrong, just something that no one
>>> else has tried.  I think this is a limitation of the default
>>> ResourceManager implementation.  Would you open a JIRA issue for this?
>>>  It seems like something that could and should be fixed.
>>>
>>> On Mon, Feb 16, 2009 at 4:16 PM, ChadDavis <ch...@gmail.com> wrote:
>>>> I've got an app where I use a file resource loader followed by a
>>>> classpath resource loader.  I want the templates in the file location
>>>> to override the templates on the classpath.  This works partially.  If
>>>> a template with the same name is in both locations, it definitely
>>>> picks up the one in the file system.  If I remove the filesystem
>>>> template, during run time, the template on the classpath is then
>>>> found.  So far, so good.  If I then, however, try to put the template
>>>> back in the file system location, it is NOT picked up.
>>>>
>>>> Note, this is all during run time.  If I restart my app ( a web
>>>> application -- not using the velocity servlet ), the filesystem
>>>> template is again picked up.
>>>>
>>>>
>>>> Here is my configuration:
>>>>
>>>> #resource.loader=class
>>>>  resource.loader=file, class
>>>>
>>>> # File resource loader information
>>>> #
>>>> file.resource.loader.description=Velocity File Resource Loader
>>>> file.resource.loader.class=org.apache.velocity.runtime.resource.loader.FileResourceLoader
>>>> file.resource.loader.cache=true
>>>> file.resource.loader.modificationCheckInterval=1
>>>> file.resource.loader.path=/home/readyportal/Desktop/machineOneWorkspaces/bipSpace/BIP/src/wego/velocity/templates/
>>>>
>>>> #file.resource.loader.path=/home/readyportal/ReadyPortal/conf/velocity/templates/
>>>>
>>>> #
>>>> # Class resource loader information
>>>> #
>>>> class.resource.loader.description=Velocity Classpath Resource Loader
>>>> class.resource.loader.class=org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
>>>> class.resource.loader.cache=true
>>>> class.resource.loader.modificationCheckInterval=1
>>>>
>>>>
>>>> Other notes:
>>>>
>>>> If I turn the caching off on the classpath resource loader ( i.e.
>>>> change only the class.resource.loader.cache to false in the above
>>>> config ), everything works at runtime.
>>>>
>>>> What am I doing wrong?
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>>>> For additional commands, e-mail: user-help@velocity.apache.org
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>>> For additional commands, e-mail: user-help@velocity.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>> For additional commands, e-mail: user-help@velocity.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>

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


Re: caching with multiple resource loaders

Posted by Nathan Bubna <nb...@gmail.com>.
Sure,  the default implementation class is:
http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/ResourceManagerImpl.java?revision=729843&view=markup

You can change that using this property:
resource.manager.class =
org.apache.velocity.runtime.resource.ResourceManagerImpl

The ResourceManager sits atop the ResourceCache and the
ResourceLoaders, coordinating their activity.  I think the basic
problem is that when multiple loaders are configured, the
ResourceManager is not paying attention to which loader a cached
resource came from.   I imagine changing the refreshResource method to
check if a cached resource that came from a lower-rung resource loader
can be found in a higher one should do the trick.

If you do get around to fixing this for yourself, would you consider
sharing the fix?

On Tue, Feb 17, 2009 at 8:51 AM, ChadDavis <ch...@gmail.com> wrote:
> Can you give me a little low down on how the ResourceManager works
> with the ResourceLoaders?  Maybe I can do a little fix and build for
> my own needs.
>
> On Mon, Feb 16, 2009 at 10:30 PM, Nathan Bubna <nb...@gmail.com> wrote:
>> I don't think you're doing anything wrong, just something that no one
>> else has tried.  I think this is a limitation of the default
>> ResourceManager implementation.  Would you open a JIRA issue for this?
>>  It seems like something that could and should be fixed.
>>
>> On Mon, Feb 16, 2009 at 4:16 PM, ChadDavis <ch...@gmail.com> wrote:
>>> I've got an app where I use a file resource loader followed by a
>>> classpath resource loader.  I want the templates in the file location
>>> to override the templates on the classpath.  This works partially.  If
>>> a template with the same name is in both locations, it definitely
>>> picks up the one in the file system.  If I remove the filesystem
>>> template, during run time, the template on the classpath is then
>>> found.  So far, so good.  If I then, however, try to put the template
>>> back in the file system location, it is NOT picked up.
>>>
>>> Note, this is all during run time.  If I restart my app ( a web
>>> application -- not using the velocity servlet ), the filesystem
>>> template is again picked up.
>>>
>>>
>>> Here is my configuration:
>>>
>>> #resource.loader=class
>>>  resource.loader=file, class
>>>
>>> # File resource loader information
>>> #
>>> file.resource.loader.description=Velocity File Resource Loader
>>> file.resource.loader.class=org.apache.velocity.runtime.resource.loader.FileResourceLoader
>>> file.resource.loader.cache=true
>>> file.resource.loader.modificationCheckInterval=1
>>> file.resource.loader.path=/home/readyportal/Desktop/machineOneWorkspaces/bipSpace/BIP/src/wego/velocity/templates/
>>>
>>> #file.resource.loader.path=/home/readyportal/ReadyPortal/conf/velocity/templates/
>>>
>>> #
>>> # Class resource loader information
>>> #
>>> class.resource.loader.description=Velocity Classpath Resource Loader
>>> class.resource.loader.class=org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
>>> class.resource.loader.cache=true
>>> class.resource.loader.modificationCheckInterval=1
>>>
>>>
>>> Other notes:
>>>
>>> If I turn the caching off on the classpath resource loader ( i.e.
>>> change only the class.resource.loader.cache to false in the above
>>> config ), everything works at runtime.
>>>
>>> What am I doing wrong?
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>>> For additional commands, e-mail: user-help@velocity.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>> For additional commands, e-mail: user-help@velocity.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>

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


Re: caching with multiple resource loaders

Posted by ChadDavis <ch...@gmail.com>.
Can you give me a little low down on how the ResourceManager works
with the ResourceLoaders?  Maybe I can do a little fix and build for
my own needs.

On Mon, Feb 16, 2009 at 10:30 PM, Nathan Bubna <nb...@gmail.com> wrote:
> I don't think you're doing anything wrong, just something that no one
> else has tried.  I think this is a limitation of the default
> ResourceManager implementation.  Would you open a JIRA issue for this?
>  It seems like something that could and should be fixed.
>
> On Mon, Feb 16, 2009 at 4:16 PM, ChadDavis <ch...@gmail.com> wrote:
>> I've got an app where I use a file resource loader followed by a
>> classpath resource loader.  I want the templates in the file location
>> to override the templates on the classpath.  This works partially.  If
>> a template with the same name is in both locations, it definitely
>> picks up the one in the file system.  If I remove the filesystem
>> template, during run time, the template on the classpath is then
>> found.  So far, so good.  If I then, however, try to put the template
>> back in the file system location, it is NOT picked up.
>>
>> Note, this is all during run time.  If I restart my app ( a web
>> application -- not using the velocity servlet ), the filesystem
>> template is again picked up.
>>
>>
>> Here is my configuration:
>>
>> #resource.loader=class
>>  resource.loader=file, class
>>
>> # File resource loader information
>> #
>> file.resource.loader.description=Velocity File Resource Loader
>> file.resource.loader.class=org.apache.velocity.runtime.resource.loader.FileResourceLoader
>> file.resource.loader.cache=true
>> file.resource.loader.modificationCheckInterval=1
>> file.resource.loader.path=/home/readyportal/Desktop/machineOneWorkspaces/bipSpace/BIP/src/wego/velocity/templates/
>>
>> #file.resource.loader.path=/home/readyportal/ReadyPortal/conf/velocity/templates/
>>
>> #
>> # Class resource loader information
>> #
>> class.resource.loader.description=Velocity Classpath Resource Loader
>> class.resource.loader.class=org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
>> class.resource.loader.cache=true
>> class.resource.loader.modificationCheckInterval=1
>>
>>
>> Other notes:
>>
>> If I turn the caching off on the classpath resource loader ( i.e.
>> change only the class.resource.loader.cache to false in the above
>> config ), everything works at runtime.
>>
>> What am I doing wrong?
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>> For additional commands, e-mail: user-help@velocity.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>

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


Re: caching with multiple resource loaders

Posted by Nathan Bubna <nb...@gmail.com>.
I don't think you're doing anything wrong, just something that no one
else has tried.  I think this is a limitation of the default
ResourceManager implementation.  Would you open a JIRA issue for this?
 It seems like something that could and should be fixed.

On Mon, Feb 16, 2009 at 4:16 PM, ChadDavis <ch...@gmail.com> wrote:
> I've got an app where I use a file resource loader followed by a
> classpath resource loader.  I want the templates in the file location
> to override the templates on the classpath.  This works partially.  If
> a template with the same name is in both locations, it definitely
> picks up the one in the file system.  If I remove the filesystem
> template, during run time, the template on the classpath is then
> found.  So far, so good.  If I then, however, try to put the template
> back in the file system location, it is NOT picked up.
>
> Note, this is all during run time.  If I restart my app ( a web
> application -- not using the velocity servlet ), the filesystem
> template is again picked up.
>
>
> Here is my configuration:
>
> #resource.loader=class
>  resource.loader=file, class
>
> # File resource loader information
> #
> file.resource.loader.description=Velocity File Resource Loader
> file.resource.loader.class=org.apache.velocity.runtime.resource.loader.FileResourceLoader
> file.resource.loader.cache=true
> file.resource.loader.modificationCheckInterval=1
> file.resource.loader.path=/home/readyportal/Desktop/machineOneWorkspaces/bipSpace/BIP/src/wego/velocity/templates/
>
> #file.resource.loader.path=/home/readyportal/ReadyPortal/conf/velocity/templates/
>
> #
> # Class resource loader information
> #
> class.resource.loader.description=Velocity Classpath Resource Loader
> class.resource.loader.class=org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
> class.resource.loader.cache=true
> class.resource.loader.modificationCheckInterval=1
>
>
> Other notes:
>
> If I turn the caching off on the classpath resource loader ( i.e.
> change only the class.resource.loader.cache to false in the above
> config ), everything works at runtime.
>
> What am I doing wrong?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>

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