Hi,

> I have an application consisting of a web application and some stand
alone java 
> clients. Both the web application and the java clients use a database.
The 
> problem is that the database configuration is duplicated.
>
> When I change the database settings, I have to reconfigure both the
webapp 
> (META-INF/context.xml) and the java clients
(mydatabasesettings.properties).
>
> I'd like to avoid this duplication. One possible solution would be to
generate 
> the context.xml based on mydatabasesettings.properties with an Ant
script. Are 
> there any better solutions?

If you are doing it the ant way I recommend using filtering. There is a
task called filter (see
http://ant.apache.org/manual/CoreTasks/filter.html). You put the values
you want to use at several places in its own property file for example
dbname=mydb, in the places you want to insert it you go @dbname@ instead
of the actual name. When you run the filter task all values in the
filter property file is put in its correct places.

(I use this now to build for different environments. One property file
for development, one for test and one for production. But in you case
you onle need on file I guess.)

If you are using Maven there is some more support for filtering although
the ant task still needs to be called explicilty.

Regards,
Fredrik Rubensson


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

Reply via email to