commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dont_know <dont_k...@gmx.net>
Subject [configuration] Calling getConfiguration on DefaultConfigurationBuilder more than once permitted
Date Fri, 21 Mar 2014 21:45:29 GMT
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.

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
View raw message