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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to