Search in sources :

Example 11 with ServiceName

use of org.jboss.msc.service.ServiceName in project wildfly by wildfly.

the class MessagingXmlInstallDeploymentUnitProcessor method deploy.

@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final List<ParseResult> parseResults = deploymentUnit.getAttachmentList(MessagingAttachments.PARSE_RESULT);
    final DeploymentResourceSupport deploymentResourceSupport = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_RESOURCE_SUPPORT);
    for (final ParseResult parseResult : parseResults) {
        for (final JmsDestination topic : parseResult.getTopics()) {
            final ServiceName serverServiceName = MessagingServices.getActiveMQServiceName(topic.getServer());
            String[] jndiBindings = null;
            if (topic.getDestination().hasDefined(CommonAttributes.DESTINATION_ENTRIES.getName())) {
                final ModelNode entries = topic.getDestination().resolve().get(CommonAttributes.DESTINATION_ENTRIES.getName());
                jndiBindings = JMSServices.getJndiBindings(entries);
            }
            JMSTopicService.installService(topic.getName(), serverServiceName, phaseContext.getServiceTarget(), jndiBindings);
            //create the management registration
            final PathElement serverElement = PathElement.pathElement(SERVER, topic.getServer());
            final PathElement destination = PathElement.pathElement(JMS_TOPIC, topic.getName());
            deploymentResourceSupport.getDeploymentSubModel(MessagingExtension.SUBSYSTEM_NAME, serverElement);
            PathAddress registration = PathAddress.pathAddress(serverElement, destination);
            createDeploymentSubModel(registration, deploymentUnit);
            JMSTopicConfigurationRuntimeHandler.INSTANCE.registerResource(topic.getServer(), topic.getName(), topic.getDestination());
        }
        for (final JmsDestination queue : parseResult.getQueues()) {
            final ServiceName serverServiceName = MessagingServices.getActiveMQServiceName(queue.getServer());
            String[] jndiBindings = null;
            final ModelNode destination = queue.getDestination();
            if (destination.hasDefined(CommonAttributes.DESTINATION_ENTRIES.getName())) {
                final ModelNode entries = destination.resolve().get(CommonAttributes.DESTINATION_ENTRIES.getName());
                jndiBindings = JMSServices.getJndiBindings(entries);
            }
            final String selector = destination.hasDefined(SELECTOR.getName()) ? destination.get(SELECTOR.getName()).resolve().asString() : null;
            final boolean durable = destination.hasDefined(DURABLE.getName()) ? destination.get(DURABLE.getName()).resolve().asBoolean() : false;
            JMSQueueService.installService(queue.getName(), phaseContext.getServiceTarget(), serverServiceName, selector, durable, jndiBindings);
            //create the management registration
            final PathElement serverElement = PathElement.pathElement(SERVER, queue.getServer());
            final PathElement dest = PathElement.pathElement(JMS_QUEUE, queue.getName());
            deploymentResourceSupport.getDeploymentSubModel(MessagingExtension.SUBSYSTEM_NAME, serverElement);
            PathAddress registration = PathAddress.pathAddress(serverElement, dest);
            createDeploymentSubModel(registration, deploymentUnit);
            JMSQueueConfigurationRuntimeHandler.INSTANCE.registerResource(queue.getServer(), queue.getName(), destination);
        }
    }
}
Also used : DeploymentResourceSupport(org.jboss.as.server.deployment.DeploymentResourceSupport) PathElement(org.jboss.as.controller.PathElement) ServiceName(org.jboss.msc.service.ServiceName) PathAddress(org.jboss.as.controller.PathAddress) ModelNode(org.jboss.dmr.ModelNode) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 12 with ServiceName

use of org.jboss.msc.service.ServiceName in project wildfly by wildfly.

the class ConnectionFactoryRemove method performRuntime.

protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
    final String name = context.getCurrentAddressValue();
    final ServiceName serviceName = MessagingServices.getActiveMQServiceName(context.getCurrentAddress());
    context.removeService(JMSServices.getConnectionFactoryBaseServiceName(serviceName).append(name));
}
Also used : ServiceName(org.jboss.msc.service.ServiceName)

Example 13 with ServiceName

use of org.jboss.msc.service.ServiceName in project wildfly by wildfly.

the class ConnectionFactoryWriteAttributeHandler 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 {
    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 && service.getState() == ServiceController.State.UP) {
        applyOperationToActiveMQService(context, getName(operation), attributeName, valueToRestore, service);
    }
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) ServiceRegistry(org.jboss.msc.service.ServiceRegistry)

Example 14 with ServiceName

use of org.jboss.msc.service.ServiceName in project wildfly by wildfly.

the class JMSQueueAdd method performRuntime.

@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
    final String name = context.getCurrentAddressValue();
    final ServiceTarget serviceTarget = context.getServiceTarget();
    final ServiceName serviceName = MessagingServices.getActiveMQServiceName(context.getCurrentAddress());
    final ModelNode selectorNode = SELECTOR.resolveModelAttribute(context, model);
    final boolean durable = DURABLE.resolveModelAttribute(context, model).asBoolean();
    final String selector = selectorNode.isDefined() ? selectorNode.asString() : null;
    // Do not pass the JNDI bindings to ActiveMQ but install them directly instead so that the
    // dependencies from the BinderServices to the JMSQueueService are not broken
    Service<Queue> queueService = JMSQueueService.installService(name, serviceTarget, serviceName, selector, durable, new String[0]);
    final ServiceName jmsQueueServiceName = JMSServices.getJmsQueueBaseServiceName(serviceName).append(name);
    for (String entry : CommonAttributes.DESTINATION_ENTRIES.unwrap(context, model)) {
        BinderServiceUtil.installBinderService(serviceTarget, entry, queueService, jmsQueueServiceName);
    }
    List<String> legacyEntries = CommonAttributes.LEGACY_ENTRIES.unwrap(context, model);
    if (!legacyEntries.isEmpty()) {
        Queue legacyQueue = HornetQJMSClient.createQueue(name);
        for (String legacyEntry : legacyEntries) {
            BinderServiceUtil.installBinderService(serviceTarget, legacyEntry, legacyQueue);
        }
    }
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) ServiceTarget(org.jboss.msc.service.ServiceTarget) ModelNode(org.jboss.dmr.ModelNode) Queue(javax.jms.Queue)

Example 15 with ServiceName

use of org.jboss.msc.service.ServiceName in project wildfly by wildfly.

the class JMSQueueReadAttributeHandler method getControl.

private JMSQueueControl getControl(OperationContext context, ModelNode operation) {
    String queueName = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR)).getLastElement().getValue();
    final ServiceName serviceName = MessagingServices.getActiveMQServiceName(PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)));
    ServiceController<?> service = context.getServiceRegistry(false).getService(serviceName);
    ActiveMQServer server = ActiveMQServer.class.cast(service.getValue());
    JMSQueueControl control = JMSQueueControl.class.cast(server.getManagementService().getResource(ResourceNames.JMS_QUEUE + queueName));
    return control;
}
Also used : ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) JMSQueueControl(org.apache.activemq.artemis.api.jms.management.JMSQueueControl) ServiceName(org.jboss.msc.service.ServiceName)

Aggregations

ServiceName (org.jboss.msc.service.ServiceName)289 ServiceTarget (org.jboss.msc.service.ServiceTarget)56 PathAddress (org.jboss.as.controller.PathAddress)54 ModelNode (org.jboss.dmr.ModelNode)48 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)44 ServiceRegistry (org.jboss.msc.service.ServiceRegistry)40 OperationFailedException (org.jboss.as.controller.OperationFailedException)33 Module (org.jboss.modules.Module)23 ServiceController (org.jboss.msc.service.ServiceController)23 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)22 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)22 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)19 BinderService (org.jboss.as.naming.service.BinderService)18 HashSet (java.util.HashSet)17 ContextNames (org.jboss.as.naming.deployment.ContextNames)17 ServiceBuilder (org.jboss.msc.service.ServiceBuilder)15 HashMap (java.util.HashMap)14 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)14 ArrayList (java.util.ArrayList)13 OperationContext (org.jboss.as.controller.OperationContext)12