use of org.apache.commons.configuration.event.ConfigurationEvent in project chassis by Kixeye.
the class MetricsCloudWatchConfiguration method addConfigurationListener.
private void addConfigurationListener() {
final MetricsCloudWatchConfiguration springConfig = this;
ConfigurationManager.getConfigInstance().addConfigurationListener(new ConfigurationListener() {
@Override
public synchronized void configurationChanged(ConfigurationEvent event) {
if (!(event.getType() == AbstractConfiguration.EVENT_SET_PROPERTY || event.getType() == AbstractConfiguration.EVENT_ADD_PROPERTY)) {
return;
}
if (event.isBeforeUpdate()) {
return;
}
String name = event.getPropertyName();
if (!(name.equals(METRICS_AWS_ENABLED) || name.equals(METRICS_AWS_FILTER) || name.equals(METRICS_AWS_PUBLISH_INTERVAL) || name.equals(METRICS_AWS_PUBLISH_INTERVAL_UNIT))) {
return;
}
springConfig.enabled = name.equals(METRICS_AWS_ENABLED) ? Boolean.parseBoolean(event.getPropertyValue() + "") : springConfig.enabled;
destroyReporter();
if (springConfig.enabled) {
createReporter();
}
}
});
}
Aggregations