プロパティ ファイルを xx 秒ごとにリロードしたいと考えています。私のコード:
...
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);
}
...
しかし、私のファイルは決してリロードされません:(何か考えはありますか?
編集:実際、私の問題は、load()メソッドをオーバーライドするという事実に起因すると思います:
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));
}
}
}
目的は、実際にはシステムにプロパティをプッシュすることです。だから私の質問は: FileChangedReloadingStrategy は PropertiesConfiguration.load() メソッドを呼び出しますか?