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)

<jobs>
  <job_1 secretKey="geheim" />
</jobs>

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

<jobs>
  <job_1 config-class="de.eichstaedt.ClassToCreateViaBeanUtils"
    secretKey="anfang"
    attribut_1="foo"
    attribut_2="bar" />
  <job_2 [...] />
  [...]
</jobs>


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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to