commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver Heger <oliver.he...@oliver-heger.de>
Subject Re: is there a context sensitive properties configuration class available?
Date Thu, 02 Nov 2006 21:37:17 GMT
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


Mime
View raw message