use of org.jboss.as.controller.OperationStepHandler in project wildfly by wildfly.
the class ServerAdd method populateModel.
@Override
protected void populateModel(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException {
super.populateModel(context, operation, resource);
// add an operation to create all the messaging paths resources that have not been already been created
// prior to adding the ActiveMQ server
context.addStep(new OperationStepHandler() {
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
final ModelNode model = Resource.Tools.readModel(resource);
for (String path : PathDefinition.PATHS.keySet()) {
if (!model.get(ModelDescriptionConstants.PATH).hasDefined(path)) {
PathAddress pathAddress = PathAddress.pathAddress(PathElement.pathElement(ModelDescriptionConstants.PATH, path));
context.createResource(pathAddress);
}
}
}
}, OperationContext.Stage.MODEL);
context.addStep((operationContext, model) -> {
// check that if journal-datasource is defined, no other attributes related to file-system journal are set.
if (ServerDefinition.JOURNAL_DATASOURCE.resolveModelAttribute(context, model).isDefined()) {
checkNoAttributesIsDefined(ServerDefinition.JOURNAL_DATASOURCE.getName(), operationContext.getCurrentAddress(), model, ServerDefinition.JOURNAL_TYPE, ServerDefinition.JOURNAL_BUFFER_TIMEOUT, ServerDefinition.JOURNAL_BUFFER_SIZE, ServerDefinition.JOURNAL_SYNC_TRANSACTIONAL, ServerDefinition.JOURNAL_SYNC_NON_TRANSACTIONAL, ServerDefinition.LOG_JOURNAL_WRITE_RATE, ServerDefinition.JOURNAL_FILE_SIZE, ServerDefinition.JOURNAL_MIN_FILES, ServerDefinition.JOURNAL_POOL_FILES, ServerDefinition.JOURNAL_COMPACT_PERCENTAGE, ServerDefinition.JOURNAL_COMPACT_MIN_FILES, ServerDefinition.JOURNAL_MAX_IO, ServerDefinition.CREATE_BINDINGS_DIR, ServerDefinition.CREATE_JOURNAL_DIR);
}
}, OperationContext.Stage.MODEL);
}
use of org.jboss.as.controller.OperationStepHandler in project wildfly by wildfly.
the class ServerRemove method performRemove.
@Override
protected void performRemove(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS);
// add a runtime step to remove services related to broadcast-group/discovery-group that are started
// when the server is added.
context.addStep(new OperationStepHandler() {
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
final String serverName = context.getCurrentAddressValue();
final ServiceName serviceName = MessagingServices.getActiveMQServiceName(serverName);
for (final Resource.ResourceEntry broadcastGroup : resource.getChildren(CommonAttributes.BROADCAST_GROUP)) {
context.removeService(GroupBindingService.getBroadcastBaseServiceName(serviceName).append(broadcastGroup.getName()));
}
for (final Resource.ResourceEntry divertGroup : resource.getChildren(CommonAttributes.DISCOVERY_GROUP)) {
context.removeService(GroupBindingService.getDiscoveryBaseServiceName(serviceName).append(divertGroup.getName()));
}
}
}, OperationContext.Stage.RUNTIME);
super.performRemove(context, operation, model);
}
use of org.jboss.as.controller.OperationStepHandler in project wildfly by wildfly.
the class GroupingHandlerAdd method performRuntime.
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
ServiceRegistry registry = context.getServiceRegistry(true);
final ServiceName serviceName = MessagingServices.getActiveMQServiceName(PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)));
ServiceController<?> service = registry.getService(serviceName);
if (service != null) {
final ActiveMQServer server = ActiveMQServer.class.cast(service.getValue());
if (server.getGroupingHandler() != null) {
throw new OperationFailedException(MessagingLogger.ROOT_LOGGER.childResourceAlreadyExists(CommonAttributes.GROUPING_HANDLER));
}
// the groupingHandler is added as a child of the server resource. Requires a reload to restart the server with the grouping-handler
if (context.isNormalServer()) {
context.addStep(new OperationStepHandler() {
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
context.reloadRequired();
context.completeStep(OperationContext.RollbackHandler.REVERT_RELOAD_REQUIRED_ROLLBACK_HANDLER);
}
}, OperationContext.Stage.RUNTIME);
}
}
// else the initial subsystem install is not complete and the grouping handler will be added in ServerAdd
}
Aggregations