velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Douglass" <>
Subject RE: clearing and setting Velocity properties
Date Sat, 30 Aug 2003 10:15:49 GMT
Here's how I've initially solved the problem. I reinstantiated
RuntimeInstance in RuntimeSingleton every time a parameterized init method
is called. This works, but smells bad to me. First of all, a new object has
to be created and initialized each time(wasteful). Second of all, and most
worrysome to me, is it makes my code dependent on a modified Velocity. When
Velocity 1.4 or Velocity 2 comes along, I'm going to have to modify it too.
I'm still hoping someone has a better suggestion.


  public static void init(Properties p) throws Exception
	ri = new RuntimeInstance();
  public static void init(String configurationFile)
        throws Exception
	ri = new RuntimeInstance();
      ri.init( configurationFile );

-----Original Message-----
From: Robert Douglass []
Sent: Saturday, August 30, 2003 9:32 AM
To: Velocity list
Subject: clearing and setting Velocity properties

	I'm integrating Velocity into an existing app, and need help with the way
the Velocity object is initialized. I understand that it is a singleton, and
that calling init() repeatedly will have no effect. However, I was surprised
that the following code also doesn't work as one might think:;
		Velocity.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, "foo");
		Object o1 = Velocity.getProperty(Velocity.FILE_RESOURCE_LOADER_PATH);
		Velocity.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, "bar");
		Object o2 = Velocity.getProperty(Velocity.FILE_RESOURCE_LOADER_PATH);

o1 and o2 both end up being "." ... which is apparently the default value
from calling Velocity.init(). So, do I understand that there is no way to
set the properties after the first call to .init(...)? In my application, I
would like to set Velocity.FILE_RESOURCE_LOADER_PATH every time before I
call .merge. Is this possible, as Velocity is, or do I need to customize it?
If I need to customize it, has anybody made this change already, and what is
the best method to do so? My first thought would be to destroy Velocity
object and create it new each time. Thanks for your thoughts,

Robert Douglass

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message