[configuration] loading xml-file via configurationFactory

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[configuration] loading xml-file via configurationFactory

thomas peter
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

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [configuration] loading xml-file via configurationFactory

Oliver Heger-3
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: [hidden email]
For additional commands, e-mail: [hidden email]