use of org.jboss.as.ejb3.cache.distributable.DistributableCacheFactoryBuilderServiceNameProvider in project wildfly by wildfly.
the class CacheFactoryAdd method performRuntime.
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
final String name = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.ADDRESS)).getLastElement().getValue();
ModelNode passivationStoreModel = CacheFactoryResourceDefinition.PASSIVATION_STORE.resolveModelAttribute(context, model);
String passivationStore = passivationStoreModel.isDefined() ? passivationStoreModel.asString() : null;
final Collection<String> unwrappedAliasValues = CacheFactoryResourceDefinition.ALIASES.unwrap(context, model);
final Set<String> aliases = unwrappedAliasValues != null ? new HashSet<>(unwrappedAliasValues) : Collections.<String>emptySet();
ServiceTarget target = context.getServiceTarget();
// set up the CacheFactoryBuilder service
ServiceConfigurator configurator = (passivationStore != null) ? new IdentityServiceConfigurator<>(new CacheFactoryBuilderServiceNameProvider(name).getServiceName(), new DistributableCacheFactoryBuilderServiceNameProvider(passivationStore).getServiceName()) : new SimpleCacheFactoryBuilderServiceConfigurator<>(name);
ServiceBuilder<?> builder = configurator.build(target);
// set up aliases to the CacheFactoryBuilder service
for (String alias : aliases) {
new IdentityServiceConfigurator<>(new CacheFactoryBuilderServiceNameProvider(alias).getServiceName(), configurator.getServiceName()).build(target).install();
}
builder.install();
}
Aggregations