commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver Heger <>
Subject Re: [configuration] loading xml-file via configurationFactory
Date Mon, 29 May 2006 19:28:24 GMT
thomas peter wrote:
> I looked in the online-doku, but didn't find the info that fitts to my
> problem.
> how do i get a configuration out of multiple files, configured in only
> one file?
> i'd like to have a config.xml where all other needed configuration files
> are listes in:
> <configuration>
>   <system/>
>   <properties fileName=""/>
>   <xmlfile fileName="component1.xml"/>
>   <xmlfile fileName="component2.xml"/>
> </configuration>
> when reading the above xml-file with creating a new
> ConfigurationFactory("config.xml")
> and then calling the .getConfoguration method, i only get a configuration
> object, but not a XMLConfiguration-Object.
> did i understand things wrong and loading of property files via
> configurationFactory has no equivalent handling for xml-files?
> thanx in advance,
> thomas

The Configuration returned by the ConfigurationFactory is an instance of 
CompositeConfiguration, which is a kind of container for other 
Configuration objects. You can cast the returned object to this type and 
then use methods like getConfiguration(int) to access the contained 
configurations. These will be of the correct classes, like 
PropertiesConfiguration or XMLConfiguration.

Note that the correct tag for loading XML configurations is <xml 
fileName="..."/> and not <xmlfile>!


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

View raw message