Search in sources :

Example 1 with JMSTopicService

use of org.wildfly.extension.messaging.activemq.jms.JMSTopicService 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 topicService = JMSTopicService.installService(topic.getName(), serverServiceName, phaseContext.getServiceTarget());
            final ServiceName topicServiceName = JMSServices.getJmsTopicBaseServiceName(serverServiceName).append(topic.getName());
            for (String binding : jndiBindings) {
                BinderServiceUtil.installBinderService(phaseContext.getServiceTarget(), binding, topicService, topicServiceName);
            }
            // 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;
            Service<Queue> queueService = JMSQueueService.installService(queue.getName(), phaseContext.getServiceTarget(), serverServiceName, selector, durable);
            final ServiceName queueServiceName = JMSServices.getJmsQueueBaseServiceName(serverServiceName).append(queue.getName());
            for (String binding : jndiBindings) {
                BinderServiceUtil.installBinderService(phaseContext.getServiceTarget(), binding, queueService, queueServiceName);
            }
            // 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 : JMSTopicService(org.wildfly.extension.messaging.activemq.jms.JMSTopicService) 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) Queue(javax.jms.Queue)

Aggregations

Queue (javax.jms.Queue)1 PathAddress (org.jboss.as.controller.PathAddress)1 PathElement (org.jboss.as.controller.PathElement)1 DeploymentResourceSupport (org.jboss.as.server.deployment.DeploymentResourceSupport)1 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)1 ModelNode (org.jboss.dmr.ModelNode)1 ServiceName (org.jboss.msc.service.ServiceName)1 JMSTopicService (org.wildfly.extension.messaging.activemq.jms.JMSTopicService)1