Search in sources :

Example 6 with ServiceNameProvider

use of org.wildfly.clustering.service.ServiceNameProvider in project wildfly by wildfly.

the class CacheContainerServiceHandler method removeServices.

@Override
public void removeServices(OperationContext context, ModelNode model) throws OperationFailedException {
    PathAddress address = context.getCurrentAddress();
    String name = context.getCurrentAddressValue();
    ModelNodes.optionalString(DEFAULT_CACHE.resolveModelAttribute(context, model)).ifPresent(defaultCache -> {
        for (CacheAliasBuilderProvider provider : ServiceLoader.load(CacheAliasBuilderProvider.class, CacheAliasBuilderProvider.class.getClassLoader())) {
            for (ServiceNameProvider builder : provider.getBuilders(requirement -> DEFAULT_CLUSTERING_CAPABILITIES.get(requirement).getServiceName(address), name, null, defaultCache)) {
                context.removeService(builder.getServiceName());
            }
        }
        if (!defaultCache.equals(JndiNameFactory.DEFAULT_LOCAL_NAME)) {
            context.removeService(InfinispanBindingFactory.createCacheBinding(name, JndiNameFactory.DEFAULT_LOCAL_NAME).getBinderServiceName());
            context.removeService(InfinispanBindingFactory.createCacheConfigurationBinding(name, JndiNameFactory.DEFAULT_LOCAL_NAME).getBinderServiceName());
        }
        DEFAULT_CAPABILITIES.values().forEach(capability -> context.removeService(capability.getServiceName(address)));
    });
    context.removeService(InfinispanBindingFactory.createCacheContainerBinding(name).getBinderServiceName());
    context.removeService(CacheContainerComponent.MODULE.getServiceName(address));
    EnumSet.allOf(CacheContainerResourceDefinition.Capability.class).stream().map(component -> component.getServiceName(address)).forEach(serviceName -> context.removeService(serviceName));
}
Also used : OperationStepHandler(org.jboss.as.controller.OperationStepHandler) ServiceNameProvider(org.wildfly.clustering.service.ServiceNameProvider) Cache(org.infinispan.Cache) CacheContainer(org.wildfly.clustering.infinispan.spi.CacheContainer) ModuleBuilder(org.jboss.as.clustering.controller.ModuleBuilder) OperationContext(org.jboss.as.controller.OperationContext) AliasServiceBuilder(org.wildfly.clustering.service.AliasServiceBuilder) CacheAliasBuilderProvider(org.wildfly.clustering.spi.CacheAliasBuilderProvider) DEFAULT_CLUSTERING_CAPABILITIES(org.jboss.as.clustering.infinispan.subsystem.CacheContainerResourceDefinition.DEFAULT_CLUSTERING_CAPABILITIES) CapabilityServiceBuilder(org.jboss.as.clustering.controller.CapabilityServiceBuilder) ServiceTarget(org.jboss.msc.service.ServiceTarget) Attribute(org.jboss.as.clustering.infinispan.subsystem.CacheContainerResourceDefinition.Attribute) ModelDescriptionConstants(org.jboss.as.controller.descriptions.ModelDescriptionConstants) EnumSet(java.util.EnumSet) BinderServiceBuilder(org.jboss.as.clustering.naming.BinderServiceBuilder) ContextNames(org.jboss.as.naming.deployment.ContextNames) Resource(org.jboss.as.controller.registry.Resource) PathAddress(org.jboss.as.controller.PathAddress) ServiceLoader(java.util.ServiceLoader) PathElement(org.jboss.as.controller.PathElement) ModelNodes(org.jboss.as.clustering.dmr.ModelNodes) ResourceServiceHandler(org.jboss.as.clustering.controller.ResourceServiceHandler) OperationFailedException(org.jboss.as.controller.OperationFailedException) DEFAULT_CAPABILITIES(org.jboss.as.clustering.infinispan.subsystem.CacheContainerResourceDefinition.DEFAULT_CAPABILITIES) Configuration(org.infinispan.configuration.cache.Configuration) InfinispanCacheRequirement(org.wildfly.clustering.infinispan.spi.InfinispanCacheRequirement) ModelNode(org.jboss.dmr.ModelNode) JndiNameFactory(org.jboss.as.clustering.naming.JndiNameFactory) CacheAliasBuilderProvider(org.wildfly.clustering.spi.CacheAliasBuilderProvider) PathAddress(org.jboss.as.controller.PathAddress) ServiceNameProvider(org.wildfly.clustering.service.ServiceNameProvider)

Aggregations

PathAddress (org.jboss.as.controller.PathAddress)6 ServiceNameProvider (org.wildfly.clustering.service.ServiceNameProvider)6 EnumSet (java.util.EnumSet)4 ServiceLoader (java.util.ServiceLoader)4 CapabilityServiceBuilder (org.jboss.as.clustering.controller.CapabilityServiceBuilder)4 ResourceServiceHandler (org.jboss.as.clustering.controller.ResourceServiceHandler)4 OperationContext (org.jboss.as.controller.OperationContext)4 OperationFailedException (org.jboss.as.controller.OperationFailedException)4 ModelNode (org.jboss.dmr.ModelNode)4 ServiceTarget (org.jboss.msc.service.ServiceTarget)4 ServiceController (org.jboss.msc.service.ServiceController)3 GroupAliasBuilderProvider (org.wildfly.clustering.spi.GroupAliasBuilderProvider)3 Cache (org.infinispan.Cache)2 Configuration (org.infinispan.configuration.cache.Configuration)2 ModuleBuilder (org.jboss.as.clustering.controller.ModuleBuilder)2 ModelNodes (org.jboss.as.clustering.dmr.ModelNodes)2 BinderServiceBuilder (org.jboss.as.clustering.naming.BinderServiceBuilder)2 JndiNameFactory (org.jboss.as.clustering.naming.JndiNameFactory)2 ContextNames (org.jboss.as.naming.deployment.ContextNames)2 AliasServiceBuilder (org.wildfly.clustering.service.AliasServiceBuilder)2