You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Erron Austin <er...@gmail.com> on 2007/07/19 16:02:54 UTC

Changing properties of Velocity Singleton

In my webapp I'm initializing Velocity the like this:
   Velocity.*init*(props);

However, later in my code I'm trying to update this properties like so:

if(condition){

Velocity.*clearProperty*("file.resource.loader.path");

Velocity.*addProperty*("file.resource.loader.path", prefs.getContentPath());

Velocity.*clearProperty*("resource.loader");

Velocity.*addProperty*("resource.loader", "file");

else{

Velocity.*clearProperty*("url.resource.loader.root");

Velocity.*addProperty*("url.resource.loader.root", prefs.getContentPath());

Velocity.*clearProperty*("resource.loader");

Velocity.*addProperty*("resource.loader", "url");

}

I've also tried to use setProperty instead.  I was hoping to avoid using
multiple instances of the Velocity Engine as initial testing shows it is
much slower than the singleton model.

Is it not possible to dynamically update the values of the singleton?

Thanks,

Erron

Re: Changing properties of Velocity Singleton

Posted by Nathan Bubna <nb...@gmail.com>.
On 7/19/07, Erron Austin <er...@gmail.com> wrote:
> In my webapp I'm initializing Velocity the like this:
>    Velocity.*init*(props);
>
> However, later in my code I'm trying to update this properties like so:
>
> if(condition){
>
> Velocity.*clearProperty*("file.resource.loader.path");
>
> Velocity.*addProperty*("file.resource.loader.path", prefs.getContentPath());
>
> Velocity.*clearProperty*("resource.loader");
>
> Velocity.*addProperty*("resource.loader", "file");
>
> else{
>
> Velocity.*clearProperty*("url.resource.loader.root");
>
> Velocity.*addProperty*("url.resource.loader.root", prefs.getContentPath());
>
> Velocity.*clearProperty*("resource.loader");
>
> Velocity.*addProperty*("resource.loader", "url");
>
> }
>
> I've also tried to use setProperty instead.  I was hoping to avoid using
> multiple instances of the Velocity Engine as initial testing shows it is
> much slower than the singleton model.
>
> Is it not possible to dynamically update the values of the singleton?

nope, sorry.  once the runtime (either the singleton or an engine) has
been initialized, the properties can't be updated.

> Thanks,
>
> Erron
>

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