Search in sources :

Example 1 with SimpleCacheFactoryBuilderServiceConfigurator

use of org.jboss.as.ejb3.cache.simple.SimpleCacheFactoryBuilderServiceConfigurator 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();
}
Also used : ServiceTarget(org.jboss.msc.service.ServiceTarget) DistributableCacheFactoryBuilderServiceNameProvider(org.jboss.as.ejb3.cache.distributable.DistributableCacheFactoryBuilderServiceNameProvider) CacheFactoryBuilderServiceNameProvider(org.jboss.as.ejb3.cache.CacheFactoryBuilderServiceNameProvider) DistributableCacheFactoryBuilderServiceNameProvider(org.jboss.as.ejb3.cache.distributable.DistributableCacheFactoryBuilderServiceNameProvider) ModelNode(org.jboss.dmr.ModelNode) IdentityServiceConfigurator(org.wildfly.clustering.service.IdentityServiceConfigurator) IdentityServiceConfigurator(org.wildfly.clustering.service.IdentityServiceConfigurator) ServiceConfigurator(org.wildfly.clustering.service.ServiceConfigurator) SimpleCacheFactoryBuilderServiceConfigurator(org.jboss.as.ejb3.cache.simple.SimpleCacheFactoryBuilderServiceConfigurator)

Aggregations

CacheFactoryBuilderServiceNameProvider (org.jboss.as.ejb3.cache.CacheFactoryBuilderServiceNameProvider)1 DistributableCacheFactoryBuilderServiceNameProvider (org.jboss.as.ejb3.cache.distributable.DistributableCacheFactoryBuilderServiceNameProvider)1 SimpleCacheFactoryBuilderServiceConfigurator (org.jboss.as.ejb3.cache.simple.SimpleCacheFactoryBuilderServiceConfigurator)1 ModelNode (org.jboss.dmr.ModelNode)1 ServiceTarget (org.jboss.msc.service.ServiceTarget)1 IdentityServiceConfigurator (org.wildfly.clustering.service.IdentityServiceConfigurator)1 ServiceConfigurator (org.wildfly.clustering.service.ServiceConfigurator)1