reloadStrategy does not work for files inside <additional> tag using 
DefaultConfigurationBuilder
------------------------------------------------------------------------------------------------

                 Key: CONFIGURATION-460
                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-460
             Project: Commons Configuration
          Issue Type: Bug
          Components: File reloading
    Affects Versions: 1.6
         Environment: Linux x86_64
            Reporter: Azfar Kazmi


In the configuration file that DefaultConfigurationBuilder reads to build a 
CombinedConfiguration, it's possible to include configuration file either 
inside <override> or <additional> xml elements.

Each such declaration, of a file, allows a realodStrategy to be specified (see 
example below). It appears that the reload occurs only for the files inside 
<override> and not for the ones inside <additional>.

Example:

<configuration>
  <header>
    <result forceReloadCheck="true">
      <expressionEngine 
config-class="org.apache.commons.configuration.tree.xpath.XPathExpressionEngine"/>
    </result>
  </header>
  <override>
    <properties fileName="user.properties" config-optional="true">
      <reloadingStrategy refreshDelay="100"
                         
config-class="org.apache.commons.configuration.reloading.FileChangedReloadingStrategy"/>
    </properties>
  </override>
  <additional>
    <properties fileName="application.properties">
      <reloadingStrategy refreshDelay="100"
                         
config-class="org.apache.commons.configuration.reloading.FileChangedReloadingStrategy"/>
    </properties>
  </additional>
</configuration>

In above example, both user.properties and application.properties are supposed 
to reload upon change. However, as tested by the following code, one 
user.properties gets reloaded:

                DefaultConfigurationBuilder dcb = new 
DefaultConfigurationBuilder("example.xml");
                Configuration conf = dcb.getConfiguration();
                System.out.println("user: " + conf.getBoolean("user"));
                System.out.println("application: " + 
conf.getBoolean("application"));

                System.out.println("Change files and then press  to 
continue...");
                System.in.read();
                
                System.out.println("user: " + conf.getBoolean("user"));
                System.out.println("application: " + 
conf.getBoolean("application"));

Output from above code:

user: true
application: true
Change files and then press  to continue...

0 [main] INFO org.apache.commons.configuration.PropertiesConfiguration  - 
Reloading configuration. URL is file:<snipped>/user.properties
user: false
application: true



--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to