You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by "Walid \"jo\" Gedeon" <wg...@gmail.com> on 2008/11/12 21:46:16 UTC

Setting a custom resource loader

Hello all!
I'm using Velocity to generate a service's output (telnetservice).
It works excellently as a standalone app, however fails to find my
resources in the context a bundle running on an osgi framework (felix in
this case).

It looks like the bundling and dependencies makes it so that the velocity
classpath resource loader cannot see my resources.
I'm looking for a way to set the resource loader to one that I would
implement and that would live in my context, and provide the resources to
velocity...

VelocityEngine.setApplicationAttribute(VelocityEngine.RESOURCE_LOADER,
                new ClasspathResourceLoader())
was my best bet, but it doesnt work? tried it before and after the init(),
am I missing another call for it to make it to the resource manager's
resource loaders list?

Unfortunately, I can't use the property "resource.loader" because my
resource loader class would not be visible from the velocity context.

ideas? :-)
w

Re: Setting a custom resource loader

Posted by "Walid \"jo\" Gedeon" <wg...@gmail.com>.
Thanks Nathan, you've saved me a lot of hassle :-)It works fine now. I
thought I looked through the documentation, but I must have missed it.
w

On Thu, Nov 13, 2008 at 12:20 AM, Nathan Bubna <nb...@gmail.com> wrote:

> VelocityEngine doesn't have any static methods, and resource loaders
> should be set via the configuration properties, not the application
> attributes.  Please be sure you have read the documentation on
> configuring resource loaders.
>
> that said, you will probably end up doing something like this:
>
> VelocityEngine engine = new VelocityEngine();
> engine.setProperty("resource.loader", "mine");
> engine.setProperty("mine.resource.loader.instance", new
> MyResourceLoader());
>
> On Wed, Nov 12, 2008 at 12:46 PM, Walid jo Gedeon <wg...@gmail.com>
> wrote:
> > Hello all!
> > I'm using Velocity to generate a service's output (telnetservice).
> > It works excellently as a standalone app, however fails to find my
> > resources in the context a bundle running on an osgi framework (felix in
> > this case).
> >
> > It looks like the bundling and dependencies makes it so that the velocity
> > classpath resource loader cannot see my resources.
> > I'm looking for a way to set the resource loader to one that I would
> > implement and that would live in my context, and provide the resources to
> > velocity...
> >
> > VelocityEngine.setApplicationAttribute(VelocityEngine.RESOURCE_LOADER,
> >                new ClasspathResourceLoader())
> > was my best bet, but it doesnt work? tried it before and after the
> init(),
> > am I missing another call for it to make it to the resource manager's
> > resource loaders list?
> >
> > Unfortunately, I can't use the property "resource.loader" because my
> > resource loader class would not be visible from the velocity context.
> >
> > ideas? :-)
> > w
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>

Re: Setting a custom resource loader

Posted by Nathan Bubna <nb...@gmail.com>.
VelocityEngine doesn't have any static methods, and resource loaders
should be set via the configuration properties, not the application
attributes.  Please be sure you have read the documentation on
configuring resource loaders.

that said, you will probably end up doing something like this:

VelocityEngine engine = new VelocityEngine();
engine.setProperty("resource.loader", "mine");
engine.setProperty("mine.resource.loader.instance", new MyResourceLoader());

On Wed, Nov 12, 2008 at 12:46 PM, Walid jo Gedeon <wg...@gmail.com> wrote:
> Hello all!
> I'm using Velocity to generate a service's output (telnetservice).
> It works excellently as a standalone app, however fails to find my
> resources in the context a bundle running on an osgi framework (felix in
> this case).
>
> It looks like the bundling and dependencies makes it so that the velocity
> classpath resource loader cannot see my resources.
> I'm looking for a way to set the resource loader to one that I would
> implement and that would live in my context, and provide the resources to
> velocity...
>
> VelocityEngine.setApplicationAttribute(VelocityEngine.RESOURCE_LOADER,
>                new ClasspathResourceLoader())
> was my best bet, but it doesnt work? tried it before and after the init(),
> am I missing another call for it to make it to the resource manager's
> resource loaders list?
>
> Unfortunately, I can't use the property "resource.loader" because my
> resource loader class would not be visible from the velocity context.
>
> ideas? :-)
> w
>

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