3

I am using CompositeConfiguration to read properties from multiple sources (like .propeties files, xml files, System properties etc) as below.

ConfigurationFactory factory = new ConfigurationFactory("config.xml");
compConfig = (CompositeConfiguration)factory.getConfiguration();
compConfig.getProperty(propName);

Config.xml

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<properties fileName="Properties1.properties"/>
<properties fileName="Properties2.properties"/>
<properties fileName="Properties3.properties"/>
<system/>
</configuration>

In addition to these files, I would like to read Preferences saved in Windows registry as well. I understand that java.util.Preferences API can be used to access values in Windows Registry. I was just wondering if there is a way to read them as well using PropertiesConfiguration?

Thanks

skaffman
  • 398,947
  • 96
  • 818
  • 769
Random
  • 325
  • 1
  • 3
  • 15

1 Answers1

1

Looks like you would need to provide your own implementation of the AbstractConfiguration class. You could also use the JNDIConfiguration class if you're willing to pay for a JNDI provider for the windows registry

qwerty
  • 3,801
  • 2
  • 28
  • 43
  • Thanks for quick reply David. Looks like I have to write my own implementation. Guess I can use this as reference. http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/PreferencesConfiguration.java?view=markup – Random Apr 01 '11 at 10:33