commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Borut BolĨina <...@najdi.si>
Subject [Configuration] save
Date Mon, 08 May 2006 14:13:22 GMT
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

    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <configuration>
      <properties fileName="i-want-to-save-here.properties"/>
      <xml fileName="a.xml"/>
      <xml fileName="b.xml"/>
      <xml fileName="c.xml"/>
    </configuration>

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


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message