1

I've got a DefaultConfigurationBuilder (from commons-configuration v1.9). This object (named config) is initialized by this very simple file :

<?xml version="1.0" encoding="UTF-8" ?>

 <configuration>
<system/>
<properties fileName="webapp-commons.properties"  throwExceptionOnMissing="true">
    <reloadingStrategy refreshDelay="1000" config-class="org.apache.commons.configuration.reloading.FileChangedReloadingStrategy"/>
</properties>

So a modification to webapp-commons.properties file must force the reload of the file. But this is not working as expected. Here is my little test :

 log.debug("Go pour modifier le fichier !");
    for (int i=0; i < 10 ; i++) {
        System.out.println("-- value : "+config.getString("clouderial.business.application.name"));
        Thread.sleep(3000);
    }
    log.debug("Vous auriez du modifier le fichier");

The value "clouderial.business.application.name" never change.

Any help woould be appreciated.

JM.

jmcollin92
  • 2,896
  • 6
  • 27
  • 49

1 Answers1

1

The solution is simple : just add a header to your configuration file :

<header>
   <result forceReloadCheck="true"/>
</header>

and it works.

The complete configuration file is now :

<?xml version="1.0" encoding="UTF-8" ?>

<configuration>
    <header>
        <result forceReloadCheck="true"/>
    </header>
    <system/>
    <properties fileName="webapp-commons.properties"  throwExceptionOnMissing="true">
            <reloadingStrategy refreshDelay="1000" config-class="org.apache.commons.configuration.reloading.FileChangedReloadingStrategy"/>     
    </properties>
</configuration>
jmcollin92
  • 2,896
  • 6
  • 27
  • 49
  • But, you will see that the DefaultConfigurationBuilder is not reloading itself (only the embedded files). This is explain [https://issues.apache.org/jira/browse/CONFIGURATION-523#comment-13559438] why. – jmcollin92 Jan 22 '13 at 07:08