commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kenneth Xu" <kenne...@gmail.com>
Subject RE: is there a context sensitive properties configuration class available?
Date Fri, 03 Nov 2006 02:30:10 GMT
I use commons Configuration. One config file for each environment and use
composite configuration to include a common one. System property to define
which environment config to pick up.
 
-----Original Message-----
From: Zhang, Alex [mailto:AZhang@cypresscom.net] 
Sent: Thursday, November 02, 2006 5:10 PM
To: Jakarta Commons Developers List
Subject: RE: is there a context sensitive properties configuration class
available?

Yes, I know I can archive that using system property.
But here my goal is to have just one property file which I can commit
into CVS, I can build my web app from CVS, deploy it, and only need to
config the run time context, one variable, to pick up the correct
properties.
The purpose is to minimize the configuration changes from build to
deploy. 
Does this make sense to anybody?

Thank you,
Alex X Zhang

-----Original Message-----
From: Oliver Heger [mailto:oliver.heger@oliver-heger.de] 
Sent: Thursday, November 02, 2006 4:37 PM
To: Jakarta Commons Developers List
Subject: Re: is there a context sensitive properties configuration class
available?

Zhang, Alex wrote:
> Hi all,
> 
>  
> 
> I am looking for a properties configuration class that is context
> sensitive, which means the value of a property depends on the context.
> 
>  
> 
> For example, I have a website that uses different databases on dev,
> stage and production environments, but all use the same user name and
> password, so my properties file should look like this:
> 
>  
> 
> DB_URL (DEV)=jdbc:mysql://10.0.0.1
> 
> DB_URL (STAGE)=jdbc:mysql://10.0.0.2
> 
> DB_ URL(PRO)=jdbc:mysql://10.0.0.3
> 
>  
> 
> DB_USER=joe_user
> 
> DB_PASSWD=abc123
> 
>  
> 
> It may be named something differently. But can anyone tell me if there
> is any class like this? 
> 
>  
There is no such thing as a context sensitive configuration, but maybe 
you can achieve the desired result using interpolation (i.e. variable 
substitution) and/or system properties. For instance you could define a 
system property for the database URL. Then you could load your 
configuration file using a ConfigurationFactory that also includes a 
SystemConfiguration (which gives you access to all defined system 
properties). While the user name and password are directly defined in 
the configuration file, the URL would be obtained from the system 
properties. Would this be an option?

Please have a look at the user guide for more details.

HTH
Oliver

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


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


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


Mime
View raw message