use of org.jboss.as.clustering.controller.ModuleBuilder in project wildfly by wildfly.
the class CacheContainerServiceHandler method installServices.
@Override
public void installServices(OperationContext context, ModelNode model) throws OperationFailedException {
PathAddress address = context.getCurrentAddress();
String name = context.getCurrentAddressValue();
// This can happen if the ejb cache-container is added to a running server
if (context.getProcessType().isServer() && !context.isBooting() && name.equals("ejb")) {
Resource rootResource = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS);
PathElement ejbPath = PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, "ejb3");
if (rootResource.hasChild(ejbPath) && rootResource.getChild(ejbPath).hasChild(PathElement.pathElement("service", "remote"))) {
// Following restart, these services will be installed by this handler, rather than the ejb remote handler
context.addStep(new OperationStepHandler() {
@Override
public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException {
context.reloadRequired();
context.completeStep(OperationContext.RollbackHandler.REVERT_RELOAD_REQUIRED_ROLLBACK_HANDLER);
}
}, OperationContext.Stage.RUNTIME);
return;
}
}
ServiceTarget target = context.getServiceTarget();
new ModuleBuilder(CacheContainerComponent.MODULE.getServiceName(address), MODULE).configure(context, model).build(target).install();
new GlobalConfigurationBuilder(address).configure(context, model).build(target).install();
CacheContainerBuilder containerBuilder = new CacheContainerBuilder(address).configure(context, model);
containerBuilder.build(target).install();
new KeyAffinityServiceFactoryBuilder(address).build(target).install();
BinderServiceBuilder<?> bindingBuilder = new BinderServiceBuilder<>(InfinispanBindingFactory.createCacheContainerBinding(name), containerBuilder.getServiceName(), CacheContainer.class);
ModelNodes.optionalString(JNDI_NAME.resolveModelAttribute(context, model)).map(jndiName -> ContextNames.bindInfoFor(JndiNameFactory.parse(jndiName).getAbsoluteName())).ifPresent(aliasBinding -> bindingBuilder.alias(aliasBinding));
bindingBuilder.build(target).install();
String defaultCache = containerBuilder.getDefaultCache();
if (defaultCache != null) {
DEFAULT_CAPABILITIES.entrySet().forEach(entry -> new AliasServiceBuilder<>(entry.getValue().getServiceName(address), entry.getKey().getServiceName(context, name, defaultCache), entry.getKey().getType()).build(target).install());
if (!defaultCache.equals(JndiNameFactory.DEFAULT_LOCAL_NAME)) {
new BinderServiceBuilder<>(InfinispanBindingFactory.createCacheBinding(name, JndiNameFactory.DEFAULT_LOCAL_NAME), DEFAULT_CAPABILITIES.get(InfinispanCacheRequirement.CACHE).getServiceName(address), Cache.class).build(target).install();
new BinderServiceBuilder<>(InfinispanBindingFactory.createCacheConfigurationBinding(name, JndiNameFactory.DEFAULT_LOCAL_NAME), DEFAULT_CAPABILITIES.get(InfinispanCacheRequirement.CONFIGURATION).getServiceName(address), Configuration.class).build(target).install();
}
for (CacheAliasBuilderProvider provider : ServiceLoader.load(CacheAliasBuilderProvider.class, CacheAliasBuilderProvider.class.getClassLoader())) {
for (CapabilityServiceBuilder<?> builder : provider.getBuilders(requirement -> DEFAULT_CLUSTERING_CAPABILITIES.get(requirement).getServiceName(address), name, null, defaultCache)) {
builder.configure(context).build(target).install();
}
}
}
}
use of org.jboss.as.clustering.controller.ModuleBuilder in project wildfly by wildfly.
the class ChannelServiceHandler method installServices.
@Override
public void installServices(OperationContext context, ModelNode model) throws OperationFailedException {
PathAddress address = context.getCurrentAddress();
String name = context.getCurrentAddressValue();
String stack = STACK.resolveModelAttribute(context, model).asString();
ServiceTarget target = context.getServiceTarget();
new ChannelClusterBuilder(JCHANNEL_CLUSTER.getServiceName(address), name).configure(context, model).build(target).install();
new ChannelBuilder(JCHANNEL.getServiceName(address), name).statisticsEnabled(STATISTICS_ENABLED.resolveModelAttribute(context, model).asBoolean()).configure(context, model).build(target).install();
new AliasServiceBuilder<>(JCHANNEL_FACTORY.getServiceName(address), JGroupsRequirement.CHANNEL_FACTORY.getServiceName(context, stack), JGroupsRequirement.CHANNEL_FACTORY.getType()).build(target).install();
new ForkChannelFactoryBuilder(FORK_CHANNEL_FACTORY.getServiceName(address), name).configure(context, model).build(target).install();
new ModuleBuilder(JCHANNEL_MODULE.getServiceName(address), MODULE).configure(context, model).build(target).install();
new BinderServiceBuilder<>(JGroupsBindingFactory.createChannelBinding(name), JGroupsRequirement.CHANNEL.getServiceName(context, name), JGroupsRequirement.CHANNEL.getType()).build(target).install();
new BinderServiceBuilder<>(JGroupsBindingFactory.createChannelFactoryBinding(name), JGroupsRequirement.CHANNEL_FACTORY.getServiceName(context, name), JGroupsRequirement.CHANNEL_FACTORY.getType()).build(target).install();
// Install group services for channel
for (GroupBuilderProvider provider : ServiceLoader.load(DistributedGroupBuilderProvider.class, DistributedGroupBuilderProvider.class.getClassLoader())) {
for (CapabilityServiceBuilder<?> builder : provider.getBuilders(requirement -> CLUSTERING_CAPABILITIES.get(requirement).getServiceName(address), name)) {
JGroupsLogger.ROOT_LOGGER.debugf("Installing %s for channel %s", builder.getServiceName(), name);
builder.configure(context).build(target).install();
}
}
}
use of org.jboss.as.clustering.controller.ModuleBuilder in project wildfly by wildfly.
the class CacheServiceHandler method installServices.
@Override
public void installServices(OperationContext context, ModelNode model) throws OperationFailedException {
PathAddress cacheAddress = context.getCurrentAddress();
PathAddress containerAddress = cacheAddress.getParent();
String containerName = containerAddress.getLastElement().getValue();
String cacheName = cacheAddress.getLastElement().getValue();
ServiceTarget target = context.getServiceTarget();
ServiceName moduleServiceName = CacheComponent.MODULE.getServiceName(cacheAddress);
if (model.hasDefined(MODULE.getName())) {
new ModuleBuilder(moduleServiceName, MODULE).configure(context, model).build(target).install();
} else {
new AliasServiceBuilder<>(moduleServiceName, CacheContainerComponent.MODULE.getServiceName(containerAddress), Module.class).build(target).install();
}
this.builderFactory.createBuilder(cacheAddress).configure(context, model).build(target).setInitialMode(ServiceController.Mode.PASSIVE).install();
new CacheBuilder<>(CACHE.getServiceName(cacheAddress), containerName, cacheName).configure(context).build(target).install();
new XAResourceRecoveryBuilder(cacheAddress).build(target).install();
new BinderServiceBuilder<>(InfinispanBindingFactory.createCacheConfigurationBinding(containerName, cacheName), CONFIGURATION.getServiceName(cacheAddress), Configuration.class).build(target).install();
BinderServiceBuilder<?> bindingBuilder = new BinderServiceBuilder<>(InfinispanBindingFactory.createCacheBinding(containerName, cacheName), CACHE.getServiceName(cacheAddress), Cache.class);
ModelNodes.optionalString(JNDI_NAME.resolveModelAttribute(context, model)).map(jndiName -> ContextNames.bindInfoFor(JndiNameFactory.parse(jndiName).getAbsoluteName())).ifPresent(aliasBinding -> bindingBuilder.alias(aliasBinding));
bindingBuilder.build(target).install();
for (CacheBuilderProvider provider : ServiceLoader.load(this.providerClass, this.providerClass.getClassLoader())) {
for (CapabilityServiceBuilder<?> builder : provider.getBuilders(requirement -> CLUSTERING_CAPABILITIES.get(requirement).getServiceName(cacheAddress), containerName, cacheName)) {
builder.configure(context).build(target).install();
}
}
}
Aggregations