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);
}
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);
}
}
}
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);
}
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);
}
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);
}
Aggregations