use of fish.payara.admin.amx.config.AMXConfiguration in project Payara by payara.
the class SetJMXMonitoringConfiguration method updateConfiguration.
/**
* Updates the configuration attributes for the
* MonitoringServiceConfiguration given to it.
*
* @param monitoringConfig
* @throws PropertyVetoException
*/
private void updateConfiguration(MonitoringServiceConfiguration monitoringConfig) throws PropertyVetoException, TransactionFailure {
if (null != enabled) {
monitoringConfig.setEnabled(String.valueOf(enabled));
}
if (null != amx) {
AMXConfiguration amxConfig = serviceLocator.getService(AMXConfiguration.class);
ConfigSupport.apply(new SingleConfigCode<AMXConfiguration>() {
@Override
public Object run(final AMXConfiguration amxConfigProxy) throws PropertyVetoException, TransactionFailure {
amxConfigProxy.setEnabled((String.valueOf(amx)));
return amxConfigProxy;
}
}, amxConfig);
monitoringConfig.setAmx(null);
}
if (null != logfrequency) {
monitoringConfig.setLogFrequency(logfrequency);
}
if (null != logfrequencyunit) {
monitoringConfig.setLogFrequencyUnit(logfrequencyunit);
}
final Set<String> notifierNames = NotifierUtils.getNotifierNames(serviceLocator);
List<String> notifiers = monitoringConfig.getNotifierList();
if (enableNotifiers != null) {
for (String notifier : enableNotifiers) {
if (notifierNames.contains(notifier)) {
if (!notifiers.contains(notifier)) {
notifiers.add(notifier);
}
} else {
throw new PropertyVetoException("Unrecognised notifier " + notifier, new PropertyChangeEvent(monitoringConfig, "notifiers", notifiers, notifiers));
}
}
}
if (disableNotifiers != null) {
for (String notifier : disableNotifiers) {
if (notifierNames.contains(notifier)) {
notifiers.remove(notifier);
} else {
throw new PropertyVetoException("Unrecognised notifier " + notifier, new PropertyChangeEvent(monitoringConfig, "notifiers", notifiers, notifiers));
}
}
}
if (setNotifiers != null) {
notifiers.clear();
for (String notifier : setNotifiers) {
if (notifierNames.contains(notifier)) {
if (!notifiers.contains(notifier)) {
notifiers.add(notifier);
}
} else {
throw new PropertyVetoException("Unrecognised notifier " + notifier, new PropertyChangeEvent(monitoringConfig, "notifiers", notifiers, notifiers));
}
}
}
}
Aggregations