@Override
protected void executeRuntimeStep(OperationContext context, ModelNode operation) throws OperationFailedException {
final String operationName = operation.require(OP).asString();
HornetQComponentControl control = null;
boolean appliedToRuntime = false;
Object handback = null;
if (READ_ATTRIBUTE_OPERATION.equals(operationName)) {
readAttributeValidator.validate(operation);
final String name = operation.require(NAME).asString();
if (STARTED.getName().equals(name)) {
control = getHornetQComponentControl(context, operation, false);
context.getResult().set(control.isStarted());
} else {
handleReadAttribute(name, context, operation);
}
} else if (START.equals(operationName)) {
control = getHornetQComponentControl(context, operation, true);
try {
control.start();
appliedToRuntime = true;
context.getResult();
} catch (Exception e) {
context.getFailureDescription().set(e.getLocalizedMessage());
}
} else if (STOP.equals(operationName)) {
control = getHornetQComponentControl(context, operation, true);
try {
control.stop();
appliedToRuntime = true;
context.getResult();
} catch (Exception e) {
context.getFailureDescription().set(e.getLocalizedMessage());
}
} else {
handback = handleOperation(operationName, context, operation);
appliedToRuntime = handback != null;
}
OperationContext.RollbackHandler rh;
if (appliedToRuntime) {
final HornetQComponentControl rhControl = control;
final Object rhHandback = handback;
rh = new OperationContext.RollbackHandler() {
@Override
public void handleRollback(OperationContext context, ModelNode operation) {
try {
if (START.equals(operationName)) {
rhControl.stop();
} else if (STOP.equals(operationName)) {
rhControl.start();
} else {
handleRevertOperation(operationName, context, operation, rhHandback);
}
} catch (Exception e) {
ROOT_LOGGER.revertOperationFailed(e, getClass().getSimpleName(),