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);
}
}
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);
}
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);
}
}
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());
}
});
}
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);
}
Aggregations