commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver Heger <>
Subject Re: [configuration] Issue with combinedConfig from Factory
Date Thu, 03 Aug 2006 19:27:11 GMT
Thomas Peter wrote:
>> The next release will contain an alternative class called
>> DefaultConfigurationBuilder. This class works very similar to
>> ConfigurationFactory, but provides true hierarchical processing.
> ok, i got the rc, and tried the following:
> DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
> try {
> 	builder.setFile(new File("config.xml"));
> 	CombinedConfiguration conf = builder.getConfiguration(true);
> } catch (ConfigurationException e) {
> 	e.printStackTrace();
> }
> i used the xml-files from my OP and got the same result.
> what would be the best (or working) :) solution for the following problem.
> i want a central configuration file, where i can include other
> configurations-files.
> the other included configurations should not be merged, but be a huge
> union, so _no_ value gets overriden by an other, and i can access all
> values.
> thank you,
> thomas
I think I know now what the problem is: the configuration key in the 
expression if(!conf.containsKey("a.b("+i+")")) is evaluated as (a).b(i) 
and not as (a.b)(i).

Because there is no <a> element in your example xml files that has more 
than 4 <b> sub elements the condition results to false for i >= 4. In 
your case (when you are not interested in the hierarchical structure and 
simply want to query all existing <b> elements) you can do:
List values = conf.getList("a.b");

The returned list will contain the values of all existing <b> elements. 
I tested this with DefaultConfigurationBuilder. I suppose it will work 
with ConfigurationFactory, too.


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

View raw message