[ 
https://issues.apache.org/jira/browse/CONFIGURATION-264?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12489707
 ] 

Oliver Heger commented on CONFIGURATION-264:
--------------------------------------------

To make a SubnodeConfiguration compatible with reloads of its parent 
configuration two things need to be changed:

- An access of the subnode configuration needs to trigger the parent 
configuration, so that it can check if a reload is required.
- When the parent configuration is reloaded, its set of nodes is completely 
replaced. So the subnode configuration has to be reconstructed.

To achieve this, it is necessary to store in the subnode configuration the 
expression that was used to construct it. Then, when the subnode 
configuration's root node is queried (which happens for every property access), 
the parent can be asked to re-evaluate the expression and return the new root 
node. This will also trigger a reload of the parent if necessary.

This solution has the following drawbacks:
- It impacts the performance of SubnodeConfiguration because for each property 
access an additional query has to be performed on the parent.
- If the expression engine is changed on the parent configuration, we are lost.
- Some updates of the parent configuration may cause unexpected results. As an 
example consider that the parent configuration contains a list of properties 
and the subnode configuration points to a single element of this list. If now a 
list element before this element is removed, the subnode configuration will 
point to a different list element when it is reconstructed. This is because the 
expression the subnode configuration is based on cannot be updated according to 
changes on the parent's properties.
- The parent configuration could be changed in a way that the subnode 
configuration becomes invalid (e.g. if the root node of the subnode 
configuration is removed).

Because of these drawbacks I would like to make this solution optional: I would 
add a new configurationAt() method to HierarchicalConfiguration that takes an 
additional boolean argument. If this flag is set to true, the subnode 
configuration will do the described checks and thus will be aware of reloads of 
its parent. Otherwise (which is the default) the subnode configuration will 
behave as it does now (and miss the reloads).

> SubnodeConfiguration does not see reloads of its parent configuration
> ---------------------------------------------------------------------
>
>                 Key: CONFIGURATION-264
>                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-264
>             Project: Commons Configuration
>          Issue Type: Bug
>    Affects Versions: 1.4
>            Reporter: Oliver Heger
>         Assigned To: Oliver Heger
>             Fix For: 1.5
>
>
> The problem can be reproduced as follows:
> 1 config = new XMLConfiguration("c:\\conf.xml");
> 2 config.setReloadingStrategy(new FileChangedReloadingStrategy());
> 3 SubnodeConfiguration parentItemConfig = 
> config.configurationAt("parent-item");
> 4 String ss2 = parentItemConfig.getString("sub-item");
> 5 //Now, <sub-item> node value changes to "new_value"
> 6 ss2 = parentItemConfig.getString("sub-item"); // still returns old_value

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to