Search in sources :

Example 1 with PooledConnectionFactoryConfigProperties

use of org.wildfly.extension.messaging.activemq.jms.PooledConnectionFactoryConfigProperties in project wildfly by wildfly.

the class JMSConnectionFactoryDefinitionInjectionSource method startedPooledConnectionFactory.

private void startedPooledConnectionFactory(ResolutionContext context, String name, ServiceBuilder<?> serviceBuilder, ServiceTarget serviceTarget, DeploymentUnit deploymentUnit, Injector<ManagedReferenceFactory> injector) throws DeploymentUnitProcessingException, OperationFailedException {
    Map<String, String> props = new HashMap<>(properties);
    List<String> connectors = getConnectors(props);
    clearUnknownProperties(properties);
    ModelNode model = new ModelNode();
    for (String connector : connectors) {
        model.get(CONNECTORS).add(connector);
    }
    for (Map.Entry<String, String> entry : properties.entrySet()) {
        model.get(entry.getKey()).set(entry.getValue());
    }
    model.get(MIN_POOL_SIZE.getName()).set(minPoolSize);
    model.get(MAX_POOL_SIZE.getName()).set(maxPoolSize);
    if (user != null && !user.isEmpty()) {
        model.get(ConnectionFactoryAttributes.Pooled.USER.getName()).set(user);
    }
    if (password != null && !password.isEmpty()) {
        model.get(ConnectionFactoryAttributes.Pooled.PASSWORD.getName()).set(password);
    }
    if (clientId != null && !clientId.isEmpty()) {
        model.get(CommonAttributes.CLIENT_ID.getName()).set(clientId);
    }
    final String discoveryGroupName = properties.containsKey(DISCOVERY_GROUP.getName()) ? properties.get(DISCOVERY_GROUP.getName()) : null;
    if (discoveryGroupName != null) {
        model.get(DISCOVERY_GROUP.getName()).set(discoveryGroupName);
    }
    final String jgroupsChannelName = properties.containsKey(JGROUPS_CHANNEL.getName()) ? properties.get(JGROUPS_CHANNEL.getName()) : null;
    if (jgroupsChannelName != null) {
        model.get(JGROUPS_CHANNEL.getName()).set(jgroupsChannelName);
    }
    final String managedConnectionPoolClassName = properties.containsKey(MANAGED_CONNECTION_POOL.getName()) ? properties.get(MANAGED_CONNECTION_POOL.getName()) : null;
    if (managedConnectionPoolClassName != null) {
        model.get(MANAGED_CONNECTION_POOL.getName()).set(managedConnectionPoolClassName);
    }
    final Boolean enlistmentTrace = properties.containsKey(ENLISTMENT_TRACE.getName()) ? Boolean.valueOf(properties.get(ENLISTMENT_TRACE.getName())) : null;
    List<PooledConnectionFactoryConfigProperties> adapterParams = getAdapterParams(model);
    String txSupport = transactional ? XA_TX : NO_TX;
    final String serverName = getActiveMQServerName(properties);
    final String pcfName = uniqueName(context, name);
    final ContextNames.BindInfo bindInfo = ContextNames.bindInfoForEnvEntry(context.getApplicationName(), context.getModuleName(), context.getComponentName(), !context.isCompUsesModule(), name);
    PooledConnectionFactoryService.installService(serviceTarget, pcfName, serverName, connectors, discoveryGroupName, jgroupsChannelName, adapterParams, bindInfo, txSupport, minPoolSize, maxPoolSize, managedConnectionPoolClassName, enlistmentTrace, true);
    final ServiceName referenceFactoryServiceName = ConnectionFactoryReferenceFactoryService.SERVICE_NAME_BASE.append(bindInfo.getBinderServiceName());
    serviceBuilder.addDependency(referenceFactoryServiceName, ManagedReferenceFactory.class, injector);
    //create the management registration
    String managementName = managementName(context, name);
    final PathElement serverElement = PathElement.pathElement(SERVER, serverName);
    final DeploymentResourceSupport deploymentResourceSupport = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_RESOURCE_SUPPORT);
    deploymentResourceSupport.getDeploymentSubModel(MessagingExtension.SUBSYSTEM_NAME, serverElement);
    final PathElement pcfPath = PathElement.pathElement(POOLED_CONNECTION_FACTORY, managementName);
    PathAddress registration = PathAddress.pathAddress(serverElement, pcfPath);
    MessagingXmlInstallDeploymentUnitProcessor.createDeploymentSubModel(registration, deploymentUnit);
    PooledConnectionFactoryConfigurationRuntimeHandler.INSTANCE.registerResource(serverName, managementName, model);
}
Also used : HashMap(java.util.HashMap) PooledConnectionFactoryConfigProperties(org.wildfly.extension.messaging.activemq.jms.PooledConnectionFactoryConfigProperties) 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) Map(java.util.Map) HashMap(java.util.HashMap) ContextNames(org.jboss.as.naming.deployment.ContextNames)

Example 2 with PooledConnectionFactoryConfigProperties

use of org.wildfly.extension.messaging.activemq.jms.PooledConnectionFactoryConfigProperties in project wildfly by wildfly.

the class JMSConnectionFactoryDefinitionInjectionSource method getAdapterParams.

private List<PooledConnectionFactoryConfigProperties> getAdapterParams(ModelNode model) {
    Map<String, ConnectionFactoryAttribute> attributes = PooledConnectionFactoryDefinition.getAttributesMap();
    List<PooledConnectionFactoryConfigProperties> props = new ArrayList<>();
    for (Property property : model.asPropertyList()) {
        ConnectionFactoryAttribute attribute = attributes.get(property.getName());
        if (attribute.getPropertyName() == null) {
            // not a RA property
            continue;
        }
        props.add(new PooledConnectionFactoryConfigProperties(attribute.getPropertyName(), property.getValue().asString(), attribute.getClassType()));
    }
    return props;
}
Also used : PooledConnectionFactoryConfigProperties(org.wildfly.extension.messaging.activemq.jms.PooledConnectionFactoryConfigProperties) ConnectionFactoryAttribute(org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttribute) ArrayList(java.util.ArrayList) Property(org.jboss.dmr.Property)

Aggregations

PooledConnectionFactoryConfigProperties (org.wildfly.extension.messaging.activemq.jms.PooledConnectionFactoryConfigProperties)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 PathAddress (org.jboss.as.controller.PathAddress)1 PathElement (org.jboss.as.controller.PathElement)1 ContextNames (org.jboss.as.naming.deployment.ContextNames)1 DeploymentResourceSupport (org.jboss.as.server.deployment.DeploymentResourceSupport)1 ModelNode (org.jboss.dmr.ModelNode)1 Property (org.jboss.dmr.Property)1 ServiceName (org.jboss.msc.service.ServiceName)1 ConnectionFactoryAttribute (org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttribute)1