Search in sources :

Example 81 with OperationFailedException

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

the class AbstractDataSourceAdd method performRuntime.

@Override
protected void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model) throws OperationFailedException {
    // domains should only be defined when Elytron enabled is undefined or false (default value)
    if (model.hasDefined(AUTHENTICATION_CONTEXT.getName()) && !ELYTRON_ENABLED.resolveModelAttribute(context, model).asBoolean()) {
        throw SUBSYSTEM_DATASOURCES_LOGGER.attributeRequiresTrueAttribute(AUTHENTICATION_CONTEXT.getName(), ELYTRON_ENABLED.getName());
    } else if (ELYTRON_ENABLED.resolveModelAttribute(context, model).asBoolean() && model.hasDefined(SECURITY_DOMAIN.getName())) {
        throw SUBSYSTEM_DATASOURCES_LOGGER.attributeRequiresFalseOrUndefinedAttribute(SECURITY_DOMAIN.getName(), ELYTRON_ENABLED.getName());
    }
    final boolean enabled = ENABLED.resolveModelAttribute(context, model).asBoolean();
    if (enabled) {
        firstRuntimeStep(context, operation, model);
        context.addStep(new OperationStepHandler() {

            @Override
            public void execute(OperationContext operationContext, ModelNode modelNode) throws OperationFailedException {
                secondRuntimeStep(context, operation, context.getResourceRegistrationForUpdate(), model, isXa());
            }
        }, OperationContext.Stage.RUNTIME);
    }
}
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 82 with OperationFailedException

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

the class HandlerAddHandler method execute.

@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
    context.addStep(new AlternativeAttributeValidationStepHandler(new SimpleAttributeDefinition[] { HandlerResourceDefinition.CLASS_NAME, HandlerResourceDefinition.CODE }), OperationContext.Stage.MODEL);
    context.addStep(new UniqueTypeValidationStepHandler(ModelElement.COMMON_HANDLER) {

        @Override
        protected String getType(OperationContext context, ModelNode model) throws OperationFailedException {
            return getHandlerType(context, model);
        }
    }, OperationContext.Stage.MODEL);
    super.execute(context, operation);
}
Also used : OperationContext(org.jboss.as.controller.OperationContext) OperationFailedException(org.jboss.as.controller.OperationFailedException) SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition) UniqueTypeValidationStepHandler(org.wildfly.extension.picketlink.common.model.validator.UniqueTypeValidationStepHandler) ModelNode(org.jboss.dmr.ModelNode) AlternativeAttributeValidationStepHandler(org.wildfly.extension.picketlink.common.model.validator.AlternativeAttributeValidationStepHandler)

Example 83 with OperationFailedException

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

the class AppClientSubsystemAdd method performBoottime.

protected void performBoottime(final OperationContext context, ModelNode operation, final ModelNode model) throws OperationFailedException {
    final String deployment = AppClientSubsystemResourceDefinition.DEPLOYMENT.resolveModelAttribute(context, model).asString();
    final File file = new File(AppClientSubsystemResourceDefinition.FILE.resolveModelAttribute(context, model).asString());
    final String hostUrl = model.hasDefined(HOST_URL) ? AppClientSubsystemResourceDefinition.HOST_URL.resolveModelAttribute(context, model).asString() : null;
    final String connectionPropertiesUrl = model.hasDefined(CONNECTION_PROPERTIES_URL) ? AppClientSubsystemResourceDefinition.CONNECTION_PROPERTIES_URL.resolveModelAttribute(context, model).asString() : null;
    final List<String> parameters = AppClientSubsystemResourceDefinition.PARAMETERS.unwrap(context, model);
    context.addStep(new AbstractDeploymentChainStep() {

        protected void execute(DeploymentProcessorTarget processorTarget) {
            if (deployment != null && !deployment.isEmpty()) {
                processorTarget.addDeploymentProcessor(Constants.SUBSYSTEM_NAME, Phase.STRUCTURE, Phase.STRUCTURE_APP_CLIENT, new ApplicationClientStructureProcessor(deployment));
            }
            processorTarget.addDeploymentProcessor(Constants.SUBSYSTEM_NAME, Phase.STRUCTURE, Phase.STRUCTURE_REGISTER_JBOSS_ALL_APPCLIENT, new JBossAllXmlParserRegisteringProcessor<>(AppClientJBossAllParser.ROOT_ELEMENT, AppClientJBossAllParser.ATTACHMENT_KEY, new AppClientJBossAllParser()));
            processorTarget.addDeploymentProcessor(Constants.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_APP_CLIENT_XML, new ApplicationClientParsingDeploymentProcessor());
            processorTarget.addDeploymentProcessor(Constants.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_APPLICATION_CLIENT_MANIFEST, new ApplicationClientManifestProcessor());
            processorTarget.addDeploymentProcessor(Constants.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_APPLICATION_CLIENT_ACTIVE, new ActiveApplicationClientProcessor(deployment));
            processorTarget.addDeploymentProcessor(Constants.SUBSYSTEM_NAME, Phase.DEPENDENCIES, Phase.DEPENDENCIES_APPLICATION_CLIENT, new ApplicationClientDependencyProcessor());
            processorTarget.addDeploymentProcessor(Constants.SUBSYSTEM_NAME, Phase.INSTALL, Phase.INSTALL_APPLICATION_CLIENT, new ApplicationClientStartProcessor(hostUrl, connectionPropertiesUrl, parameters.toArray(EMPTY_STRING)));
        }
    }, OperationContext.Stage.RUNTIME);
    final ApplicationClientDeploymentService service = new ApplicationClientDeploymentService(file);
    context.getServiceTarget().addService(ApplicationClientDeploymentService.SERVICE_NAME, service).addDependency(Services.JBOSS_SERVER_CONTROLLER, ModelController.class, service.getControllerValue()).install();
    try {
        URI uri;
        if (hostUrl == null) {
            uri = new URI("remote+http://localhost:8080");
        } else {
            uri = new URI(hostUrl);
        }
        context.getServiceTarget().addService(APP_CLIENT_URI_SERVICE_NAME, new ValueService<>(new ImmediateValue<>(uri))).install();
    } catch (URISyntaxException e) {
        throw new OperationFailedException(e);
    }
}
Also used : JBossAllXmlParserRegisteringProcessor(org.jboss.as.server.deployment.jbossallxml.JBossAllXmlParserRegisteringProcessor) ApplicationClientDependencyProcessor(org.jboss.as.appclient.deployment.ApplicationClientDependencyProcessor) OperationFailedException(org.jboss.as.controller.OperationFailedException) ApplicationClientDeploymentService(org.jboss.as.appclient.service.ApplicationClientDeploymentService) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) ValueService(org.jboss.msc.service.ValueService) ApplicationClientStartProcessor(org.jboss.as.appclient.deployment.ApplicationClientStartProcessor) DeploymentProcessorTarget(org.jboss.as.server.DeploymentProcessorTarget) ActiveApplicationClientProcessor(org.jboss.as.appclient.deployment.ActiveApplicationClientProcessor) ApplicationClientStructureProcessor(org.jboss.as.appclient.deployment.ApplicationClientStructureProcessor) AbstractDeploymentChainStep(org.jboss.as.server.AbstractDeploymentChainStep) ApplicationClientManifestProcessor(org.jboss.as.appclient.deployment.ApplicationClientManifestProcessor) ModelController(org.jboss.as.controller.ModelController) File(java.io.File) AppClientJBossAllParser(org.jboss.as.appclient.deployment.AppClientJBossAllParser) ApplicationClientParsingDeploymentProcessor(org.jboss.as.appclient.deployment.ApplicationClientParsingDeploymentProcessor)

Example 84 with OperationFailedException

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

the class BatchSubsystemDefinition method registerAttributes.

@Override
public void registerAttributes(final ManagementResourceRegistration resourceRegistration) {
    super.registerAttributes(resourceRegistration);
    final OperationStepHandler writeHandler = new ReloadRequiredWriteAttributeHandler(DEFAULT_JOB_REPOSITORY, DEFAULT_THREAD_POOL, SECURITY_DOMAIN);
    resourceRegistration.registerReadWriteAttribute(DEFAULT_JOB_REPOSITORY, null, writeHandler);
    resourceRegistration.registerReadWriteAttribute(DEFAULT_THREAD_POOL, null, writeHandler);
    resourceRegistration.registerReadWriteAttribute(SECURITY_DOMAIN, null, writeHandler);
    resourceRegistration.registerReadWriteAttribute(RESTART_JOBS_ON_RESUME, null, new AbstractWriteAttributeHandler<Boolean>(RESTART_JOBS_ON_RESUME) {

        @Override
        protected boolean applyUpdateToRuntime(final OperationContext context, final ModelNode operation, final String attributeName, final ModelNode resolvedValue, final ModelNode currentValue, final HandbackHolder<Boolean> handbackHolder) throws OperationFailedException {
            setValue(context, resolvedValue);
            return false;
        }

        @Override
        protected void revertUpdateToRuntime(final OperationContext context, final ModelNode operation, final String attributeName, final ModelNode valueToRestore, final ModelNode valueToRevert, final Boolean handback) throws OperationFailedException {
            setValue(context, valueToRestore);
        }

        private void setValue(final OperationContext context, final ModelNode value) {
            final BatchConfigurationService service = (BatchConfigurationService) context.getServiceRegistry(true).getService(context.getCapabilityServiceName(Capabilities.BATCH_CONFIGURATION_CAPABILITY.getName(), BatchConfiguration.class)).getService();
            service.setRestartOnResume(value.asBoolean());
        }
    });
}
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) ReloadRequiredWriteAttributeHandler(org.jboss.as.controller.ReloadRequiredWriteAttributeHandler)

Example 85 with OperationFailedException

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

the class ExecutionHandler method executeRuntimeStep.

@Override
protected void executeRuntimeStep(OperationContext context, ModelNode operation) {
    String name = this.nameExtractor.apply(operation);
    E executable = this.executables.get(name);
    try {
        ModelNode result = this.executor.execute(context, executable);
        if (result != null) {
            context.getResult().set(result);
        }
    } catch (OperationFailedException e) {
        context.getFailureDescription().set(e.getLocalizedMessage());
    }
    context.completeStep(OperationContext.ResultHandler.NOOP_RESULT_HANDLER);
}
Also used : OperationFailedException(org.jboss.as.controller.OperationFailedException) ModelNode(org.jboss.dmr.ModelNode)

Aggregations

OperationFailedException (org.jboss.as.controller.OperationFailedException)113 ModelNode (org.jboss.dmr.ModelNode)86 PathAddress (org.jboss.as.controller.PathAddress)51 OperationContext (org.jboss.as.controller.OperationContext)49 OperationStepHandler (org.jboss.as.controller.OperationStepHandler)34 ServiceName (org.jboss.msc.service.ServiceName)33 Resource (org.jboss.as.controller.registry.Resource)26 ServiceController (org.jboss.msc.service.ServiceController)19 ServiceTarget (org.jboss.msc.service.ServiceTarget)15 PathElement (org.jboss.as.controller.PathElement)13 ServiceRegistry (org.jboss.msc.service.ServiceRegistry)12 IOException (java.io.IOException)11 Map (java.util.Map)11 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)11 ArrayList (java.util.ArrayList)9 AttributeDefinition (org.jboss.as.controller.AttributeDefinition)9 ContextNames (org.jboss.as.naming.deployment.ContextNames)7 ServiceBuilder (org.jboss.msc.service.ServiceBuilder)7 List (java.util.List)6 ResourceServiceHandler (org.jboss.as.clustering.controller.ResourceServiceHandler)6