use of org.jboss.as.controller.OperationStepHandler in project wildfly by wildfly.
the class BroadcastGroupAdd method execute.
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
CommonAttributes.renameChannelToCluster(operation);
if (!isLegacyCall) {
ModelNode op = operation.clone();
PathAddress target = context.getCurrentAddress().getParent();
OperationStepHandler addHandler;
if (operation.hasDefined(JGROUPS_CLUSTER.getName())) {
target = target.append(CommonAttributes.JGROUPS_BROADCAST_GROUP, context.getCurrentAddressValue());
addHandler = JGroupsBroadcastGroupAdd.LEGACY_INSTANCE;
} else {
target = target.append(CommonAttributes.SOCKET_BROADCAST_GROUP, context.getCurrentAddressValue());
addHandler = SocketBroadcastGroupAdd.LEGACY_INSTANCE;
}
op.get(OP_ADDR).set(target.toModelNode());
context.addStep(op, addHandler, OperationContext.Stage.MODEL, true);
}
super.execute(context, operation);
}
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() {
@Override
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
}
use of org.jboss.as.controller.OperationStepHandler in project wildfly by wildfly.
the class BroadcastGroupRemove method execute.
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
if (!isLegacyCall) {
ModelNode op = operation.clone();
PathAddress target = context.getCurrentAddress().getParent();
OperationStepHandler removeHandler;
try {
context.readResourceFromRoot(target.append(CommonAttributes.JGROUPS_BROADCAST_GROUP, context.getCurrentAddressValue()), false);
target = target.append(CommonAttributes.JGROUPS_BROADCAST_GROUP, context.getCurrentAddressValue());
removeHandler = JGroupsBroadcastGroupRemove.LEGACY_INSTANCE;
} catch (Resource.NoSuchResourceException ex) {
target = target.append(CommonAttributes.SOCKET_BROADCAST_GROUP, context.getCurrentAddressValue());
removeHandler = SocketBroadcastGroupRemove.LEGACY_INSTANCE;
}
op.get(OP_ADDR).set(target.toModelNode());
context.addStep(op, removeHandler, OperationContext.Stage.MODEL, true);
}
super.execute(context, operation);
}
use of org.jboss.as.controller.OperationStepHandler in project wildfly by wildfly.
the class DiscoveryGroupAdd method execute.
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
CommonAttributes.renameChannelToCluster(operation);
if (!isLegacyCall) {
ModelNode op = operation.clone();
PathAddress target = context.getCurrentAddress().getParent();
OperationStepHandler addHandler;
if (operation.hasDefined(JGROUPS_CLUSTER.getName())) {
target = target.append(CommonAttributes.JGROUPS_DISCOVERY_GROUP, context.getCurrentAddressValue());
addHandler = JGroupsDiscoveryGroupAdd.LEGACY_INSTANCE;
} else {
target = target.append(CommonAttributes.SOCKET_DISCOVERY_GROUP, context.getCurrentAddressValue());
addHandler = SocketDiscoveryGroupAdd.LEGACY_INSTANCE;
}
op.get(OP_ADDR).set(target.toModelNode());
context.addStep(op, addHandler, OperationContext.Stage.MODEL, true);
}
super.execute(context, operation);
}
use of org.jboss.as.controller.OperationStepHandler in project wildfly by wildfly.
the class JGroupsBroadcastGroupAdd method populateModel.
@Override
protected void populateModel(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException {
super.populateModel(context, operation, resource);
final ModelNode connectorRefs = resource.getModel().require(CONNECTOR_REFS.getName());
if (connectorRefs.isDefined()) {
context.addStep(new OperationStepHandler() {
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
BroadcastGroupWriteAttributeHandler.JGROUP_INSTANCE.validateConnectors(context, operation, connectorRefs);
}
}, OperationContext.Stage.MODEL);
}
}
Aggregations