You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Jorge Ferrer <jo...@gmail.com> on 2005/05/08 21:22:41 UTC

[Configuration] Creating a copy of a CompositeConfiguration

Hi,

In an application I'm developing I want to add a configuration
temporaly to a CompositeConfiguration. As it is a multithreaded
application and other threads should no view this temporally added
configuration I had the idea of cloning the CompositeConfiguration
before adding it.

But this class does not implement the clone() method. Is there any
other way to create a copy?

-- 
Cheers,
    Jorge

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [Configuration] Creating a copy of a CompositeConfiguration

Posted by Jorge Ferrer <jo...@gmail.com>.
Thanks Oliver,

The copy method is functionally what I need, but too slow as it copies
property by property. Your other solution works.

But while trying it out I thought of a better solution for my problem.
I wrap the original CompositeObject with a second CompositeObject and
then add the temporal configuration to the wrap. This way I keep the
original totally unmodified without having to make a copy.

Regards,
Jorge

On 5/9/05, Oliver Heger <he...@med.uni-marburg.de> wrote:
> ConfigurationUtils has a copy() method, but I am not sure if this fits
> your needs.
> 
> However creating a copy of a CompositeConfiguration is easy enough: Just
> fetch the contained Configuration objects using the getConfiguration(int
> index) method and add them to another CompositeConfiguration.
> 
> HTH
> Oliver
> 
> Jorge Ferrer wrote:
> > Hi,
> >
> > In an application I'm developing I want to add a configuration
> > temporaly to a CompositeConfiguration. As it is a multithreaded
> > application and other threads should no view this temporally added
> > configuration I had the idea of cloning the CompositeConfiguration
> > before adding it.
> >
> > But this class does not implement the clone() method. Is there any
> > other way to create a copy?
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
> 

-- 
Jorge Ferrer
EasyConf developer
http://easyconf.sourceforge.net

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [Configuration] Creating a copy of a CompositeConfiguration

Posted by Oliver Heger <he...@med.uni-marburg.de>.
ConfigurationUtils has a copy() method, but I am not sure if this fits 
your needs.

However creating a copy of a CompositeConfiguration is easy enough: Just 
fetch the contained Configuration objects using the getConfiguration(int 
index) method and add them to another CompositeConfiguration.

HTH
Oliver

Jorge Ferrer wrote:
> Hi,
> 
> In an application I'm developing I want to add a configuration
> temporaly to a CompositeConfiguration. As it is a multithreaded
> application and other threads should no view this temporally added
> configuration I had the idea of cloning the CompositeConfiguration
> before adding it.
> 
> But this class does not implement the clone() method. Is there any
> other way to create a copy?
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org