commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jörg Schaible <>
Subject RE: [Configuration] Caching properties
Date Tue, 06 Apr 2004 16:39:25 GMT
Michael MATTOX wrote on Tuesday, April 06, 2004 6:17 PM:

> From what I've seen of the documentation and javadocs, using
> Configuration requires creating  new object which will then
> read in the properties file. If I have 20 classes, all using
> the same property file, I'd like to avoid having 20
> Configuration objects that parse the config file 20 times.


> Is there anything wrong with creating a singleton which has a
> getConfiguration() method to return a global Configuration
> class?

No. But if you write you have to synchronize yourself.

> I know I could go one step further and have the
> Singleton implement the Configuration interface but that
> seems to be a lot of unnecessary work.
> An alternative would be like in log4J where they have a
> static getLogger() method in the Logger class.  But in
> looking at the source, log4J actually creates a new logger
> each time instead of caching it.
> Any suggestions?

The current implementation of SubsetConfiguration is just a delegator. So you can tailor a
big configuration in smart pieces without a lot of run-time costs. So you can have a singleton
for the global configuration and can use subsets (like a logger) for the relevant parts in
your classes.


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

View raw message