Search in sources :

Example 1 with ServiceConfigurator

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

the class RemoteCacheContainerServiceHandler method installServices.

@Override
public void installServices(OperationContext context, ModelNode model) throws OperationFailedException {
    super.installServices(context, model);
    PathAddress address = context.getCurrentAddress();
    String name = context.getCurrentAddressValue();
    ServiceTarget target = context.getServiceTarget();
    Module defaultModule = Module.forClass(RemoteCacheContainer.class);
    new ModulesServiceConfigurator(RemoteCacheContainerComponent.MODULES.getServiceName(address), MODULES, Collections.singletonList(defaultModule)).configure(context, model).build(target).setInitialMode(ServiceController.Mode.PASSIVE).install();
    ServiceConfigurator containerBuilder = new RemoteCacheContainerServiceConfigurator(address).configure(context, model);
    containerBuilder.build(target).install();
    new ServiceValueCaptorServiceConfigurator<>(this.registry.add(containerBuilder.getServiceName())).build(target).install();
    new BinderServiceConfigurator(InfinispanBindingFactory.createRemoteCacheContainerBinding(name), containerBuilder.getServiceName()).build(target).install();
}
Also used : ModulesServiceConfigurator(org.jboss.as.clustering.controller.ModulesServiceConfigurator) BinderServiceConfigurator(org.jboss.as.clustering.naming.BinderServiceConfigurator) PathAddress(org.jboss.as.controller.PathAddress) ServiceTarget(org.jboss.msc.service.ServiceTarget) ServiceValueCaptorServiceConfigurator(org.jboss.as.clustering.controller.ServiceValueCaptorServiceConfigurator) Module(org.jboss.modules.Module) BinderServiceConfigurator(org.jboss.as.clustering.naming.BinderServiceConfigurator) ServiceValueCaptorServiceConfigurator(org.jboss.as.clustering.controller.ServiceValueCaptorServiceConfigurator) ModulesServiceConfigurator(org.jboss.as.clustering.controller.ModulesServiceConfigurator) ServiceConfigurator(org.wildfly.clustering.service.ServiceConfigurator)

Example 2 with ServiceConfigurator

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

the class DistributableSingleSignOnManagerServiceConfigurator method configure.

@Override
public ServiceConfigurator configure(OperationContext context) {
    String securityDomainName = this.configuration.getSecurityDomainName();
    Supplier<String> generator = this.configuration.getIdentifierGenerator();
    CapabilityServiceSupport support = context.getCapabilityServiceSupport();
    SupplierDependency<DistributableSSOManagementProvider> provider = getProvider(context, securityDomainName);
    ServiceName managerServiceName = this.getServiceName().append("manager");
    this.manager = new ServiceSupplierDependency<>(managerServiceName);
    this.provider = provider;
    this.installer = new Consumer<ServiceTarget>() {

        @Override
        public void accept(ServiceTarget target) {
            ServiceConfigurator factoryConfigurator = provider.get().getServiceConfigurator(securityDomainName).configure(support);
            factoryConfigurator.build(target).install();
            SupplierDependency<SSOManagerFactory<ElytronAuthentication, String, Map.Entry<String, URI>, Batch>> factoryDependency = new ServiceSupplierDependency<>(factoryConfigurator);
            SupplierDependency<SessionIdGenerator> generatorDependency = new SimpleSupplierDependency<>(new SessionIdGeneratorAdapter(generator));
            new SSOManagerServiceConfigurator<>(managerServiceName, factoryDependency, generatorDependency, new LocalSSOContextFactory()).configure(support).build(target).install();
        }
    };
    return this;
}
Also used : ServiceTarget(org.jboss.msc.service.ServiceTarget) SupplierDependency(org.wildfly.clustering.service.SupplierDependency) SimpleSupplierDependency(org.wildfly.clustering.service.SimpleSupplierDependency) ServiceSupplierDependency(org.wildfly.clustering.service.ServiceSupplierDependency) SSOManagerServiceConfigurator(org.wildfly.clustering.web.undertow.sso.SSOManagerServiceConfigurator) DistributableSSOManagementProvider(org.wildfly.clustering.web.sso.DistributableSSOManagementProvider) CapabilityServiceSupport(org.jboss.as.controller.capability.CapabilityServiceSupport) Entry(java.util.Map.Entry) ServiceName(org.jboss.msc.service.ServiceName) Batch(org.wildfly.clustering.ee.Batch) ServiceConfigurator(org.wildfly.clustering.service.ServiceConfigurator) SSOManagerServiceConfigurator(org.wildfly.clustering.web.undertow.sso.SSOManagerServiceConfigurator) CapabilityServiceConfigurator(org.jboss.as.clustering.controller.CapabilityServiceConfigurator)

Example 3 with ServiceConfigurator

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

the class ModClusterSubsystemServiceHandler method installServices.

@Override
public void installServices(OperationContext context, ModelNode model) throws OperationFailedException {
    if (!context.isBooting())
        return;
    Resource subsystemResource = context.readResource(PathAddress.EMPTY_ADDRESS);
    if (subsystemResource.hasChildren(ProxyConfigurationResourceDefinition.WILDCARD_PATH.getKey())) {
        Set<String> adapterNames = new HashSet<>();
        Set<LoadMetric> enabledMetrics = new HashSet<>();
        for (Resource.ResourceEntry proxyResource : subsystemResource.getChildren(ProxyConfigurationResourceDefinition.WILDCARD_PATH.getKey())) {
            String proxyName = proxyResource.getName();
            PathAddress proxyAddress = context.getCurrentAddress().append(ProxyConfigurationResourceDefinition.pathElement(proxyName));
            adapterNames.add(proxyName);
            ModelNode proxyModel = Resource.Tools.readModel(proxyResource);
            ServiceTarget target = context.getServiceTarget();
            ProxyConfigurationServiceConfigurator configurationBuilder = new ProxyConfigurationServiceConfigurator(proxyAddress);
            configurationBuilder.configure(context, proxyModel).build(target).install();
            // Construct LoadBalanceFactorProvider and call pluggable boot time metric
            Set<LoadMetric> metrics = new HashSet<>();
            LoadBalanceFactorProvider loadProvider = this.getLoadProvider(proxyName, metrics, context, proxyModel);
            enabledMetrics.addAll(metrics);
            String listenerName = LISTENER.resolveModelAttribute(context, proxyModel).asString();
            int statusInterval = STATUS_INTERVAL.resolveModelAttribute(context, proxyModel).asInt();
            ServiceConfigurator configurator = new ContainerEventHandlerServiceConfigurator(proxyAddress, loadProvider);
            configurator.build(target).install();
            new ServiceValueCaptorServiceConfigurator<>(this.registry.add(configurator.getServiceName())).build(target).install();
            // Install services for web container integration
            for (ContainerEventHandlerAdapterServiceConfiguratorProvider provider : ServiceLoader.load(ContainerEventHandlerAdapterServiceConfiguratorProvider.class, ContainerEventHandlerAdapterServiceConfiguratorProvider.class.getClassLoader())) {
                provider.getServiceConfigurator(proxyName, listenerName, Duration.ofSeconds(statusInterval)).configure(context).build(target).setInitialMode(Mode.PASSIVE).install();
            }
        }
        for (BoottimeHandlerProvider handler : ServiceLoader.load(BoottimeHandlerProvider.class, BoottimeHandlerProvider.class.getClassLoader())) {
            handler.performBoottime(context, adapterNames, enabledMetrics);
        }
    }
}
Also used : ServiceTarget(org.jboss.msc.service.ServiceTarget) Resource(org.jboss.as.controller.registry.Resource) ServiceValueCaptorServiceConfigurator(org.jboss.as.clustering.controller.ServiceValueCaptorServiceConfigurator) LoadBalanceFactorProvider(org.jboss.modcluster.load.LoadBalanceFactorProvider) SimpleLoadBalanceFactorProvider(org.jboss.modcluster.load.impl.SimpleLoadBalanceFactorProvider) DynamicLoadBalanceFactorProvider(org.jboss.modcluster.load.impl.DynamicLoadBalanceFactorProvider) LoadMetric(org.jboss.modcluster.load.metric.LoadMetric) PathAddress(org.jboss.as.controller.PathAddress) ModelNode(org.jboss.dmr.ModelNode) HashSet(java.util.HashSet) ServiceConfigurator(org.wildfly.clustering.service.ServiceConfigurator) ServiceValueCaptorServiceConfigurator(org.jboss.as.clustering.controller.ServiceValueCaptorServiceConfigurator)

Example 4 with ServiceConfigurator

use of org.wildfly.clustering.service.ServiceConfigurator 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 5 with ServiceConfigurator

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

the class EJB3RemoteServiceAdd method installRuntimeServices.

void installRuntimeServices(final OperationContext context, final ModelNode model) throws OperationFailedException {
    final String clientMappingsClusterName = EJB3RemoteResourceDefinition.CLIENT_MAPPINGS_CLUSTER_NAME.resolveModelAttribute(context, model).asString();
    final List<ModelNode> connectorNameNodes = EJB3RemoteResourceDefinition.CONNECTORS.resolveModelAttribute(context, model).asList();
    final String threadPoolName = EJB3RemoteResourceDefinition.THREAD_POOL_NAME.resolveModelAttribute(context, model).asString();
    final boolean executeInWorker = EJB3RemoteResourceDefinition.EXECUTE_IN_WORKER.resolveModelAttribute(context, model).asBoolean();
    final ServiceTarget target = context.getServiceTarget();
    // for each connector specified, we need to set up a client-mappings cache
    for (ModelNode connectorNameNode : connectorNameNodes) {
        String connectorName = connectorNameNode.asString();
        // Install the client-mapping service for the remoting connector
        ServiceConfigurator clientMappingsEntryProviderConfigurator = new EJBRemotingConnectorClientMappingsEntryProviderService(clientMappingsClusterName, connectorName).configure(context);
        clientMappingsEntryProviderConfigurator.build(target).setInitialMode(ServiceController.Mode.ON_DEMAND).install();
        if (this.provider != null) {
            // Install the registry for the remoting connector's client mappings
            SupplierDependency<Map.Entry<String, List<ClientMapping>>> registryEntryDependency = new ServiceSupplierDependency<>(clientMappingsEntryProviderConfigurator.getServiceName());
            for (CapabilityServiceConfigurator configurator : this.provider.getServiceConfigurators(clientMappingsClusterName, connectorName, new FunctionSupplierDependency<>(registryEntryDependency, Map.Entry::getValue))) {
                configurator.configure(context).build(target).install();
            }
        }
    }
    final OptionMap channelCreationOptions = this.getChannelCreationOptions(context);
    // Install the Jakarta Enterprise Beans remoting connector service which will listen for client connections on the remoting channel
    // TODO: Externalize (expose via management API if needed) the version and the marshalling strategy
    final EJBRemoteConnectorService ejbRemoteConnectorService = new EJBRemoteConnectorService(channelCreationOptions, FilterSpecClassResolverFilter.getFilterForOperationContext(context));
    CapabilityServiceBuilder<?> builder = (CapabilityServiceBuilder<?>) context.getCapabilityServiceTarget().addCapability(EJB3RemoteResourceDefinition.EJB_REMOTE_CAPABILITY).setInstance(ejbRemoteConnectorService).addCapabilityRequirement(EJB3RemoteResourceDefinition.REMOTING_ENDPOINT_CAPABILITY_NAME, Endpoint.class, ejbRemoteConnectorService.getEndpointInjector());
    if (!executeInWorker) {
        builder.addCapabilityRequirement(EJB3RemoteResourceDefinition.THREAD_POOL_CAPABILITY_NAME, ExecutorService.class, ejbRemoteConnectorService.getExecutorService(), threadPoolName);
    }
    // add rest of the dependencies
    builder.addDependency(AssociationService.SERVICE_NAME, AssociationService.class, ejbRemoteConnectorService.getAssociationServiceInjector()).addCapabilityRequirement(EJB3RemoteResourceDefinition.REMOTE_TRANSACTION_SERVICE_CAPABILITY_NAME, RemotingTransactionService.class, ejbRemoteConnectorService.getRemotingTransactionServiceInjector()).addAliases(EJBRemoteConnectorService.SERVICE_NAME).setInitialMode(ServiceController.Mode.LAZY).install();
}
Also used : CapabilityServiceConfigurator(org.jboss.as.clustering.controller.CapabilityServiceConfigurator) EJBRemotingConnectorClientMappingsEntryProviderService(org.jboss.as.ejb3.remote.EJBRemotingConnectorClientMappingsEntryProviderService) ServiceTarget(org.jboss.msc.service.ServiceTarget) ServiceSupplierDependency(org.wildfly.clustering.service.ServiceSupplierDependency) RemotingTransactionService(org.wildfly.transaction.client.provider.remoting.RemotingTransactionService) CapabilityServiceBuilder(org.jboss.as.controller.CapabilityServiceBuilder) Endpoint(org.jboss.remoting3.Endpoint) EJBRemoteConnectorService(org.jboss.as.ejb3.remote.EJBRemoteConnectorService) OptionMap(org.xnio.OptionMap) ClientMapping(org.jboss.as.network.ClientMapping) ModelNode(org.jboss.dmr.ModelNode) OptionMap(org.xnio.OptionMap) Map(java.util.Map) ServiceConfigurator(org.wildfly.clustering.service.ServiceConfigurator) CapabilityServiceConfigurator(org.jboss.as.clustering.controller.CapabilityServiceConfigurator)

Aggregations

ServiceConfigurator (org.wildfly.clustering.service.ServiceConfigurator)7 ServiceTarget (org.jboss.msc.service.ServiceTarget)6 CapabilityServiceConfigurator (org.jboss.as.clustering.controller.CapabilityServiceConfigurator)3 PathAddress (org.jboss.as.controller.PathAddress)3 ModelNode (org.jboss.dmr.ModelNode)3 ServiceValueCaptorServiceConfigurator (org.jboss.as.clustering.controller.ServiceValueCaptorServiceConfigurator)2 ServiceSupplierDependency (org.wildfly.clustering.service.ServiceSupplierDependency)2 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 ModulesServiceConfigurator (org.jboss.as.clustering.controller.ModulesServiceConfigurator)1 BinderServiceConfigurator (org.jboss.as.clustering.naming.BinderServiceConfigurator)1 CapabilityServiceBuilder (org.jboss.as.controller.CapabilityServiceBuilder)1 CapabilityServiceSupport (org.jboss.as.controller.capability.CapabilityServiceSupport)1 Resource (org.jboss.as.controller.registry.Resource)1 CacheFactoryBuilderServiceNameProvider (org.jboss.as.ejb3.cache.CacheFactoryBuilderServiceNameProvider)1 DistributableCacheFactoryBuilderServiceNameProvider (org.jboss.as.ejb3.cache.distributable.DistributableCacheFactoryBuilderServiceNameProvider)1 SimpleCacheFactoryBuilderServiceConfigurator (org.jboss.as.ejb3.cache.simple.SimpleCacheFactoryBuilderServiceConfigurator)1 EJBRemoteConnectorService (org.jboss.as.ejb3.remote.EJBRemoteConnectorService)1 EJBRemotingConnectorClientMappingsEntryProviderService (org.jboss.as.ejb3.remote.EJBRemotingConnectorClientMappingsEntryProviderService)1