use of org.wildfly.clustering.service.ServiceDependency in project wildfly by wildfly.
the class CacheServiceConfigurator method configure.
@Override
public ServiceConfigurator configure(CapabilityServiceSupport support) {
this.container = new ServiceSupplierDependency<>(InfinispanRequirement.CONTAINER.getServiceName(support, this.containerName));
this.configuration = new ServiceDependency(InfinispanCacheRequirement.CONFIGURATION.getServiceName(support, this.containerName, this.cacheName));
return this;
}
use of org.wildfly.clustering.service.ServiceDependency in project wildfly by wildfly.
the class InfinispanBeanManagerFactoryServiceConfiguratorFactory method getDeploymentServiceConfigurators.
@Override
public Iterable<CapabilityServiceConfigurator> getDeploymentServiceConfigurators(final ServiceName name) {
String cacheName = getCacheName(name, this.name);
String containerName = this.config.getContainerName();
String templateCacheName = this.config.getCacheName();
// Ensure eviction and expiration are disabled
Consumer<ConfigurationBuilder> configurator = builder -> {
// Ensure expiration is not enabled on cache
ExpirationConfiguration expiration = builder.expiration().create();
if ((expiration.lifespan() >= 0) || (expiration.maxIdle() >= 0)) {
builder.expiration().lifespan(-1).maxIdle(-1);
InfinispanEjbLogger.ROOT_LOGGER.expirationDisabled(InfinispanCacheRequirement.CONFIGURATION.resolve(containerName, templateCacheName));
}
int size = this.config.getMaxSize();
EvictionStrategy strategy = (size > 0) ? EvictionStrategy.REMOVE : EvictionStrategy.MANUAL;
builder.memory().storage(StorageType.HEAP).whenFull(strategy).maxCount(size);
if (strategy.isEnabled()) {
// Only evict bean group entries
// We will cascade eviction to the associated beans
builder.addModule(DataContainerConfigurationBuilder.class).evictable(BeanGroupKey.class::isInstance);
}
};
CapabilityServiceConfigurator configurationConfigurator = new TemplateConfigurationServiceConfigurator(ServiceNameFactory.parseServiceName(InfinispanCacheRequirement.CONFIGURATION.getName()).append(containerName, cacheName), containerName, cacheName, templateCacheName, configurator);
CapabilityServiceConfigurator cacheConfigurator = new CacheServiceConfigurator<>(ServiceNameFactory.parseServiceName(InfinispanCacheRequirement.CACHE.getName()).append(containerName, cacheName), containerName, cacheName).require(new ServiceDependency(name.append("marshalling")));
List<Iterable<CapabilityServiceConfigurator>> configurators = new LinkedList<>();
configurators.add(Arrays.asList(configurationConfigurator, cacheConfigurator));
ServiceNameRegistry<ClusteringCacheRequirement> registry = new ServiceNameRegistry<ClusteringCacheRequirement>() {
@Override
public ServiceName getServiceName(ClusteringCacheRequirement requirement) {
return (requirement == ClusteringCacheRequirement.GROUP) ? ServiceNameFactory.parseServiceName(requirement.getName()).append(containerName, cacheName) : null;
}
};
for (CacheServiceConfiguratorProvider provider : ServiceLoader.load(DistributedCacheServiceConfiguratorProvider.class, DistributedCacheServiceConfiguratorProvider.class.getClassLoader())) {
configurators.add(provider.getServiceConfigurators(registry, containerName, cacheName));
}
return new CompositeIterable<>(configurators);
}
Aggregations