commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emmanuel Bourg <>
Subject Re: [configuration] Refactor AbstractConfiguration(Configuration defaults)
Date Mon, 16 Feb 2004 16:23:30 GMT
Eric Pugh wrote:

> Are we sure we want to do the deprecated?  Seems odd to have 1.0 have a
> deprecated method..  It may make more sense to just add another howto:  How
> to save your properties set in CompositeConfiguration?  Basically should be
> able to just grab out the inmemory and save it by hand...

That seems quite complicated, using a CompositeConfiguration we would 
have (I'm not familiar with this class so let me know if my use case is 
wrong) :

// loading
Configuration default = new PropertiesConfiguration("");

Configuration config = new PropertiesConfiguration("");

CompositeConfiguration cc = new CompositeConfiguration();

// using/modifying
cc.addProperty("foo", "bar");

// saving (assuming the previous reference is not available here)
PropertiesConfiguration pc = (PropertiesConfiguration) 
Configuration inmemory = cc.getConfiguration(0);
Iterator it = inmemory.getKeys();
while (it.hasNext()) {
     String key = (String);
     pc.addProperty(key, inmemory.getProperty(key));

using an unmodified PropertiesConfiguration this would be reduced to :

// loading
Configuration default = new PropertiesConfiguration("");

PropertiesConfiguration config = new 
PropertiesConfiguration("", default);

// using
config.addProperty("foo", "bar");

// saving;


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

View raw message