Search in sources :

Example 1 with ServiceTarget

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

the class JMSTopicAdd method performRuntime.

@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
    final String name = context.getCurrentAddressValue();
    final ServiceName serviceName = MessagingServices.getActiveMQServiceName(context.getCurrentAddress());
    final ServiceTarget serviceTarget = context.getServiceTarget();
    // 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
    JMSTopicService jmsTopicService = JMSTopicService.installService(name, serviceName, serviceTarget, new String[0]);
    final ServiceName jmsTopicServiceName = JMSServices.getJmsTopicBaseServiceName(serviceName).append(name);
    for (String entry : CommonAttributes.DESTINATION_ENTRIES.unwrap(context, model)) {
        BinderServiceUtil.installBinderService(serviceTarget, entry, jmsTopicService, jmsTopicServiceName);
    }
    List<String> legacyEntries = CommonAttributes.LEGACY_ENTRIES.unwrap(context, model);
    if (!legacyEntries.isEmpty()) {
        Topic legacyTopic = HornetQJMSClient.createTopic(name);
        for (String legacyEntry : legacyEntries) {
            BinderServiceUtil.installBinderService(serviceTarget, legacyEntry, legacyTopic);
        }
    }
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) ServiceTarget(org.jboss.msc.service.ServiceTarget) Topic(javax.jms.Topic)

Example 2 with ServiceTarget

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

the class PooledConnectionFactoryAdd method performRuntime.

@Override
protected void performRuntime(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException {
    ModelNode model = resource.getModel();
    PathAddress address = context.getCurrentAddress();
    final String name = context.getCurrentAddressValue();
    final ModelNode resolvedModel = model.clone();
    for (final AttributeDefinition attribute : getDefinitions(PooledConnectionFactoryDefinition.ATTRIBUTES)) {
        resolvedModel.get(attribute.getName()).set(attribute.resolveModelAttribute(context, resolvedModel));
    }
    // We validated that jndiName part of the model in populateModel
    final List<String> jndiNames = new ArrayList<String>();
    for (ModelNode node : resolvedModel.get(Common.ENTRIES.getName()).asList()) {
        jndiNames.add(node.asString());
    }
    String managedConnectionPoolClassName = null;
    if (resolvedModel.hasDefined(ConnectionFactoryAttributes.Pooled.MANAGED_CONNECTION_POOL.getName())) {
        managedConnectionPoolClassName = resolvedModel.get(ConnectionFactoryAttributes.Pooled.MANAGED_CONNECTION_POOL.getName()).asString();
    }
    final int minPoolSize = resolvedModel.get(ConnectionFactoryAttributes.Pooled.MIN_POOL_SIZE.getName()).asInt();
    final int maxPoolSize = resolvedModel.get(ConnectionFactoryAttributes.Pooled.MAX_POOL_SIZE.getName()).asInt();
    Boolean enlistmentTrace = null;
    if (resolvedModel.hasDefined(ConnectionFactoryAttributes.Pooled.ENLISTMENT_TRACE.getName())) {
        enlistmentTrace = resolvedModel.get(ConnectionFactoryAttributes.Pooled.ENLISTMENT_TRACE.getName()).asBoolean();
    }
    final String txSupport;
    if (resolvedModel.hasDefined(ConnectionFactoryAttributes.Pooled.TRANSACTION.getName())) {
        String txType = resolvedModel.get(ConnectionFactoryAttributes.Pooled.TRANSACTION.getName()).asString();
        if (LOCAL.equals(txType)) {
            txSupport = LOCAL_TX;
        } else if (NONE.equals(txType)) {
            txSupport = NO_TX;
        } else {
            txSupport = XA_TX;
        }
    } else {
        txSupport = XA_TX;
    }
    ServiceTarget serviceTarget = context.getServiceTarget();
    List<String> connectors = Common.CONNECTORS.unwrap(context, model);
    String discoveryGroupName = getDiscoveryGroup(resolvedModel);
    String jgroupsChannelName = null;
    if (discoveryGroupName != null) {
        Resource dgResource = context.readResourceFromRoot(MessagingServices.getActiveMQServerPathAddress(address).append(CommonAttributes.DISCOVERY_GROUP, discoveryGroupName));
        ModelNode dgModel = dgResource.getModel();
        jgroupsChannelName = JGROUPS_CHANNEL.resolveModelAttribute(context, dgModel).asString();
    }
    List<PooledConnectionFactoryConfigProperties> adapterParams = getAdapterParams(resolvedModel, context);
    final PathAddress serverAddress = MessagingServices.getActiveMQServerPathAddress(address);
    PooledConnectionFactoryService.installService(serviceTarget, name, serverAddress.getLastElement().getValue(), connectors, discoveryGroupName, jgroupsChannelName, adapterParams, jndiNames, txSupport, minPoolSize, maxPoolSize, managedConnectionPoolClassName, enlistmentTrace);
    boolean statsEnabled = ConnectionFactoryAttributes.Pooled.STATISTICS_ENABLED.resolveModelAttribute(context, model).asBoolean();
    if (statsEnabled) {
        installStatistics(context, name);
    }
}
Also used : ServiceTarget(org.jboss.msc.service.ServiceTarget) ArrayList(java.util.ArrayList) Resource(org.jboss.as.controller.registry.Resource) AttributeDefinition(org.jboss.as.controller.AttributeDefinition) PathAddress(org.jboss.as.controller.PathAddress) ModelNode(org.jboss.dmr.ModelNode)

Example 3 with ServiceTarget

use of org.jboss.msc.service.ServiceTarget 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 4 with ServiceTarget

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

the class NamingBindingAdd method installSimpleBinding.

void installSimpleBinding(final OperationContext context, final String name, final ModelNode model) throws OperationFailedException {
    Object bindValue = createSimpleBinding(context, model);
    ValueManagedReferenceFactory referenceFactory = new ValueManagedReferenceFactory(new ImmediateValue<Object>(bindValue));
    final BinderService binderService = new BinderService(name, bindValue);
    binderService.getManagedObjectInjector().inject(new MutableManagedReferenceFactory(referenceFactory));
    final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(name);
    final ServiceTarget serviceTarget = context.getServiceTarget();
    ServiceBuilder<ManagedReferenceFactory> builder = serviceTarget.addService(bindInfo.getBinderServiceName(), binderService).addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, binderService.getNamingStoreInjector());
    builder.install();
}
Also used : ExternalContextBinderService(org.jboss.as.naming.service.ExternalContextBinderService) BinderService(org.jboss.as.naming.service.BinderService) ValueManagedReferenceFactory(org.jboss.as.naming.ValueManagedReferenceFactory) ContextListAndJndiViewManagedReferenceFactory(org.jboss.as.naming.ContextListAndJndiViewManagedReferenceFactory) ContextListManagedReferenceFactory(org.jboss.as.naming.ContextListManagedReferenceFactory) ManagedReferenceFactory(org.jboss.as.naming.ManagedReferenceFactory) ValueManagedReferenceFactory(org.jboss.as.naming.ValueManagedReferenceFactory) ServiceTarget(org.jboss.msc.service.ServiceTarget) ContextNames(org.jboss.as.naming.deployment.ContextNames)

Example 5 with ServiceTarget

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

the class NamingBindingAdd method installLookup.

void installLookup(final OperationContext context, final String name, final ModelNode model) throws OperationFailedException {
    final String lookup = NamingBindingResourceDefinition.LOOKUP.resolveModelAttribute(context, model).asString();
    final ServiceTarget serviceTarget = context.getServiceTarget();
    final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(name);
    final BinderService binderService = new BinderService(name);
    binderService.getManagedObjectInjector().inject(new MutableManagedReferenceFactory(new LookupManagedReferenceFactory(lookup)));
    serviceTarget.addService(bindInfo.getBinderServiceName(), binderService).addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, binderService.getNamingStoreInjector()).install();
}
Also used : ExternalContextBinderService(org.jboss.as.naming.service.ExternalContextBinderService) BinderService(org.jboss.as.naming.service.BinderService) ServiceBasedNamingStore(org.jboss.as.naming.ServiceBasedNamingStore) ServiceTarget(org.jboss.msc.service.ServiceTarget) ContextNames(org.jboss.as.naming.deployment.ContextNames)

Aggregations

ServiceTarget (org.jboss.msc.service.ServiceTarget)108 ServiceName (org.jboss.msc.service.ServiceName)57 PathAddress (org.jboss.as.controller.PathAddress)30 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)26 ModelNode (org.jboss.dmr.ModelNode)26 Module (org.jboss.modules.Module)18 ServiceBuilder (org.jboss.msc.service.ServiceBuilder)15 OperationFailedException (org.jboss.as.controller.OperationFailedException)12 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)11 ContextNames (org.jboss.as.naming.deployment.ContextNames)11 Resource (org.jboss.as.controller.registry.Resource)10 BinderService (org.jboss.as.naming.service.BinderService)10 AbstractDeploymentChainStep (org.jboss.as.server.AbstractDeploymentChainStep)10 DeploymentProcessorTarget (org.jboss.as.server.DeploymentProcessorTarget)10 PathElement (org.jboss.as.controller.PathElement)9 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)9 ServiceRegistry (org.jboss.msc.service.ServiceRegistry)9 ServiceController (org.jboss.msc.service.ServiceController)8 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5