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