Search in sources :

Example 96 with ServiceName

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);
        }
    }
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) AttributeDefinition(org.jboss.as.controller.AttributeDefinition) ServiceRegistry(org.jboss.msc.service.ServiceRegistry)

Example 97 with ServiceName

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;
}
Also used : ServiceName(org.jboss.msc.service.ServiceName)

Example 98 with ServiceName

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
}
Also used : ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) ActiveMQServerControl(org.apache.activemq.artemis.api.core.management.ActiveMQServerControl) ServiceName(org.jboss.msc.service.ServiceName) BridgeConfiguration(org.apache.activemq.artemis.core.config.BridgeConfiguration) ServiceRegistry(org.jboss.msc.service.ServiceRegistry)

Example 99 with ServiceName

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());
    }
}
Also used : ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) ServiceName(org.jboss.msc.service.ServiceName) BridgeConfiguration(org.apache.activemq.artemis.core.config.BridgeConfiguration) ServiceRegistry(org.jboss.msc.service.ServiceRegistry)

Example 100 with ServiceName

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();
        }
    }
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) PathAddress(org.jboss.as.controller.PathAddress) ServiceTarget(org.jboss.msc.service.ServiceTarget) ServiceRegistry(org.jboss.msc.service.ServiceRegistry)

Aggregations

ServiceName (org.jboss.msc.service.ServiceName)323 ServiceTarget (org.jboss.msc.service.ServiceTarget)62 PathAddress (org.jboss.as.controller.PathAddress)57 ModelNode (org.jboss.dmr.ModelNode)53 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)47 ServiceRegistry (org.jboss.msc.service.ServiceRegistry)45 OperationFailedException (org.jboss.as.controller.OperationFailedException)35 ServiceController (org.jboss.msc.service.ServiceController)26 Module (org.jboss.modules.Module)24 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)22 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)22 ContextNames (org.jboss.as.naming.deployment.ContextNames)21 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)20 BinderService (org.jboss.as.naming.service.BinderService)20 ArrayList (java.util.ArrayList)17 HashSet (java.util.HashSet)17 ServiceBuilder (org.jboss.msc.service.ServiceBuilder)16 HashMap (java.util.HashMap)14 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)14 OperationContext (org.jboss.as.controller.OperationContext)12