Search in sources :

Example 6 with AMXConfiguration

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));
            }
        }
    }
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) TransactionFailure(org.jvnet.hk2.config.TransactionFailure) AMXConfiguration(fish.payara.admin.amx.config.AMXConfiguration) PropertyChangeEvent(java.beans.PropertyChangeEvent)

Aggregations

AMXConfiguration (fish.payara.admin.amx.config.AMXConfiguration)6 PropertyVetoException (java.beans.PropertyVetoException)4 ActionReport (org.glassfish.api.ActionReport)4 Config (com.sun.enterprise.config.serverbeans.Config)3 MonitoringService (com.sun.enterprise.config.serverbeans.MonitoringService)3 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)3 ColumnFormatter (com.sun.enterprise.util.ColumnFormatter)2 HashMap (java.util.HashMap)2 Properties (java.util.Properties)2 AMXBootService (fish.payara.admin.amx.AMXBootService)1 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 ManagementFactory.getPlatformMBeanServer (java.lang.management.ManagementFactory.getPlatformMBeanServer)1 MBeanServer (javax.management.MBeanServer)1 CommandRunner (org.glassfish.api.admin.CommandRunner)1 SingleConfigCode (org.jvnet.hk2.config.SingleConfigCode)1