commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver Heger <>
Subject Re: [Configuration] Use Configuration as a singleton?
Date Mon, 19 Sep 2005 16:26:39 GMT
DuFault, Bill J (PLC, IT) wrote:

>I'd like to make a Configuration object accessible as a singleton.  There was an entry
on this topic in the archives from 4/2004 which stated that you could use a Configuration
object in a singleton, but you would have to synchronize it yourself.  Is this still true?
Yes, this is still valid.

>I'm taking the approach that since you are dealing with a Configuration *interface* that
you can't know the implementation details and therefore can't know if it is threadsafe.  With
that in mind, I've written a SynchronizedConfiguration wrapper, but I haven't tested its performance
yet.  Is there an existing, project-recommended way that I could achieve the same thing?
You are right. Configuration classes *should* be threadsafe when 
accessed read only, but this is not guaranteed for all possible 
implementations of the interface.

So a wrapper approach is a good solution for this problem. We have 
nothing similar yet, so if you like to share your code, you are welcome.

Perhaps an abstract ConfigurationDecorator class could be useful 
implementing the typical Decorator pattern. The 
SynchronizedConfiguration would be a sub class of this class. There are 
certainly other use cases that could be implemented using a Decorator 


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

View raw message