public ExecutedHostRequest execute(final ProxyOperationListener listener) {
boolean trace = HOST_CONTROLLER_LOGGER.isTraceEnabled();
if (trace) {
HOST_CONTROLLER_LOGGER.tracef("Sending %s to %s", operation, name);
}
final TransactionalProtocolClient client = proxyController.getProtocolClient();
final OperationMessageHandler messageHandler = new DelegatingMessageHandler(context);
final OperationAttachments operationAttachments = new DelegatingOperationAttachments(context);
final SubsystemInfoOperationListener subsystemListener = new SubsystemInfoOperationListener(listener, proxyController.getTransformers());
try {
final OperationTransformer.TransformedOperation transformationResult = proxyController.transformOperation(context, operation);
final ModelNode transformedOperation = transformationResult.getTransformedOperation();
final ProxyOperation proxyOperation = new ProxyOperation(name, transformedOperation, messageHandler, operationAttachments);
try {
// Make sure we preserve the operation headers like PrepareStepHandler.EXECUTE_FOR_COORDINATOR
if(transformedOperation != null) {
transformedOperation.get(OPERATION_HEADERS).set(operation.get(OPERATION_HEADERS));
// If the operation was transformed in any way
if(operation != transformedOperation) {
// push all operations (incl. read-only) to the servers
transformedOperation.get(OPERATION_HEADERS, ServerOperationsResolverHandler.DOMAIN_PUSH_TO_SERVERS).set(true);
}
}
final AsyncFuture<ModelNode> result = client.execute(subsystemListener, proxyOperation);
return new ExecutedHostRequest(result, transformationResult);
} catch (IOException e) {
// Handle protocol failures
final TransactionalProtocolClient.PreparedOperation<ProxyOperation> result = BlockingQueueOperationListener.FailedOperation.create(proxyOperation, e);
subsystemListener.operationPrepared(result);