commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver Heger <heg...@med.uni-marburg.de>
Subject Re: Configuration: Value not overriding
Date Thu, 28 Jul 2005 07:14:17 GMT
Tan Kah Siong schrieb:
> Hi.
> 
> I need to clarify the following about commons
> configuration.
> 
> Commons configuration can make use of a substitution
> technique as follows.
> 
> file: application1.properties
> key1 = ${key2}
> key2 = key2value
> key3 = key3value
> 
> This will result in key1=key2value
> 
> Now, say i got another file
> 
> file: application2.properties
> key2 = keyXvalue
> 
> This file is loaded into a compositeconfiguration as
> follows,
> 
> CompositeConfiguration config = new
> CompositeConfiguration();
> config.addConfiguration(new
> PropertiesConfiguration("application1.properties"));
> config.addConfiguration(new
> PropertiesConfiguration("application2.properties"));
> 
> Will key2 now be key2value or keyXvalue or an array of
> both?
> Consequently, will key1 be key2value or keyXvalue
> after application2.properties is loaded?
> 
> Please advice.
> 
> 
CompositeConfiguration evaluates keys by processing the contained 
configurations in the order they were added. When the first match is 
found, processing stops.

In your case that means, that application1.properties will be searched 
first. Here the value "key2value" will be found and returned.

More information about this topic, including how to create a union 
configuration using ConfigurationFactory, can be found in the Howtos on 
the main site of commons-configuration. Have a look at [1] and [2].

HTH
Oliver

[1] 
http://jakarta.apache.org/commons/configuration/howto_configurationfactory.html
[2] http://jakarta.apache.org/commons/configuration/howto_xml.html

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


Mime
View raw message