Return-Path: Delivered-To: apmail-jakarta-commons-user-archive@www.apache.org Received: (qmail 53766 invoked from network); 13 May 2006 14:09:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 13 May 2006 14:09:55 -0000 Received: (qmail 83157 invoked by uid 500); 13 May 2006 14:09:35 -0000 Delivered-To: apmail-jakarta-commons-user-archive@jakarta.apache.org Received: (qmail 82950 invoked by uid 500); 13 May 2006 14:09:34 -0000 Mailing-List: contact commons-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Jakarta Commons Users List" Reply-To: "Jakarta Commons Users List" Delivered-To: mailing list commons-user@jakarta.apache.org Received: (qmail 82859 invoked by uid 99); 13 May 2006 14:09:34 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 13 May 2006 07:09:34 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=UNPARSEABLE_RELAY X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [194.25.134.84] (HELO mailout09.sul.t-online.com) (194.25.134.84) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 13 May 2006 07:09:32 -0700 Received: from fwd31.aul.t-online.de by mailout09.sul.t-online.com with smtp id 1Feunb-0005fw-09; Sat, 13 May 2006 16:08:51 +0200 Received: from [192.168.0.1] (G5KfccZAoeku1MGSUpqiYzL90AlldVw85IWFHUnA2brANjxuZ49p8P@[84.174.122.80]) by fwd31.sul.t-online.de with esmtp id 1FeunW-2B8iCu0; Sat, 13 May 2006 16:08:46 +0200 Message-ID: <4465E870.6080302@t-online.de> Date: Sat, 13 May 2006 16:08:48 +0200 From: Oliver Heger User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Jakarta Commons Users List Subject: Re: [Configuration] save References: <445F5202.7040805@najdi.si> In-Reply-To: <445F5202.7040805@najdi.si> X-Enigmail-Version: 0.92.0.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ID: G5KfccZAoeku1MGSUpqiYzL90AlldVw85IWFHUnA2brANjxuZ49p8P X-TOI-MSGID: 20761103-342d-4c54-8972-f8a42a583722 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Hello Borut, Borut BolĨina wrote: > Hello, > > when instantiating CompositeConfiguration with > > ConfigurationFactory factory = new > ConfigurationFactory(confDefinition); > try { > CompositeConfiguration config = (CompositeConfiguration) > factory.getConfiguration(); > return config; > } catch (ConfigurationException e) { > e.printStackTrace(); > } > > where confDefinition is a configuration.xml file defining several > properties file > > > > > > > > > > it would be nice to define which properties to save to by something like > > config.setDefaultSaveConfiguration(config.getConfiguration(0)); // > would be "i-want-to-save-here.properties" > // or even better by "named-and-not-by-index" configuration > > then calling > > config.save() > > would save any changes made by > > config.setProperty("newProperty","new value"); > > to i-want-to-save-here.properties. > > Currently, one must extract > > PropertiesConfiguration pc = (PropertiesConfiguration) > config.getConfiguration(0); > > set the desired property > > pc.setProperty("newProperty","new value"); > or > config.setProperty("newProperty","new value"); > if instantiated by > > PropertiesConfiguration pc = new > PropertiesConfiguration(fileToSaveChangesIn); > Configuration config = new CompositeConfiguration(saveConfiguration); > > and call > > pc.save(); > > Or did I miss something? > > Regards, > Borut > > CompositeConfiguration at least supports a so-called "in-memory configuration", to which all new properties are added. This can play the role of your "default save configuration". However there seems to be no possibility to set the in-memory configuration after the composite configuration was created. After having looked at the source code I fear it won't be easy to implement the behavior you suggested because the current implementation does not expect the in-memory configuration to belong to the regular list of configurations that have been added to the composite. It is treated differently at many places. Well, while the problems mentioned above can surely be solved, I am reluctant of adding a save() method to CompositeConfiguration. A save() operation is special to file-based configurations while a CompositeConfiguration supports all types of configurations. In this case I think, it is acceptable for the user to do something like this: ((FileConfiguration) config.getInMemoryConfiguration()).save()); Oliver --------------------------------------------------------------------- To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-user-help@jakarta.apache.org