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