Search in sources :

Example 1 with AMXBootService

use of fish.payara.admin.amx.AMXBootService in project Payara by payara.

the class SetAmxEnabled method execute.

@Override
public void execute(AdminCommandContext context) {
    ActionReport actionReport = context.getActionReport();
    Config targetConfig = targetUtil.getConfig(target);
    AMXConfiguration metricsConfiguration = targetConfig.getExtensionByType(AMXConfiguration.class);
    try {
        ConfigSupport.apply(new SingleConfigCode<AMXConfiguration>() {

            @Override
            public Object run(final AMXConfiguration configProxy) throws PropertyVetoException, TransactionFailure {
                configProxy.setEnabled(enabled.toString());
                actionReport.setActionExitCode(ActionReport.ExitCode.SUCCESS);
                return configProxy;
            }
        }, metricsConfiguration);
        AMXBootService bootService = habitat.getService(AMXBootService.class);
        bootService.setEnabled(enabled, dynamic);
    } catch (TransactionFailure ex) {
        LOGGER.log(Level.WARNING, "Exception during command set-amx-enabled: {0}", ex.getCause().getMessage());
        actionReport.setMessage(ex.getCause().getMessage());
        actionReport.setActionExitCode(ActionReport.ExitCode.FAILURE);
    }
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) TransactionFailure(org.jvnet.hk2.config.TransactionFailure) AMXConfiguration(fish.payara.admin.amx.config.AMXConfiguration) Config(com.sun.enterprise.config.serverbeans.Config) ActionReport(org.glassfish.api.ActionReport) AMXBootService(fish.payara.admin.amx.AMXBootService)

Aggregations

Config (com.sun.enterprise.config.serverbeans.Config)1 AMXBootService (fish.payara.admin.amx.AMXBootService)1 AMXConfiguration (fish.payara.admin.amx.config.AMXConfiguration)1 PropertyVetoException (java.beans.PropertyVetoException)1 ActionReport (org.glassfish.api.ActionReport)1 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)1