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);
}
}
}
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));
}
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);
}
}
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);
}
}
}
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;
}
Aggregations