commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject [configuration] Mutability of CompositeConfiguration
Date Wed, 15 Sep 2004 15:27:12 GMT
I am unsure whether CompositeConfiguration is mutable or immutable. 

 From the documentation, I was under the impression that it would be
immutable. By this, I mean that if you load it with configuration and then
add more configuration, if you repeat the same key in both sets of
configuration, the first definition of the key is the one that will be
returned when you look-up its value. 

If the second configuration updated the value of the key which had been
initially defined in the first configuration, I would consider it to be

I am trying to load configuration from a set of files but allow this
configuration to be overridden by System Properties. So I am loading the
system properties first and then adding the configuration from files. My
understanding is that configuration settings in CompositeConfiguration
would be immutable but my experience seems to be that this is not the case.
If I load a system property which is also included in the configuration
files, the one from configuration files is what is subsequently available.
Is this the behaviour that I should expect? 

Here is the code that I am using. 

     CompositeConfiguration compositeConfiguration = new

     // load system properties - these override all others
     Properties properties = System.getProperties();
     Enumeration e = properties.propertyNames();
     String key;
     while (e.hasMoreElements()) {
           key = (String) e.nextElement();

     // load file based properties
     ConfigurationFactory factory = new ConfigurationFactory();
     Configuration configuration = factory.getConfiguration();

So if I specify a system setting key/value pair of keyX=valueY where
configuration in my files sets keyX=valueZ, what should I get when I
retrieve the value after this set-up? 

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message