commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver Heger <oliver.he...@oliver-heger.de>
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="application.properties"/>
>   <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>!

HTH
Oliver

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message