use of org.wildfly.clustering.service.AliasServiceBuilder 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