commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Gainty <mgai...@hotmail.com>
Subject RE: [configuration] Calling getConfiguration on DefaultConfigurationBuilder more than once permitted
Date Sat, 22 Mar 2014 01:17:44 GMT

  


> Date: Fri, 21 Mar 2014 22:45:29 +0100
> From: dont_know@gmx.net
> To: user@commons.apache.org
> Subject: [configuration] Calling getConfiguration on DefaultConfigurationBuilder more
than once permitted
> 
> Hi,
> 
> is it permitted to call getConfiguration more than once on the same 
> instance of DefaultConfigurationBuilder like this:
> 
> DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
> builder.setFile(new File("config.xml"));
> Configuration config = builder.getConfiguration(true);
> config = builder.getConfiguration(true);
> config = builder.getConfiguration(true);
> ...
> 
> The config.xml looks like this:
> <?xml version="1.0" encoding="ISO-8859-1" ?>
> 
> <configuration>
> <properties fileName="test.properties" config-at="a"/>
> <properties fileName="test.properties" config-at="b"/>
> <properties fileName="test.properties" config-at="c"/>
> <properties fileName="test.properties" config-at="d"/>
> <properties fileName="test.properties" config-at="e"/>
> <properties fileName="test.properties" config-at="f"/>
> <properties fileName="test.properties" config-at="g"/>
> <properties fileName="test.properties" config-at="h"/>
> <properties fileName="test.properties" config-at="i"/>
> <properties fileName="test.properties" config-at="j"/>
> </configuration>
> 
> and the referenced file "test.properties" contains:
> a=a
> b=b
> c=c
> 
> I asked this question, because with the first call of getConfiguration 
> the "test.properties"-file is read 10 times (once for every 
> "config-at"), with the second call 20 times, with the third call 30 
> times and so on. So in the end the program slows down and after 100 
> calls it needs 200ms to read the properties.
 
MG>builder.getConfiguration(true) a Union between one DB Table and another DB Table
MG>if you want to 'merge' 2 groups together I suggest using OverrideCombiner
MG>ConfigurationNode combine(ConfigurationNode node1,      ConfigurationNode node2)
MG> http://www.docjar.com/html/api/org/apache/commons/configuration/tree/OverrideCombiner.java.html
> 
> I'm a little bit confused because my idea was to instantiate 
> DefaultConfigurationBuilder for performance reasons only once (as a 
> Singleton) and call getConfiguration subsequently to read "fresh" 
> properties.
> 
> Thanks
> Stefan
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
> 
 		 	   		  
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message