context.addStep(new OperationStepHandler() {
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
final ServiceTarget serviceTarget = context.getServiceTarget();
final ServiceVerificationHandler verificationHandler = new ServiceVerificationHandler();
ModifiableResourceAdaptors resourceAdapters = buildResourceAdaptersObject(operation);
final ServiceController<?> raService = context.getServiceRegistry(false).getService(
ConnectorServices.RESOURCEADAPTERS_SERVICE);
ServiceController<?> controller = null;
if (raService == null) {
controller = serviceTarget.addService(ConnectorServices.RESOURCEADAPTERS_SERVICE,
new ResourceAdaptersService(resourceAdapters)).setInitialMode(Mode.ACTIVE).addListener(verificationHandler).install();
} else {
((ModifiableResourceAdaptors) raService.getValue()).addAllResourceAdapters(resourceAdapters.getResourceAdapters());
}
context.addStep(verificationHandler, OperationContext.Stage.VERIFY);
if (context.completeStep() == OperationContext.ResultAction.ROLLBACK) {