use of org.jboss.msc.service.ServiceRegistry 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.msc.service.ServiceRegistry in project wildfly by wildfly.
the class BridgeRemove method performRuntime.
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
final String name = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR)).getLastElement().getValue();
final ServiceRegistry registry = context.getServiceRegistry(true);
final ServiceName serviceName = MessagingServices.getActiveMQServiceName(PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)));
final ServiceController<?> service = registry.getService(serviceName);
if (service != null && service.getState() == ServiceController.State.UP) {
ActiveMQServer server = ActiveMQServer.class.cast(service.getValue());
try {
server.getActiveMQServerControl().destroyBridge(name);
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
// TODO should this be an OFE instead?
throw new RuntimeException(e);
}
}
}
use of org.jboss.msc.service.ServiceRegistry in project wildfly by wildfly.
the class DivertRemove method recoverServices.
@Override
protected void recoverServices(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
final ServiceRegistry registry = context.getServiceRegistry(true);
final ServiceName serviceName = MessagingServices.getActiveMQServiceName(PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)));
final ServiceController<?> service = registry.getService(serviceName);
if (service != null && service.getState() == ServiceController.State.UP) {
final String name = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR)).getLastElement().getValue();
final DivertConfiguration divertConfiguration = DivertAdd.createDivertConfiguration(context, name, model);
ActiveMQServer server = ActiveMQServer.class.cast(service.getValue());
DivertAdd.createDivert(name, divertConfiguration, server.getActiveMQServerControl());
}
}
use of org.jboss.msc.service.ServiceRegistry in project wildfly by wildfly.
the class ClusterConnectionAdd method performRuntime.
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
ServiceRegistry registry = context.getServiceRegistry(false);
final ServiceName serviceName = MessagingServices.getActiveMQServiceName(PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)));
ServiceController<?> service = registry.getService(serviceName);
if (service != null) {
context.reloadRequired();
}
// else MessagingSubsystemAdd will add a handler that calls addBroadcastGroupConfigs
}
use of org.jboss.msc.service.ServiceRegistry in project wildfly by wildfly.
the class SocketDiscoveryGroupAdd method performRuntime.
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
final String name = address.getLastElement().getValue();
ServiceRegistry registry = context.getServiceRegistry(false);
ServiceName serviceName = MessagingServices.getActiveMQServiceName(PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)));
ServiceController<?> service = serviceName == null ? null : registry.getService(serviceName);
if (service != null) {
context.reloadRequired();
} else {
final ServiceTarget target = context.getServiceTarget();
if (model.hasDefined(JGROUPS_CLUSTER.getName())) {
// nothing to do, in that case, the clustering.jgroups subsystem will have setup the stack
} else if (model.hasDefined(RemoteTransportDefinition.SOCKET_BINDING.getName())) {
if (serviceName == null) {
serviceName = MessagingServices.getActiveMQServiceName((String) null);
}
ServiceBuilder builder = target.addService(GroupBindingService.getDiscoveryBaseServiceName(serviceName).append(name));
builder.setInstance(new GroupBindingService(builder.requires(SocketBinding.JBOSS_BINDING_NAME.append(model.get(SOCKET_BINDING).asString()))));
builder.install();
}
}
}
Aggregations