commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas Eichstädt-Engelen" <>
Subject Re: [configuration] Overriden Properties in CombinedConfiguration and the configuratinAt method
Date Sun, 28 Jan 2007 18:52:23 GMT
Hi Oliver,

thanks for your quick response.

> Or could you provide a more detailed example with such an overridden
> bean declaration that causes ambigous keys?

Let's assume i have two XmlConfigurations. Both of which are configured in my configuration-definition.xml
file. The order is SpecialisedConfiguration at first followed by GeneralConfiguration.

SpecialisedConfig (lies somewhere editable for my operationsTeam)

  <job_1 secretKey="geheim" />

and the GeneralConfig (is packed into a war-file)

  <job_1 config-class="de.eichstaedt.ClassToCreateViaBeanUtils"
    attribut_2="bar" />
  <job_2 [...] />

Now I use a DefaultConfigurationBuilder to create my configuration object as described in
the UserGuide:

DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
builder.setFile(new File("configuration.xml"));
CombinedConfiguration cc = builder.getConfiguration(true);

After that i start the bean creation with:

// get a combined subConfig with 
// overridenValues to build a Bean from
HierchicalConfiguration config = cc.configurationAt("jobs.job_1")
BeanDeclaration decl = new XMLBeanDeclaration(config);
ClassToCreateViaBeanUtils createdClass = (ClassToCreateViaBeanUtils) BeanHelper.createBean(decl);

At this point i assumed to get a view to one combined configuration and to get a Configuration
with the overriden secretKey attribute. But an exception is thrown instead.

My workaround is to create a combined node via getRootNode(). It worked but in this case all
that previoulsy configured stuff e.g. ReloadingStratety, NodeCombiner, etc. disappears because
i created a new XmlConfiguration from that RootNode.

I think the exception at configruationAt() - implemented in HierarchicalConfiguration - occured
because it simply fetches a nodeList with the given key. It does not take into account that
one configuration has overriden some values of the other one. That is clear because the overriding
behaviour is added deeper in the ClassHierarchy initially with the CombinedConfiguration.
Thus i assumed to find a specialised version of configurationAt() dealing with the combinedRoot
in that class.

Does my question became clearer now? Sorry for my english ...

Kind regards from Germany,

Thomas E.-E.

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

View raw message