Search in sources :

Example 66 with Service

use of org.jboss.msc.Service in project wildfly by wildfly.

the class HotRodSessionManagerFactoryServiceConfigurator method build.

@Override
public ServiceBuilder<?> build(ServiceTarget target) {
    this.cacheConfigurator.build(target).install();
    ServiceBuilder<?> builder = target.addService(this.getServiceName());
    Consumer<SessionManagerFactory<SC, LC, TransactionBatch>> factory = this.cache.register(builder).provides(this.getServiceName());
    Service service = new FunctionalService<>(factory, Function.identity(), this, Consumers.close());
    return builder.setInstance(service).setInitialMode(ServiceController.Mode.ON_DEMAND);
}
Also used : FunctionalService(org.wildfly.clustering.service.FunctionalService) SessionManagerFactory(org.wildfly.clustering.web.session.SessionManagerFactory) FunctionalService(org.wildfly.clustering.service.FunctionalService) Service(org.jboss.msc.Service)

Example 67 with Service

use of org.jboss.msc.Service in project wildfly by wildfly.

the class DistributableWebDeploymentDependencyProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext context) throws DeploymentUnitProcessingException {
    DeploymentUnit unit = context.getDeploymentUnit();
    WarMetaData warMetaData = unit.getAttachment(WarMetaData.ATTACHMENT_KEY);
    SharedSessionManagerConfig sharedConfig = unit.getAttachment(SharedSessionManagerConfig.ATTACHMENT_KEY);
    if (((warMetaData != null) && (warMetaData.getMergedJBossWebMetaData() != null && warMetaData.getMergedJBossWebMetaData().getDistributable() != null)) || ((sharedConfig != null) && sharedConfig.isDistributable())) {
        CapabilityServiceSupport support = unit.getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT);
        DistributableWebDeploymentConfiguration config = unit.getAttachment(CONFIGURATION_KEY);
        String name = (config != null) ? config.getSessionManagementName() : null;
        DistributableSessionManagementProvider management = (name == null) && (config != null) ? config.getSessionManagement() : null;
        List<String> immutableClasses = (config != null) ? config.getImmutableClasses() : Collections.emptyList();
        for (String immutableClass : immutableClasses) {
            unit.addToAttachmentList(DistributableSessionManagementProvider.IMMUTABILITY_ATTACHMENT_KEY, immutableClass);
        }
        if (management != null) {
            LOGGER.debugf("%s will use a deployment-specific distributable session management provider", unit.getName());
            ServiceTarget target = context.getServiceTarget();
            DeploymentUnit parentUnit = unit.getParent();
            String deploymentName = (parentUnit != null) ? parentUnit.getName() + "." + unit.getName() : unit.getName();
            ServiceName serviceName = WebProviderRequirement.SESSION_MANAGEMENT_PROVIDER.getServiceName(support, deploymentName);
            ServiceBuilder<?> builder = target.addService(serviceName);
            Consumer<DistributableSessionManagementProvider> injector = builder.provides(serviceName);
            Service service = Service.newInstance(injector, management);
            builder.setInstance(service).setInitialMode(ServiceController.Mode.ON_DEMAND).install();
            context.addDependency(serviceName, DistributableSessionManagementProvider.ATTACHMENT_KEY);
        } else {
            if (name != null) {
                LOGGER.debugf("%s will use the '%s' distributable session management provider", unit.getName(), name);
            } else {
                LOGGER.debugf("%s will use the default distributable session management provider", unit.getName());
            }
            context.addDependency(WebProviderRequirement.SESSION_MANAGEMENT_PROVIDER.getServiceName(support, name), DistributableSessionManagementProvider.ATTACHMENT_KEY);
        }
    }
}
Also used : ServiceTarget(org.jboss.msc.service.ServiceTarget) WarMetaData(org.jboss.as.web.common.WarMetaData) DistributableSessionManagementProvider(org.wildfly.clustering.web.session.DistributableSessionManagementProvider) Service(org.jboss.msc.Service) CapabilityServiceSupport(org.jboss.as.controller.capability.CapabilityServiceSupport) SharedSessionManagerConfig(org.jboss.as.web.session.SharedSessionManagerConfig) ServiceName(org.jboss.msc.service.ServiceName) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 68 with Service

use of org.jboss.msc.Service in project wildfly by wildfly.

the class RoutingProviderServiceConfigurator method build.

@Override
public ServiceBuilder<?> build(ServiceTarget target) {
    ServiceName name = this.getServiceName();
    ServiceBuilder<?> builder = target.addService(name);
    Consumer<RoutingProvider> provider = builder.provides(name);
    Service service = new FunctionalService<>(provider, Function.identity(), this);
    return builder.setInstance(service).setInitialMode(ServiceController.Mode.ON_DEMAND);
}
Also used : RoutingProvider(org.wildfly.clustering.web.routing.RoutingProvider) FunctionalService(org.wildfly.clustering.service.FunctionalService) ServiceName(org.jboss.msc.service.ServiceName) FunctionalService(org.wildfly.clustering.service.FunctionalService) Service(org.jboss.msc.Service)

Example 69 with Service

use of org.jboss.msc.Service in project wildfly by wildfly.

the class SSOManagementServiceConfigurator method build.

@Override
public ServiceBuilder<?> build(ServiceTarget target) {
    ServiceName name = this.getServiceName();
    ServiceBuilder<?> builder = target.addService(name);
    Consumer<DistributableSSOManagementProvider> provider = builder.provides(name);
    Service service = Service.newInstance(provider, this.get());
    return builder.setInstance(service).setInitialMode(ServiceController.Mode.ON_DEMAND);
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) Service(org.jboss.msc.Service) DistributableSSOManagementProvider(org.wildfly.clustering.web.sso.DistributableSSOManagementProvider)

Example 70 with Service

use of org.jboss.msc.Service in project wildfly by wildfly.

the class DistributableSingleSignOnManagerServiceConfigurator method build.

@Override
public ServiceBuilder<?> build(ServiceTarget target) {
    ServiceName name = this.getServiceName();
    ServiceController<?> installerController = this.provider.register(target.addService(name.append("installer"))).setInstance(new ChildTargetService(this.installer)).install();
    ServiceBuilder<?> builder = target.addService(name).addListener(new CascadeRemovalLifecycleListener(installerController));
    Consumer<SingleSignOnManager> manager = this.manager.register(builder).provides(name);
    Service service = new FunctionalService<>(manager, this, this.manager);
    return builder.setInstance(service);
}
Also used : FunctionalService(org.wildfly.clustering.service.FunctionalService) ServiceName(org.jboss.msc.service.ServiceName) ChildTargetService(org.wildfly.clustering.service.ChildTargetService) SingleSignOnManager(org.wildfly.security.http.util.sso.SingleSignOnManager) FunctionalService(org.wildfly.clustering.service.FunctionalService) Service(org.jboss.msc.Service) ChildTargetService(org.wildfly.clustering.service.ChildTargetService) CascadeRemovalLifecycleListener(org.wildfly.clustering.service.CascadeRemovalLifecycleListener)

Aggregations

Service (org.jboss.msc.Service)76 FunctionalService (org.wildfly.clustering.service.FunctionalService)46 CompositeDependency (org.wildfly.clustering.service.CompositeDependency)26 ServiceName (org.jboss.msc.service.ServiceName)23 AsyncServiceConfigurator (org.wildfly.clustering.service.AsyncServiceConfigurator)13 Dependency (org.wildfly.clustering.service.Dependency)7 ServiceSupplierDependency (org.wildfly.clustering.service.ServiceSupplierDependency)7 SupplierDependency (org.wildfly.clustering.service.SupplierDependency)7 StartContext (org.jboss.msc.service.StartContext)4 ExecutorService (java.util.concurrent.ExecutorService)3 CapabilityServiceSupport (org.jboss.as.controller.capability.CapabilityServiceSupport)3 ServerEnvironmentService (org.jboss.as.server.ServerEnvironmentService)3 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)3 ServiceTarget (org.jboss.msc.service.ServiceTarget)3 StopContext (org.jboss.msc.service.StopContext)3 RouteLocator (org.wildfly.clustering.web.routing.RouteLocator)3 Supplier (java.util.function.Supplier)2 CapabilityServiceConfigurator (org.jboss.as.clustering.controller.CapabilityServiceConfigurator)2 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)2 CacheFactoryBuilder (org.jboss.as.ejb3.cache.CacheFactoryBuilder)2