i would like to have my properties file to be reloaded every xx seconds. My code :
...
configuration = new PropertiesConfiguration();
configuration.setFileName(filename);
if (configuration.getFile().exists()) {
configuration.load();
final FileChangedReloadingStrategy strategy = new FileChangedReloadingStrategy();
strategy.setRefreshDelay(3000);
configuration.setReloadingStrategy(strategy);
} else {
LOGGER.warn("Configuration file '{}' not found", filename);
}
...
But my file is never reloaded :( any idea?
Edit : Actually i think my problem comes from the fact that i override the load() method :
private static final class SystemPropertiesConfiguration extends PropertiesConfiguration {
public SystemPropertiesConfiguration(String fileName) throws ConfigurationException
{
super(fileName);
}
@Override
public synchronized void load(final Reader in) throws ConfigurationException {
super.load(in);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Updating system properties");
}
final boolean debugEnabled = LOGGER.isDebugEnabled();
final Iterator<String> ite = getKeys();
String key;
while (ite.hasNext()) {
key = ite.next();
if (debugEnabled) {
LOGGER.debug("Updating system property: {}", key);
}
System.setProperty(key, getString(key));
}
}
}
The purpose is actually to push the properties in System. So my question is : is the FileChangedReloadingStrategy calls the PropertiesConfiguration.load() method?