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);
}
}
Aggregations