[configuration] XMLConfiguration and ConfigurationFactory

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

[configuration] XMLConfiguration and ConfigurationFactory

thomas peter
i need a hint what to use for the following scenario:

i'd like to have a central config.xml where i include my additional
config files (<configuration><xml
fileName="a-config.xml"/></configuration>).

so i create a ConfigurationFactory(config.xml) and get a configuration
object via getConfiguration().

the referenced files, that are included in my config.xml, are xml-files
as well, they are more complex than property-files too, and can overlap
each other:
<tags>
 <tag>
  <subtag>value1</subtag>
 </tag>
 <tag>
  <subtag>value2</subtag>
  <othersubtag>value43</othersubtag>
 </tag>
</tags>

as i saw in the tutorials, the most powerfull way to handle these
structures is to see them as XMLConfiguration.
But the ConfigurationFactory only deliveres Configurations.
any hint's how to resolve the problem?
am i doing things wrong?

thanx,
thomas

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

Reply | Threaded
Open this post in threaded view
|

Re: [configuration] XMLConfiguration and ConfigurationFactory

Oliver Heger-3
thomas peter wrote:

> i need a hint what to use for the following scenario:
>
> i'd like to have a central config.xml where i include my additional
> config files (<configuration><xml
> fileName="a-config.xml"/></configuration>).
>
> so i create a ConfigurationFactory(config.xml) and get a configuration
> object via getConfiguration().
>
> the referenced files, that are included in my config.xml, are xml-files
> as well, they are more complex than property-files too, and can overlap
> each other:
> <tags>
>  <tag>
>   <subtag>value1</subtag>
>  </tag>
>  <tag>
>   <subtag>value2</subtag>
>   <othersubtag>value43</othersubtag>
>  </tag>
> </tags>
>
> as i saw in the tutorials, the most powerfull way to handle these
> structures is to see them as XMLConfiguration.
> But the ConfigurationFactory only deliveres Configurations.
> any hint's how to resolve the problem?
> am i doing things wrong?
>
> thanx,
> thomas
>

The CompositeConfiguration you obtain from a ConfigurationFactory simply
passes the keys of the getter methods you call to the contained
configurations. If these are XMLConfigurations, they will understand the
extended syntax as described in the tutorial. So there is no need to do
something special. But maybe I don't fully understand your use case?

What you also can do is to use an <additional> tag in your configuration
definition file, e.g.:

<configuration>
   <additional>
     <xml fileName="xmlconfig1.xml"/>
     <xml fileName="xmlconfig2.xml"/>
     ...
   </additional>
</configuration>

This will combine all declared configuration sources into a single
hierarchical configuration. (But from the factory you will still obtain
a CompositeConfiguration; this will contain a single hierarchical
configuration, which is the combination of the declared configurations.)


Oliver

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

Reply | Threaded
Open this post in threaded view
|

Re: [configuration] XMLConfiguration and ConfigurationFactory

thomas peter
thank you oliver. i didn't notice that my first post made it to the list
- the mailarchive isn't the fastest (i wasn't subscribed at that time)
gmane works better.

Oliver Heger wrote:
> The CompositeConfiguration you obtain from a ConfigurationFactory simply
> passes the keys of the getter methods you call to the contained
> configurations. If these are XMLConfigurations, they will understand the
> extended syntax as described in the tutorial. So there is no need to do
> something special. But maybe I don't fully understand your use case?

what i try to do is:

<root>
  <source>
    <db>
      <driver></driver>
      <url></url>
      <user></user>
      <password></password>
    </db>
    <query></query>
    <rrd>
      <file></file>
      <rra></rra>
    </rrd>
  </source>
  <source>
    <cmd>
      <shell></shell>
    </cmd>
    <rrd>
      <file></file>
      <rra></rra>
    </rrd>
  </source>
...
</root>

iterate over all 'source'-nodes and read their children.
i can't see the wood for the trees.
thanx. thomas

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