Search in sources :

Example 1 with IdentityServiceConfigurator

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

the class CacheContainerServiceHandler method installServices.

@Override
public void installServices(OperationContext context, ModelNode model) throws OperationFailedException {
    PathAddress address = context.getCurrentAddress();
    String name = context.getCurrentAddressValue();
    ServiceTarget target = context.getServiceTarget();
    new ModulesServiceConfigurator(CacheContainerComponent.MODULES.getServiceName(address), MODULES, Collections.singletonList(Module.forClass(WildFlyInfinispanModuleLifecycle.class))).configure(context, model).build(target).setInitialMode(ServiceController.Mode.PASSIVE).install();
    GlobalConfigurationServiceConfigurator configBuilder = new GlobalConfigurationServiceConfigurator(address);
    configBuilder.configure(context, model).build(target).install();
    CacheContainerServiceConfigurator containerBuilder = new CacheContainerServiceConfigurator(address, this.cacheRegistry).configure(context, model);
    containerBuilder.build(target).install();
    new ServiceValueCaptorServiceConfigurator<>(this.containerRegistry.add(containerBuilder.getServiceName())).build(target).install();
    new KeyAffinityServiceFactoryServiceConfigurator(address).build(target).install();
    new BinderServiceConfigurator(InfinispanBindingFactory.createCacheContainerBinding(name), containerBuilder.getServiceName()).build(target).install();
    String defaultCache = DEFAULT_CACHE.resolveModelAttribute(context, model).asString(null);
    if (defaultCache != null) {
        for (Map.Entry<InfinispanCacheRequirement, Capability> entry : DEFAULT_CAPABILITIES.entrySet()) {
            new IdentityServiceConfigurator<>(entry.getValue().getServiceName(address), entry.getKey().getServiceName(context, name, defaultCache)).build(target).install();
        }
        if (!defaultCache.equals(JndiNameFactory.DEFAULT_LOCAL_NAME)) {
            new BinderServiceConfigurator(InfinispanBindingFactory.createCacheBinding(name, JndiNameFactory.DEFAULT_LOCAL_NAME), DEFAULT_CAPABILITIES.get(InfinispanCacheRequirement.CACHE).getServiceName(address)).build(target).install();
            new BinderServiceConfigurator(InfinispanBindingFactory.createCacheConfigurationBinding(name, JndiNameFactory.DEFAULT_LOCAL_NAME), DEFAULT_CAPABILITIES.get(InfinispanCacheRequirement.CONFIGURATION).getServiceName(address)).build(target).install();
        }
        ServiceNameRegistry<ClusteringCacheRequirement> registry = new CapabilityServiceNameRegistry<>(DEFAULT_CLUSTERING_CAPABILITIES, address);
        for (IdentityCacheServiceConfiguratorProvider provider : ServiceLoader.load(IdentityCacheServiceConfiguratorProvider.class, IdentityCacheServiceConfiguratorProvider.class.getClassLoader())) {
            for (CapabilityServiceConfigurator configurator : provider.getServiceConfigurators(registry, name, null, defaultCache)) {
                configurator.configure(context).build(target).install();
            }
        }
    }
}
Also used : ModulesServiceConfigurator(org.jboss.as.clustering.controller.ModulesServiceConfigurator) CapabilityServiceNameRegistry(org.wildfly.clustering.spi.CapabilityServiceNameRegistry) BinderServiceConfigurator(org.jboss.as.clustering.naming.BinderServiceConfigurator) Capability(org.jboss.as.clustering.controller.Capability) CapabilityServiceConfigurator(org.jboss.as.clustering.controller.CapabilityServiceConfigurator) ServiceTarget(org.jboss.msc.service.ServiceTarget) ServiceValueCaptorServiceConfigurator(org.jboss.as.clustering.controller.ServiceValueCaptorServiceConfigurator) ClusteringCacheRequirement(org.wildfly.clustering.spi.ClusteringCacheRequirement) InfinispanCacheRequirement(org.wildfly.clustering.infinispan.spi.InfinispanCacheRequirement) IdentityCacheServiceConfiguratorProvider(org.wildfly.clustering.spi.IdentityCacheServiceConfiguratorProvider) PathAddress(org.jboss.as.controller.PathAddress) Map(java.util.Map) IdentityServiceConfigurator(org.wildfly.clustering.service.IdentityServiceConfigurator)

Example 2 with IdentityServiceConfigurator

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

the class EJB3SubsystemDefaultCacheWriteHandler method updateCacheService.

void updateCacheService(final OperationContext context, final ModelNode model) throws OperationFailedException {
    ModelNode cacheName = this.attribute.resolveModelAttribute(context, model);
    ServiceRegistry registry = context.getServiceRegistry(true);
    if (registry.getService(this.serviceName) != null) {
        context.removeService(this.serviceName);
    }
    if (cacheName.isDefined()) {
        new IdentityServiceConfigurator<>(this.serviceName, new CacheFactoryBuilderServiceNameProvider(cacheName.asString()).getServiceName()).build(context.getServiceTarget()).install();
    }
}
Also used : ServiceRegistry(org.jboss.msc.service.ServiceRegistry) ModelNode(org.jboss.dmr.ModelNode) CacheFactoryBuilderServiceNameProvider(org.jboss.as.ejb3.cache.CacheFactoryBuilderServiceNameProvider) IdentityServiceConfigurator(org.wildfly.clustering.service.IdentityServiceConfigurator)

Example 3 with IdentityServiceConfigurator

use of org.wildfly.clustering.service.IdentityServiceConfigurator 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)

Example 4 with IdentityServiceConfigurator

use of org.wildfly.clustering.service.IdentityServiceConfigurator 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();
        }
    }
}
Also used : ModulesServiceConfigurator(org.jboss.as.clustering.controller.ModulesServiceConfigurator) CapabilityServiceNameRegistry(org.wildfly.clustering.spi.CapabilityServiceNameRegistry) CacheServiceConfiguratorProvider(org.wildfly.clustering.spi.CacheServiceConfiguratorProvider) BinderServiceConfigurator(org.jboss.as.clustering.naming.BinderServiceConfigurator) CapabilityServiceConfigurator(org.jboss.as.clustering.controller.CapabilityServiceConfigurator) ServiceTarget(org.jboss.msc.service.ServiceTarget) ClusteringCacheRequirement(org.wildfly.clustering.spi.ClusteringCacheRequirement) ServiceName(org.jboss.msc.service.ServiceName) PathAddress(org.jboss.as.controller.PathAddress) IdentityServiceConfigurator(org.wildfly.clustering.service.IdentityServiceConfigurator)

Example 5 with IdentityServiceConfigurator

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

the class JGroupsSubsystemServiceHandler method installServices.

@Override
public void installServices(OperationContext context, ModelNode model) throws OperationFailedException {
    ROOT_LOGGER.activatingSubsystem(Version.printVersion());
    ServiceTarget target = context.getServiceTarget();
    PathAddress address = context.getCurrentAddress();
    // In this case, the Infinispan subsystem may have already registered default group capabilities
    if (context.getProcessType().isServer() && !context.isBooting()) {
        if (context.readResourceFromRoot(address.getParent(), false).hasChild(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, "infinispan"))) {
            // Following restart, default group services will be installed by this handler, rather than the infinispan subsystem handler
            context.addStep((ctx, operation) -> {
                ctx.reloadRequired();
                ctx.completeStep(OperationContext.RollbackHandler.REVERT_RELOAD_REQUIRED_ROLLBACK_HANDLER);
            }, OperationContext.Stage.RUNTIME);
            return;
        }
    }
    new ProtocolDefaultsServiceConfigurator().build(target).install();
    String defaultChannel = DEFAULT_CHANNEL.resolveModelAttribute(context, model).asStringOrNull();
    if (defaultChannel != null) {
        for (Map.Entry<JGroupsRequirement, Capability> entry : CAPABILITIES.entrySet()) {
            new IdentityServiceConfigurator<>(entry.getValue().getServiceName(address), entry.getKey().getServiceName(context, defaultChannel)).build(target).install();
        }
        if (!defaultChannel.equals(JndiNameFactory.DEFAULT_LOCAL_NAME)) {
            new BinderServiceConfigurator(JGroupsBindingFactory.createChannelBinding(JndiNameFactory.DEFAULT_LOCAL_NAME), JGroupsRequirement.CHANNEL.getServiceName(context, defaultChannel)).build(target).install();
            new BinderServiceConfigurator(JGroupsBindingFactory.createChannelFactoryBinding(JndiNameFactory.DEFAULT_LOCAL_NAME), JGroupsRequirement.CHANNEL_FACTORY.getServiceName(context, defaultChannel)).build(target).install();
        }
        ServiceNameRegistry<ClusteringRequirement> registry = new CapabilityServiceNameRegistry<>(CLUSTERING_CAPABILITIES, address);
        for (IdentityGroupServiceConfiguratorProvider provider : ServiceLoader.load(IdentityGroupServiceConfiguratorProvider.class, IdentityGroupServiceConfiguratorProvider.class.getClassLoader())) {
            for (CapabilityServiceConfigurator configurator : provider.getServiceConfigurators(registry, null, defaultChannel)) {
                configurator.configure(context).build(target).install();
            }
        }
    }
}
Also used : IdentityGroupServiceConfiguratorProvider(org.wildfly.clustering.spi.IdentityGroupServiceConfiguratorProvider) CapabilityServiceNameRegistry(org.wildfly.clustering.spi.CapabilityServiceNameRegistry) BinderServiceConfigurator(org.jboss.as.clustering.naming.BinderServiceConfigurator) Capability(org.jboss.as.clustering.controller.Capability) CapabilityServiceConfigurator(org.jboss.as.clustering.controller.CapabilityServiceConfigurator) ServiceTarget(org.jboss.msc.service.ServiceTarget) JGroupsRequirement(org.wildfly.clustering.jgroups.spi.JGroupsRequirement) PathAddress(org.jboss.as.controller.PathAddress) ClusteringRequirement(org.wildfly.clustering.spi.ClusteringRequirement) Map(java.util.Map) IdentityServiceConfigurator(org.wildfly.clustering.service.IdentityServiceConfigurator)

Aggregations

IdentityServiceConfigurator (org.wildfly.clustering.service.IdentityServiceConfigurator)8 ServiceTarget (org.jboss.msc.service.ServiceTarget)7 CapabilityServiceConfigurator (org.jboss.as.clustering.controller.CapabilityServiceConfigurator)5 BinderServiceConfigurator (org.jboss.as.clustering.naming.BinderServiceConfigurator)5 PathAddress (org.jboss.as.controller.PathAddress)5 CapabilityServiceNameRegistry (org.wildfly.clustering.spi.CapabilityServiceNameRegistry)5 ModelNode (org.jboss.dmr.ModelNode)3 ClusteringRequirement (org.wildfly.clustering.spi.ClusteringRequirement)3 Map (java.util.Map)2 Capability (org.jboss.as.clustering.controller.Capability)2 ModulesServiceConfigurator (org.jboss.as.clustering.controller.ModulesServiceConfigurator)2 ServiceValueCaptorServiceConfigurator (org.jboss.as.clustering.controller.ServiceValueCaptorServiceConfigurator)2 CacheFactoryBuilderServiceNameProvider (org.jboss.as.ejb3.cache.CacheFactoryBuilderServiceNameProvider)2 ServiceName (org.jboss.msc.service.ServiceName)2 ClusteringCacheRequirement (org.wildfly.clustering.spi.ClusteringCacheRequirement)2 IdentityGroupServiceConfiguratorProvider (org.wildfly.clustering.spi.IdentityGroupServiceConfiguratorProvider)2 ModuleServiceConfigurator (org.jboss.as.clustering.controller.ModuleServiceConfigurator)1 DistributableCacheFactoryBuilderServiceNameProvider (org.jboss.as.ejb3.cache.distributable.DistributableCacheFactoryBuilderServiceNameProvider)1 SimpleCacheFactoryBuilderServiceConfigurator (org.jboss.as.ejb3.cache.simple.SimpleCacheFactoryBuilderServiceConfigurator)1 ServiceRegistry (org.jboss.msc.service.ServiceRegistry)1