final ModelNode result = new ModelNode().setEmptyList();
boolean sawExtensionAdd = false;
List<ParsedBootOp> postExtensionOps = null;
ParallelExtensionAddHandler parallelExtensionAddHandler = executorService == null ? null : new ParallelExtensionAddHandler(executorService);
ParallelBootOperationStepHandler parallelSubsystemHandler = (executorService != null && processType.isServer() && runningModeControl.getRunningMode() == RunningMode.NORMAL)
? new ParallelBootOperationStepHandler(executorService, rootRegistration, processState) : null;
boolean registeredParallelSubsystemHandler = false;
int subsystemIndex = 0;
for (ModelNode bootOp : bootList) {
final ParsedBootOp parsedOp = new ParsedBootOp(bootOp, result.add());
if (postExtensionOps != null) {
// Handle cases like AppClient where extension adds are interleaved with subsystem ops
if (parsedOp.isExtensionAdd()) {
final ExtensionAddHandler stepHandler = (ExtensionAddHandler) rootRegistration.getOperationHandler(parsedOp.address, parsedOp.operationName);
if (parallelExtensionAddHandler != null) {
parallelExtensionAddHandler.addParsedOp(parsedOp, stepHandler);
} else {
context.addStep(parsedOp.response, parsedOp.operation, stepHandler, OperationContext.Stage.MODEL);
}
} else {
if (parallelSubsystemHandler == null || !parallelSubsystemHandler.addSubsystemOperation(parsedOp)) {
// Put any interface/socket op before the subsystem op
if (registeredParallelSubsystemHandler && (parsedOp.isInterfaceOperation() || parsedOp.isSocketOperation())) {
postExtensionOps.add(subsystemIndex++, parsedOp);
} else {
postExtensionOps.add(parsedOp);
}
} else if (!registeredParallelSubsystemHandler) {
ModelNode op = Util.getEmptyOperation("parallel-subsystem-boot", new ModelNode().setEmptyList());
postExtensionOps.add(new ParsedBootOp(op, parallelSubsystemHandler, result.add()));
subsystemIndex = postExtensionOps.size() - 1;
registeredParallelSubsystemHandler = true;
}
}
} else {
final OperationStepHandler stepHandler = rootRegistration.getOperationHandler(parsedOp.address, parsedOp.operationName);
if (!sawExtensionAdd && stepHandler == null) {
// Odd case. An op prior to the first extension add where there is no handler. This would really
// only happen during AS development
ROOT_LOGGER.noHandler(parsedOp.operationName, parsedOp.address);
context.setRollbackOnly();
// stop
break;
} else if (stepHandler instanceof ExtensionAddHandler) {
if (parallelExtensionAddHandler != null) {
parallelExtensionAddHandler.addParsedOp(parsedOp, (ExtensionAddHandler) stepHandler);
if (!sawExtensionAdd) {
ModelNode op = Util.getEmptyOperation("parallel-extension-add", new ModelNode().setEmptyList());
context.addStep(result.add(), op, parallelExtensionAddHandler, OperationContext.Stage.MODEL);
}
} else {