Questions tagged [apache-commons-config]

The Commons Configuration software library provides a generic configuration interface which enables a Java application to read configuration data from a variety of sources.

The Apache Commons Configuration software library provides a generic configuration interface which enables a Java application to read configuration data from a variety of sources. Commons Configuration provides typed access to single, and multi-valued configuration parameters as demonstrated by the following code:

Double double = config.getDouble("number");
Integer integer = config.getInteger("number");

Configuration parameters may be loaded from the following sources:

  • Properties files
  • XML documents
  • Windows INI files
  • Property list files (plist)
  • JNDI
  • JDBC Datasource
  • System properties
  • Applet parameters
  • Servlet parameters

Different configuration sources can be mixed using a ConfigurationFactory and a CompositeConfiguration. Additional sources of configuration parameters can be created by using custom configuration objects. This customization can be achieved by extending AbstractConfiguration or AbstractFileConfiguration.

Official Website: http://commons.apache.org/configuration/

Useful Links:

146 questions
3
votes
1 answer

addProperty including blanks with XMLConfiguration

I'm using the Apache Commons Configuration. How can I add a property (String with blanks) to the configuration that I only get one single property? config.addProperty("date", "08.05.2011, 15:20"); leads to two…
Thomas
  • 225
  • 5
  • 13
3
votes
2 answers

XMLConfiguration to String

I'm using the Apache Commons Configuration. How can I get directly a String of the XMLConfiguration without saving it to a file? Thank you very much.
Thomas
  • 225
  • 5
  • 13
3
votes
1 answer

Commons - Configuration CompositeConfiguration and Preferences

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 =…
Random
  • 325
  • 1
  • 3
  • 15
3
votes
0 answers

FileBasedConfigurationBuilder from Apache Commons Configuration2 not writing the configuration file

I need to write a simple configuration file using apache-commons-configuration but no matter what I try, it's not writing anything to the file. This is how the file should look like bar This is what I'm doing to…
Magno Nascimento
  • 615
  • 4
  • 19
3
votes
1 answer

apache commons configuration2 :ConfigurationEvent is not generated for ReloadingFileBasedConfigurationBuilder

Using commons configuration2, i would like to be notified when a specific file based property changes. For that am using a ReloadingFileBasedConfigurationBuilder, PeriodicReloadingTrigger. As per the documentation, the builder should be used as a…
3
votes
1 answer

dependency for Apache Commons Configuration2 declared as optional

I try to simple usage of simple Apache Commons Configuration2 loading configuration from a properties file. Here is my dependency: org.apache.commons
Garret Wilson
  • 18,219
  • 30
  • 144
  • 272
3
votes
1 answer

Direct way to convert org.apache.commons.configuration.Configuration to java.util.Properties

I am able to convert org.apache.commons.configuration.Configuration to java.util.Properties using: Properties props = new Properties(); Configuration config = new PropertiesConfiguration(fileName); Iterator iter = config.getKeys(); while…
Dev
  • 13,492
  • 19
  • 81
  • 174
3
votes
1 answer

How to save xml configuration filled with values from properties file in Apache Commons Configuration can't save

I am trying to use Apache Commons Configuration in groovy script to read values from a simple properties file and fill an XML template with these values from that file. The goal of this example is to be able to launch multiple instances of Tomcat…
3
votes
1 answer

PropertiesConfiguration doesn't want to reload

i would like to have my properties file to be reloaded every xx seconds. My code : ... configuration = new PropertiesConfiguration(); configuration.setFileName(filename); if (configuration.getFile().exists()) { configuration.load(); final…
Lempkin
  • 1,458
  • 2
  • 26
  • 49
3
votes
2 answers

Create JSON configuration from string using Apache commons configuration

Is it possible to create a JSON configuration form a String in Apache commons configuration so that I can get some values from it? For example, if I'd have a String containing this configuration, I'd like to be able to convert it into an…
user1779715
3
votes
1 answer

Apache commons config ignores outermost XML tag? Why? Am I doing something wrong?

Ok, I used to use apache commons config years ago a little, and have probably forgotten some things. I'm a little baffled by what's going on, and it seems counter-intuitive to me. So, here's my code: public static void main(String[] args) throws…
King_V
  • 285
  • 1
  • 2
  • 7
3
votes
1 answer

Missing class: org.apache.commons.lang.exception.NestableException

I am following an online example to read information from a basic properties file. As I started to implement the code I keep getting the following error at the top of the class. The type org.apache.commons.lang.exception.NestableException cannot…
JME
  • 2,293
  • 9
  • 36
  • 56
3
votes
2 answers

apache commons configuration: setting an xml namespace for the root element

When saving a configuration file, I need to specify the xmlns for the root element (by default ). The reason is, I validate (with a schema) upon loading the configuration file later. I can't seem to find how commons-configuration…
Miquel
  • 15,405
  • 8
  • 54
  • 87
3
votes
1 answer

Singleton configuration class? concrete example

I have started reading the Apache commons documentation but its very extensive so I am hoping someone can answer a simple question so I don't need to read all of it just to start using it for basic configuration. I am losing patience really quick…
user1443778
  • 581
  • 1
  • 5
  • 20
3
votes
1 answer

Can I provide my own variable interpolator for spring?

I've learnt that I can provide Spring with a element, which appears to use a PropertyPlaceholderConfigurer to interpolate variables (i.e. replace tokens like ${foo}) against a properties file. Is there a way to…
bacar
  • 9,761
  • 11
  • 55
  • 75
1 2
3
9 10