You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Thomas Thomas <de...@gmail.com> on 2006/12/17 14:15:14 UTC

Dynamicly adapt Configuration on Redploy

Hi,

I am using Jakarta configuration to specify in my web application, an
absolute path to the images dir.

This absolute path is different in the test server and in the deployment
server.

So when I deploy I need to manually change that path every time ...

How can I handle this ? Thank u.

Re: Dynamicly adapt Configuration on Redploy

Posted by "Oliver.Heger" <ol...@oliver-heger.de>.
Thomas Thomas wrote:
> Hi,
> 
> I am using Jakarta configuration to specify in my web application, an
> absolute path to the images dir.
> 
> This absolute path is different in the test server and in the deployment
> server.
> 
> So when I deploy I need to manually change that path every time ...
> 
> How can I handle this ? Thank u.
> 
One solution could be making use of system properties: You can specify
the location of the images as a property such as myapp.imagedir and pass
it to the JVM in your server start script using the -D option. The value
of this property would differ on the test server and the production server.

Then in your configuration file(s) you can access the property's value.
To do this you have to use a configuration definition file and work with
ConfigurationFactory or DefaultConfigurationBuilder (the user guide
contains information for both of these classes). The definition file
could look something like this:

<configuration>
  <!-- Enable access to system properties -->
  <system/>
  <!-- Include the normal configuration files -->
  <xml fileName="..."/>
  <properties fileName="..."/>
</configuration>

To include the image path property in a configuration file - e.g. in a
properties file - use the following syntax:

imagepath = ${myapp.imagedir}

(I hope that in future versions of Commons Configuration access to
system properties can be simplyfied.)

Oliver

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