Good afternoon.
I am using commons configuration as follows:
 
commons_configuration.xml:
 
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <properties fileName="test.properties" config-name="test">
   <reloadingStrategy refreshDelay="30000"
     
config-class="org.apache.commons.configuration.reloading.FileChangedReloadingStrategy"/>
  </properties>
</configuration>
 
===============================================
CommonsConfiguration.java
----------------------------------------
 
public class CommonsConfiguration {
 
 
 private static CombinedConfiguration configuration;
 
 
 static {
  try {
   DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder(new 
File("/var/commons_configuration.xml"));
   configuration = builder.getConfiguration(true);
  } catch (ConfigurationException e) {
   e.printStackTrace();
  }
 }
 
 
 public static CombinedConfiguration getCombinedConfiguration() {
  return configuration;
 }
}
=================================================================
When I use commons configuration as follows in any instance/static method:
 
String testMe= (String) 
CommonsConfiguration.getCombinedConfiguration().getConfiguration("test").getProperty("test.me");
 
It work fine with reloading strategy. In other words when I change the 
test.properties property value, the change gets reflected.
 
In some class I was accessing the property in a static block as follows:
public Sample {
 static{
  String testMe = String) 
CommonsConfiguration.getCombinedConfiguration().getConfiguration("test").getProperty("test.me");
  //do something
 }
}
 
If a property is accessed in static block and the property value is changed, 
the change does not get reflected.
Is there any work around to access a property in static block and have the 
property change reflected.
 
I appreciate and thank you for your feed back.
 
Thanks
Venkat

Reply via email to