Skip to content

Commit

Permalink
WFLY-11534 DistributableCacheFactoryServiceConfigurator should genera…
Browse files Browse the repository at this point in the history
…te ServiceName for TSR via capability name
  • Loading branch information
pferraro committed Jan 19, 2019
1 parent 24e26e7 commit ff8d9d2
Showing 1 changed file with 4 additions and 10 deletions.
Expand Up @@ -5,12 +5,10 @@
package org.jboss.as.ejb3.cache.distributable; package org.jboss.as.ejb3.cache.distributable;


import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.Supplier;


import javax.transaction.TransactionSynchronizationRegistry; import javax.transaction.TransactionSynchronizationRegistry;


import org.jboss.as.clustering.controller.CapabilityServiceConfigurator; import org.jboss.as.clustering.controller.CapabilityServiceConfigurator;
import org.jboss.as.controller.ServiceNameFactory;
import org.jboss.as.controller.capability.CapabilityServiceSupport; import org.jboss.as.controller.capability.CapabilityServiceSupport;
import org.jboss.as.ejb3.cache.Cache; import org.jboss.as.ejb3.cache.Cache;
import org.jboss.as.ejb3.cache.CacheFactory; import org.jboss.as.ejb3.cache.CacheFactory;
Expand All @@ -26,6 +24,7 @@
import org.wildfly.clustering.ejb.BeanManagerFactory; import org.wildfly.clustering.ejb.BeanManagerFactory;
import org.wildfly.clustering.ejb.IdentifierFactory; import org.wildfly.clustering.ejb.IdentifierFactory;
import org.wildfly.clustering.ejb.PassivationListener; import org.wildfly.clustering.ejb.PassivationListener;
import org.wildfly.clustering.service.CompositeDependency;
import org.wildfly.clustering.service.ServiceConfigurator; import org.wildfly.clustering.service.ServiceConfigurator;
import org.wildfly.clustering.service.ServiceSupplierDependency; import org.wildfly.clustering.service.ServiceSupplierDependency;
import org.wildfly.clustering.service.SimpleServiceNameProvider; import org.wildfly.clustering.service.SimpleServiceNameProvider;
Expand All @@ -43,7 +42,7 @@ public class DistributableCacheFactoryServiceConfigurator<K, V extends Identifia
private final CapabilityServiceConfigurator configurator; private final CapabilityServiceConfigurator configurator;
private final SupplierDependency<BeanManagerFactory<K, V, Batch>> factory; private final SupplierDependency<BeanManagerFactory<K, V, Batch>> factory;


private volatile Supplier<TransactionSynchronizationRegistry> tsr; private volatile SupplierDependency<TransactionSynchronizationRegistry> tsr;


public DistributableCacheFactoryServiceConfigurator(ServiceName name, CapabilityServiceConfigurator configurator) { public DistributableCacheFactoryServiceConfigurator(ServiceName name, CapabilityServiceConfigurator configurator) {
super(name); super(name);
Expand All @@ -54,6 +53,7 @@ public DistributableCacheFactoryServiceConfigurator(ServiceName name, Capability
@Override @Override
public ServiceConfigurator configure(CapabilityServiceSupport support) { public ServiceConfigurator configure(CapabilityServiceSupport support) {
this.configurator.configure(support); this.configurator.configure(support);
this.tsr = new ServiceSupplierDependency<>(support.getCapabilityServiceName("org.wildfly.transactions.transaction-synchronization-registry"));
return this; return this;
} }


Expand All @@ -62,13 +62,7 @@ public ServiceBuilder<?> build(ServiceTarget target) {
this.configurator.build(target).install(); this.configurator.build(target).install();
ServiceName name = this.getServiceName(); ServiceName name = this.getServiceName();
ServiceBuilder<?> builder = target.addService(name); ServiceBuilder<?> builder = target.addService(name);
// Ensure the local transaction synchronization registry is started before the cache Consumer<CacheFactory<K, V>> factory = new CompositeDependency(this.factory, this.tsr).register(builder).provides(name);
// This parsing isn't 100% ideal as it's somewhat 'internal' knowledge of the relationship between
// capability names and service names. But at this point that relationship really needs to become
// a contract anyway
ServiceName tsrServiceName = ServiceNameFactory.parseServiceName("org.wildfly.transactions.transaction-synchronization-registry");
this.tsr = builder.requires(tsrServiceName);
Consumer<CacheFactory<K, V>> factory = this.factory.register(builder).provides(name);
Service service = Service.newInstance(factory, this); Service service = Service.newInstance(factory, this);
return builder.setInstance(service); return builder.setInstance(service);
} }
Expand Down

0 comments on commit ff8d9d2

Please sign in to comment.