Am 23.04.2010 20:36, schrieb Santhosh Kumar:
It is a very common requirement that some configuration value changes across 
environments (dev/qa/stg/prd etc). I went through the documentation but didn't 
find any feature to do this in the Configuration (please correct me if you know 
a way to do this).

If such feature doesn't already there, I was hoping something like 
EnvironmentAwareConfiguration can add such feature based on the environment and 
server id (for usecases where each server in the production cluster needs to 
get different property value).

Please let me know what you think. If this is something adds value (which I 
truly believe it will), I will post a detailed information.

Thanks,
Santhosh.


One way to achieve this would be to use DefaultConfigurationBuilder and the interpolation facilities supported by all configuration implementations. For instance, you can have the following definition file for DefaultConfigurationBuilder:

<configuration>
  <properties fileName="${env:STAGE}/config.properties"/>
</configuration>

Here with ${env:STAGE} the OS environment variable STAGE is referenced, and the properties file is load from a subdirectory whose name matches the value of the variable. The environment variable could have different values depending on the specific server environment and thus different configuration files would be loaded.

Note however, that interpolation of environment variables is available in Commons Configuration 1.7 only which has not yet been released.

Would this approach work for you?

Oliver

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

Reply via email to