use of org.jboss.msc.service.ServiceName in project wildfly by wildfly.
the class ActiveMQServerControlWriteHandler method revertUpdateToRuntime.
@Override
protected void revertUpdateToRuntime(final OperationContext context, final ModelNode operation, final String attributeName, final ModelNode valueToRestore, final ModelNode valueToRevert, final Void handback) throws OperationFailedException {
AttributeDefinition attr = getAttributeDefinition(attributeName);
if (!attr.getFlags().contains(AttributeAccess.Flag.RESTART_ALL_SERVICES)) {
ServiceRegistry registry = context.getServiceRegistry(true);
final ServiceName serviceName = MessagingServices.getActiveMQServiceName(PathAddress.pathAddress(operation.get(OP_ADDR)));
ServiceController<?> service = registry.getService(serviceName);
if (service != null && service.getState() == ServiceController.State.UP) {
applyOperationToActiveMQService(operation, attributeName, valueToRestore, service);
}
}
}
use of org.jboss.msc.service.ServiceName in project wildfly by wildfly.
the class ActiveMQServerService method isServiceInstalled.
/**
* Returns true if a {@link ServiceController} for this service has been {@link org.jboss.msc.service.ServiceBuilder#install() installed}
* in MSC under the
* {@link MessagingServices#getActiveMQServiceName(org.jboss.as.controller.PathAddress) service name appropriate to the given operation}.
*
* @param context the operation context
* @return {@code true} if a {@link ServiceController} is installed
*/
static boolean isServiceInstalled(final OperationContext context) {
if (context.isNormalServer()) {
final ServiceName serviceName = MessagingServices.getActiveMQServiceName(context.getCurrentAddress());
final ServiceController<?> controller = context.getServiceRegistry(false).getService(serviceName);
return controller != null;
}
return false;
}
use of org.jboss.msc.service.ServiceName in project wildfly by wildfly.
the class BridgeAdd 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) {
// The original subsystem initialization is complete; use the control object to create the divert
if (service.getState() != ServiceController.State.UP) {
throw MessagingLogger.ROOT_LOGGER.invalidServiceState(serviceName, ServiceController.State.UP, service.getState());
}
final String name = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR)).getLastElement().getValue();
BridgeConfiguration bridgeConfig = createBridgeConfiguration(context, name, model);
ActiveMQServerControl serverControl = ActiveMQServer.class.cast(service.getValue()).getActiveMQServerControl();
createBridge(name, bridgeConfig, serverControl);
}
// else the initial subsystem install is not complete; MessagingSubsystemAdd will add a
// handler that calls addBridgeConfigs
}
use of org.jboss.msc.service.ServiceName in project wildfly by wildfly.
the class BridgeRemove 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 BridgeConfiguration bridgeConfiguration = BridgeAdd.createBridgeConfiguration(context, name, model);
ActiveMQServer server = ActiveMQServer.class.cast(service.getValue());
BridgeAdd.createBridge(name, bridgeConfiguration, server.getActiveMQServerControl());
}
}
use of org.jboss.msc.service.ServiceName in project wildfly by wildfly.
the class BroadcastGroupAdd 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 {
final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
final String name = address.getLastElement().getValue();
final ServiceTarget target = context.getServiceTarget();
if (model.hasDefined(JGROUPS_CHANNEL.getName())) {
// nothing to do, in that case, the clustering.jgroups subsystem will have setup the stack
} else if (model.hasDefined(RemoteTransportDefinition.SOCKET_BINDING.getName())) {
final GroupBindingService bindingService = new GroupBindingService();
target.addService(GroupBindingService.getBroadcastBaseServiceName(serviceName).append(name), bindingService).addDependency(SocketBinding.JBOSS_BINDING_NAME.append(model.get(SOCKET_BINDING).asString()), SocketBinding.class, bindingService.getBindingRef()).install();
}
}
}
Aggregations