use of org.wildfly.clustering.spi.ClusteringCacheRequirement 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.MODULES.getServiceName(cacheAddress);
if (model.hasDefined(MODULES.getName())) {
new ModulesServiceConfigurator(moduleServiceName, MODULES, Collections.emptyList()).configure(context, model).build(target).setInitialMode(ServiceController.Mode.ON_DEMAND).install();
} else {
new IdentityServiceConfigurator<>(moduleServiceName, CacheContainerComponent.MODULES.getServiceName(containerAddress)).build(target).install();
}
this.configuratorFactory.createServiceConfigurator(cacheAddress).configure(context, model).build(target).install();
new CacheServiceConfigurator<>(CACHE.getServiceName(cacheAddress), containerName, cacheName).configure(context).build(target).install();
if (context.hasOptionalCapability(XA_RESOURCE_RECOVERY_REGISTRY.getName(), null, null)) {
new XAResourceRecoveryServiceConfigurator(cacheAddress).configure(context).build(target).install();
}
new BinderServiceConfigurator(InfinispanBindingFactory.createCacheConfigurationBinding(containerName, cacheName), CONFIGURATION.getServiceName(cacheAddress)).build(target).install();
new BinderServiceConfigurator(InfinispanBindingFactory.createCacheBinding(containerName, cacheName), CACHE.getServiceName(cacheAddress)).build(target).install();
ServiceNameRegistry<ClusteringCacheRequirement> registry = new CapabilityServiceNameRegistry<>(CLUSTERING_CAPABILITIES, cacheAddress);
for (CacheServiceConfiguratorProvider provider : ServiceLoader.load(this.providerClass, this.providerClass.getClassLoader())) {
for (CapabilityServiceConfigurator configurator : provider.getServiceConfigurators(registry, containerName, cacheName)) {
configurator.configure(context).build(target).install();
}
}
}
use of org.wildfly.clustering.spi.ClusteringCacheRequirement in project wildfly by wildfly.
the class CacheServiceHandler method removeServices.
@Override
public void removeServices(OperationContext context, ModelNode model) {
PathAddress cacheAddress = context.getCurrentAddress();
PathAddress containerAddress = cacheAddress.getParent();
String containerName = containerAddress.getLastElement().getValue();
String cacheName = cacheAddress.getLastElement().getValue();
ServiceNameRegistry<ClusteringCacheRequirement> registry = new CapabilityServiceNameRegistry<>(CLUSTERING_CAPABILITIES, cacheAddress);
for (CacheServiceConfiguratorProvider provider : ServiceLoader.load(this.providerClass, this.providerClass.getClassLoader())) {
for (ServiceNameProvider configurator : provider.getServiceConfigurators(registry, containerName, cacheName)) {
context.removeService(configurator.getServiceName());
}
}
context.removeService(InfinispanBindingFactory.createCacheBinding(containerName, cacheName).getBinderServiceName());
context.removeService(InfinispanBindingFactory.createCacheConfigurationBinding(containerName, cacheName).getBinderServiceName());
context.removeService(new XAResourceRecoveryServiceConfigurator(cacheAddress).getServiceName());
context.removeService(CacheComponent.MODULES.getServiceName(cacheAddress));
for (Capability capability : EnumSet.allOf(Capability.class)) {
context.removeService(capability.getServiceName(cacheAddress));
}
}
use of org.wildfly.clustering.spi.ClusteringCacheRequirement 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);
}
use of org.wildfly.clustering.spi.ClusteringCacheRequirement in project wildfly by wildfly.
the class InfinispanClientMappingsRegistryProvider method getServiceConfigurators.
@Override
public Iterable<CapabilityServiceConfigurator> getServiceConfigurators(String containerName, String connectorName, SupplierDependency<List<ClientMapping>> clientMappings) {
CapabilityServiceConfigurator configurationConfigurator = new TemplateConfigurationServiceConfigurator(ServiceNameFactory.parseServiceName(InfinispanCacheRequirement.CONFIGURATION.getName()).append(containerName, connectorName), containerName, connectorName, null, this);
CapabilityServiceConfigurator cacheConfigurator = new CacheServiceConfigurator<>(ServiceNameFactory.parseServiceName(InfinispanCacheRequirement.CACHE.getName()).append(containerName, connectorName), containerName, connectorName);
CapabilityServiceConfigurator registryEntryConfigurator = new ClientMappingsRegistryEntryServiceConfigurator(containerName, connectorName, clientMappings);
List<Iterable<CapabilityServiceConfigurator>> configurators = new LinkedList<>();
configurators.add(Arrays.asList(configurationConfigurator, cacheConfigurator, registryEntryConfigurator));
ServiceNameRegistry<ClusteringCacheRequirement> routingRegistry = new ServiceNameRegistry<ClusteringCacheRequirement>() {
@Override
public ServiceName getServiceName(ClusteringCacheRequirement requirement) {
return REGISTRY_REQUIREMENTS.contains(requirement) ? ServiceNameFactory.parseServiceName(requirement.getName()).append(containerName, connectorName) : null;
}
};
for (CacheServiceConfiguratorProvider provider : ServiceLoader.load(DistributedCacheServiceConfiguratorProvider.class, DistributedCacheServiceConfiguratorProvider.class.getClassLoader())) {
configurators.add(provider.getServiceConfigurators(routingRegistry, containerName, connectorName));
}
return new CompositeIterable<>(configurators);
}
Aggregations