Thanks for the reply, Oliver.  In fact I *have* created an abstract 
ConfigurationDecorator class and also an ImmutableConfiguration wrapper.

Anyway, I'll test it out and see about submitting it to the project.

Thanks again,
Bill



-----Original Message-----
From: Oliver Heger [mailto:[EMAIL PROTECTED]
Sent: Monday, September 19, 2005 12:27 PM
To: Jakarta Commons Users List
Subject: Re: [Configuration] Use Configuration as a singleton?


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?
>
>Thanks,
>Bill
>
>  
>
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 
approach.

Oliver


*************************************************************************
This communication, including attachments, is
for the exclusive use of addressee and may contain proprietary,
confidential and/or privileged information.  If you are not the intended
recipient, any use, copying, disclosure, dissemination or distribution is
strictly prohibited.  If you are not the intended recipient, please notify
the sender immediately by return e-mail, delete this communication and
destroy all copies.
*************************************************************************


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to