commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver Heger <>
Subject Re: [configuration] can you use wild cards to read in multiple files
Date Wed, 16 Nov 2011 21:31:02 GMT
Am 15.11.2011 14:37, schrieb Billy Newman:
> I am trying to read in multiple files into a configuration. The file
> names are dynamic so I cannot hard code to names in my config.xml
> file.
> File names might be something like:
> Some-nodes.xml
> More-nodes.xml
> Is there a way I can specify *-nodes.xml in my config.xml file to load
> all files that match?

This feature is not directly supported, but it could be implemented on 
top of DefaultConfigurationBuilder.

The DefaultConfigurationBuilder class is the option of choice if 
multiple configuration files are to be loaded. It extends 
XMLConfiguration and thus can load an XML-based configuration definition 
file with the configuration sources to be loaded.

It is also possible to use methods like addProperty() or setProperty() 
to create or manipulate a configuration definition file dynamically. The 
keys of the properties have to match the XML structures used by such a 
document. The unit tests for this class [1] contain some examples how 
this could look like.

After you are done with manipulating the definition, just call 
getConfiguration(false) on the DefaultConfigurationBuilder instance. The 
resulting combined configuration will then contain all the configuration 
sources you have added.



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

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

View raw message