Search in sources :

Example 1 with OperationStepHandler

use of org.jboss.as.controller.OperationStepHandler in project wildfly by wildfly.

the class ConfigurationResource method registerOperations.

@Override
public void registerOperations(ManagementResourceRegistration resourceRegistration) {
    super.registerOperations(resourceRegistration);
    resourceRegistration.registerOperationHandler(UPDATE_DEFINITION, new OperationStepHandler() {

        @Override
        public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
            context.completeStep(OperationContext.ResultHandler.NOOP_RESULT_HANDLER);
        }
    });
}
Also used : OperationContext(org.jboss.as.controller.OperationContext) OperationStepHandler(org.jboss.as.controller.OperationStepHandler) OperationFailedException(org.jboss.as.controller.OperationFailedException) ModelNode(org.jboss.dmr.ModelNode)

Example 2 with OperationStepHandler

use of org.jboss.as.controller.OperationStepHandler in project wildfly by wildfly.

the class BroadcastGroupAdd method populateModel.

@Override
protected void populateModel(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException {
    super.populateModel(context, operation, resource);
    final ModelNode connectorRefs = resource.getModel().get(CONNECTOR_REFS.getName());
    if (connectorRefs.isDefined()) {
        context.addStep(new OperationStepHandler() {

            @Override
            public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
                validateConnectors(context, operation, connectorRefs);
            }
        }, OperationContext.Stage.MODEL);
    }
}
Also used : OperationContext(org.jboss.as.controller.OperationContext) OperationStepHandler(org.jboss.as.controller.OperationStepHandler) OperationFailedException(org.jboss.as.controller.OperationFailedException) ModelNode(org.jboss.dmr.ModelNode)

Example 3 with OperationStepHandler

use of org.jboss.as.controller.OperationStepHandler in project wildfly by wildfly.

the class SecurityDomainAdd method performRuntime.

@Override
protected void performRuntime(OperationContext context, ModelNode operation, final ModelNode model) {
    PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR));
    final String securityDomain = address.getLastElement().getValue();
    // This needs to run after all child resources so that they can detect a fresh state
    context.addStep(new OperationStepHandler() {

        @Override
        public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
            final Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS);
            launchServices(context, securityDomain, Resource.Tools.readModel(resource));
            // Rollback handled by the parent step
            context.completeStep(OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER);
        }
    }, OperationContext.Stage.RUNTIME);
}
Also used : OperationContext(org.jboss.as.controller.OperationContext) OperationStepHandler(org.jboss.as.controller.OperationStepHandler) PathAddress(org.jboss.as.controller.PathAddress) OperationFailedException(org.jboss.as.controller.OperationFailedException) Resource(org.jboss.as.controller.registry.Resource) ModelNode(org.jboss.dmr.ModelNode)

Example 4 with OperationStepHandler

use of org.jboss.as.controller.OperationStepHandler in project wildfly by wildfly.

the class AbstractPicketLinkMetricsOperationHandler method execute.

@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
    context.addStep(new OperationStepHandler() {

        @Override
        public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
            final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
            final String name = address.getLastElement().getValue();
            final String attributeName = operation.require(NAME).asString();
            final ServiceController<?> controller = context.getServiceRegistry(false).getRequiredService(createServiceName(name));
            try {
                PicketLinkFederationService<?> service = (PicketLinkFederationService<?>) controller.getValue();
                doPopulateResult(service.getMetrics(), context.getResult(), attributeName);
            } catch (Exception e) {
                throw PicketLinkLogger.ROOT_LOGGER.failedToGetMetrics(e.getMessage());
            }
            context.completeStep(OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER);
        }
    }, OperationContext.Stage.RUNTIME);
    context.completeStep(OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER);
}
Also used : OperationContext(org.jboss.as.controller.OperationContext) PicketLinkFederationService(org.wildfly.extension.picketlink.federation.service.PicketLinkFederationService) OperationStepHandler(org.jboss.as.controller.OperationStepHandler) PathAddress(org.jboss.as.controller.PathAddress) OperationFailedException(org.jboss.as.controller.OperationFailedException) ServiceController(org.jboss.msc.service.ServiceController) ModelNode(org.jboss.dmr.ModelNode) OperationFailedException(org.jboss.as.controller.OperationFailedException)

Example 5 with OperationStepHandler

use of org.jboss.as.controller.OperationStepHandler in project wildfly by wildfly.

the class IDMConfigWriteAttributeHandler method execute.

@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
    context.addStep(new OperationStepHandler() {

        @Override
        public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
            final PathAddress address = getParentAddress(PathAddress.pathAddress(operation.require(OP_ADDR)));
            Resource resource = context.readResourceFromRoot(address);
            final ModelNode parentModel = Resource.Tools.readModel(resource);
            PartitionManagerAddHandler.INSTANCE.validateModel(context, address.getLastElement().getValue(), parentModel);
            context.stepCompleted();
        }
    }, OperationContext.Stage.MODEL);
    super.execute(context, operation);
}
Also used : OperationContext(org.jboss.as.controller.OperationContext) OperationStepHandler(org.jboss.as.controller.OperationStepHandler) PathAddress(org.jboss.as.controller.PathAddress) OperationFailedException(org.jboss.as.controller.OperationFailedException) Resource(org.jboss.as.controller.registry.Resource) ModelNode(org.jboss.dmr.ModelNode)

Aggregations

OperationStepHandler (org.jboss.as.controller.OperationStepHandler)76 ModelNode (org.jboss.dmr.ModelNode)57 OperationContext (org.jboss.as.controller.OperationContext)45 OperationFailedException (org.jboss.as.controller.OperationFailedException)40 PathAddress (org.jboss.as.controller.PathAddress)31 AttributeDefinition (org.jboss.as.controller.AttributeDefinition)23 Resource (org.jboss.as.controller.registry.Resource)19 SimpleAttributeDefinition (org.jboss.as.controller.SimpleAttributeDefinition)17 ReloadRequiredWriteAttributeHandler (org.jboss.as.controller.ReloadRequiredWriteAttributeHandler)14 PathElement (org.jboss.as.controller.PathElement)9 ServiceController (org.jboss.msc.service.ServiceController)8 ServiceName (org.jboss.msc.service.ServiceName)8 Map (java.util.Map)7 ImmutableManagementResourceRegistration (org.jboss.as.controller.registry.ImmutableManagementResourceRegistration)7 ArrayList (java.util.ArrayList)6 List (java.util.List)5 ObjectTypeAttributeDefinition (org.jboss.as.controller.ObjectTypeAttributeDefinition)5 PropertiesAttributeDefinition (org.jboss.as.controller.PropertiesAttributeDefinition)5 SimpleOperationDefinitionBuilder (org.jboss.as.controller.SimpleOperationDefinitionBuilder)5 ManagementResourceRegistration (org.jboss.as.clustering.controller.ManagementResourceRegistration)4