See this JIRA document. I will reevaluate my
contribution (still havent dont it) and submit it to
Velocity1.5 codebase.

But you should fine UnicodeResourceLoader custom class
and example application. Maybe it helps you resolve
the why velocity.properties did not work for you.

http://issues.apache.org/jira/browse/VELOCITY-191
http://koti.mbnet.fi/akini/java/unicodereader/

--- Nathan Bubna <[EMAIL PROTECTED]> wrote:

> On 11/23/05, Magnus Kvalheim <[EMAIL PROTECTED]>
> wrote:
> > Thanks for your reply Steve,
> >
> > No, I'm not getting any calls to the
> isSourceModified or getLastModified
> > methods.
> >
> > Using velocity-tools I have never had the need to
> specify any
> > resource-loaders before.
> > Taken from:
> >
>
http://jakarta.apache.org/velocity/tools/view/index.html#Installation
> > "Velocity configuration is *optional*, and for
> most applications the
> > defaults will work fine. The *velocity.properties*
> file contains
> > settings that affect logging, encoding, and macro
> settings".
> > Does this mean that resourceLoaders with
> velocity-tools should be
> > defined outside the velocity.properties file?
> 
> nope.  it just means that if you specify some in
> your
> velocity.properties, you will effectively be
> *overriding* the defaults
> set by the VelocityViewServlet.  so when you did:
> 
> resource.loader=custom
> 
> you told Velocity not to use the WebappLoader.  All
> you should need to
> do to have both loaders work is:
> 
> resource.loader = custom,webapp
> custom.resource.loader.description = A custom
> resource loader
> custom.resource.loader.class =
> package.CustomResourceLoader
> 
> or
> 
> resource.loader = webapp,custom
> custom.resource.loader.description = A custom
> resource loader
> custom.resource.loader.class =
> package.CustomResourceLoader
> 
> depending on which resource loader you'd like
> Velocity to be the first
> asked for templates and which one you want to be the
> backup. :)
> 
> > Velocity only search for templates in the default
> > resource-handler(velocity-tools) and never hits my
> custom loader (except
> > on deploy).
> >
> > One strange thing though: At the time of
> web-deploy the
> > CustomResourceLoader.getResourceStream is called
> searching for
> > /WEB-INF/VM_global_library.vm - which it will not
> find.
> 
> i'm not sure i understand what's going on with
> these.  under what
> circumstances were these things happening?
> 
> > Is the ResourceManagerImpl making the call looking
> for the file?
> > ... and will I have to write my own implementation
> of the
> > ResourceManager interface in order to make my
> resourceloader work properly?
> 
> no, you should not have to write your own resource
> manager.
> 
> > Any help is much appreciated
> >
> > thanks
> > Magnus
> >
> >
> > Steve O'Hara wrote:
> >
> > >Hi Magnus,
> > >
> > >Answering your last question first, no, velocity
> will only load a
> > >template using the resource loaders you specify. 
> In your case, you've
> > >only specified one, "custom".  If you leave it
> blank, then it assumes
> > >"file".  If you want more than one loader, then
> you should do something
> > >like the following;
> > >
> > >     resource.loader = custom,WebAppLoader
> > >
> > >Back to your problem - are you getting calls to
> the methods
> > >getLastModified & isSourceModified within your
> resource loader?
> > >Perhaps you're not sending back anything in
> response to these calls and
> > >therefore the loader manager is not bothering to
> call your
> > >getResourceStream method.
> > >
> > >Steve
> > >
> > >
> > >-----Original Message-----
> > >From:
> >
>
>[EMAIL PROTECTED]
> > >.org
> >
>
>[mailto:[EMAIL PROTECTED]
> > >a.apache.org] On Behalf Of Magnus Kvalheim
> > >Sent: 23 November 2005 10:33
> > >To: velocity-user@jakarta.apache.org
> > >Subject: Write a custom resourceloader
> > >
> > >Hi all,
> > >
> > >I have tried to write a custom resourceloader on
> order to be able to
> > >load templates from an alternate source.
> > >
> > >I am using velocity-tools 1.2
> > >
> > >I have extended the
> >
>
>org.apache.velocity.runtime.resource.loader.ResourceLoader
> class and
> > >registered the resource loader in the
> velocity.properties file like
> > >this.
> > >
> > >---------
> > >resource.loader = custom
> > >custom.resource.loader.description = A custom
> resource loader
> > >custom.resource.loader.class =
> package.CustomResourceLoader
> > >-------
> > >
> > >The resource loader is indeed being loaded - as
> the init function is
> > >called when the project is deployed to the web
> server. It also calls the
> > >
> > >getResourceStream with the
> "/WEB-INF/VM_global_library.vm" as parameter,
> > >
> > >but I guess the ResourceManagerImpl is the cause
> of this.
> > >
> > >The getResourceStream for my custom class is
> however NEVER called when I
> > >
> > >  request a template.
> > >getTemplate("templateFromCustomSource.vm");
> > >
> > >Have I missed something?
> > >Shouldn't velocity now look for templates in both
> WebAppLoader and
> > >CustomResourceLoader?
> > >
> > >thanks
> > >Magnus


                
__________________________________ 
Yahoo! Music Unlimited 
Access over 1 million songs. Try it free. 
http://music.yahoo.com/unlimited/

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to