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?
确保更改了部署目录中的文件而不是IDE中的源文件。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.