use of org.apache.commons.configuration.reloading.FileChangedReloadingStrategy in project distributedlog by twitter.
the class ConfigurationSubscription method initConfig.
private boolean initConfig() {
if (fileConfigs.isEmpty()) {
try {
for (FileConfigurationBuilder fileConfigBuilder : fileConfigBuilders) {
FileConfiguration fileConfig = fileConfigBuilder.getConfiguration();
FileChangedReloadingStrategy reloadingStrategy = new FileChangedReloadingStrategy();
reloadingStrategy.setRefreshDelay(0);
fileConfig.setReloadingStrategy(reloadingStrategy);
fileConfigs.add(fileConfig);
}
} catch (ConfigurationException ex) {
if (!fileNotFound(ex)) {
LOG.error("Config init failed {}", ex);
}
}
}
return !fileConfigs.isEmpty();
}
use of org.apache.commons.configuration.reloading.FileChangedReloadingStrategy in project bookkeeper by apache.
the class ConfigurationSubscription method initConfig.
private boolean initConfig() {
if (fileConfigs.isEmpty()) {
try {
for (FileConfigurationBuilder fileConfigBuilder : fileConfigBuilders) {
FileConfiguration fileConfig = fileConfigBuilder.getConfiguration();
FileChangedReloadingStrategy reloadingStrategy = new FileChangedReloadingStrategy();
reloadingStrategy.setRefreshDelay(0);
fileConfig.setReloadingStrategy(reloadingStrategy);
fileConfigs.add(fileConfig);
}
} catch (ConfigurationException ex) {
if (!fileNotFound(ex)) {
LOG.error("Config init failed {}", ex);
}
}
}
return !fileConfigs.isEmpty();
}
use of org.apache.commons.configuration.reloading.FileChangedReloadingStrategy in project accumulo by apache.
the class MetricsConfiguration method loadConfiguration.
private void loadConfiguration() {
URL metricsUrl = MetricsConfiguration.class.getClassLoader().getResource("accumulo-metrics.xml");
if (metricsUrl == null) {
if (!alreadyWarned)
log.warn("accumulo-metrics.xml was not found on classpath. Metrics collection will be disabled.");
alreadyWarned = true;
notFound = true;
return;
}
try {
xConfig = new XMLConfiguration(metricsUrl);
xConfig.append(getEnvironmentConfiguration());
xConfig.addConfigurationListener(new MetricsConfigListener());
xConfig.setReloadingStrategy(new FileChangedReloadingStrategy());
// every so often to force the FileChangedReloadingStrategy to fire.
if (null == watcher || !watcher.isAlive()) {
watcher = new MetricsConfigWatcher();
watcher.start();
}
notFound = false;
alreadyWarned = false;
} catch (ConfigurationException ce) {
log.error("Error reading accumulo-metrics.xml file.");
notFound = true;
return;
}
if (xConfig != null) {
config = xConfig.interpolatedConfiguration();
// set the enabled boolean from the configuration
enabled = config.getBoolean(enabledName);
if (log.isDebugEnabled())
log.debug("Metrics collection enabled={}", enabled);
} else {
enabled = false;
}
}
use of org.apache.commons.configuration.reloading.FileChangedReloadingStrategy in project ninja by ninjaframework.
the class MessagesImpl method loadLanguageConfiguration.
/**
* Attempts to load a message file and sets the file changed reloading
* strategy on the configuration if the runtime mode is Dev.
*/
private PropertiesConfiguration loadLanguageConfiguration(String fileOrUrl) {
PropertiesConfiguration configuration = SwissKnife.loadConfigurationInUtf8(fileOrUrl);
if (configuration != null && ninjaProperties.isDev()) {
// enable runtime reloading of translations in dev mode
FileChangedReloadingStrategy strategy = new FileChangedReloadingStrategy();
configuration.setReloadingStrategy(strategy);
}
return configuration;
}
Aggregations