use of org.wildfly.extension.undertow.session.SimpleDistributableSessionManagerConfiguration in project wildfly by wildfly.
the class SharedSessionManagerDeploymentProcessor method deploy.
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
SharedSessionManagerConfig sharedConfig = deploymentUnit.getAttachment(UndertowAttachments.SHARED_SESSION_MANAGER_CONFIG);
if (sharedConfig == null) {
return;
}
ServiceTarget target = phaseContext.getServiceTarget();
ServiceName deploymentServiceName = deploymentUnit.getServiceName();
ServiceName managerServiceName = deploymentServiceName.append(SharedSessionManagerConfig.SHARED_SESSION_MANAGER_SERVICE_NAME);
DistributableSessionManagerFactoryBuilder builder = new DistributableSessionManagerFactoryBuilderValue().getValue();
if (builder != null) {
CapabilityServiceSupport support = deploymentUnit.getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT);
Module module = deploymentUnit.getAttachment(Attachments.MODULE);
builder.build(support, target, managerServiceName, new SimpleDistributableSessionManagerConfiguration(sharedConfig, deploymentUnit.getName(), module)).setInitialMode(Mode.ON_DEMAND).install();
} else {
InMemorySessionManager manager = new InMemorySessionManager(deploymentUnit.getName(), sharedConfig.getMaxActiveSessions());
if (sharedConfig.getSessionConfig() != null) {
if (sharedConfig.getSessionConfig().getSessionTimeoutSet()) {
manager.setDefaultSessionTimeout(sharedConfig.getSessionConfig().getSessionTimeout());
}
}
SessionManagerFactory factory = new ImmediateSessionManagerFactory(manager);
target.addService(managerServiceName, new ValueService<>(new ImmediateValue<>(factory))).setInitialMode(Mode.ON_DEMAND).install();
}
ServiceName codecServiceName = deploymentServiceName.append(SharedSessionManagerConfig.SHARED_SESSION_IDENTIFIER_CODEC_SERVICE_NAME);
DistributableSessionIdentifierCodecBuilder sessionIdentifierCodecBuilder = new DistributableSessionIdentifierCodecBuilderValue().getValue();
if (sessionIdentifierCodecBuilder != null) {
sessionIdentifierCodecBuilder.build(target, codecServiceName, deploymentUnit.getName()).setInitialMode(Mode.ON_DEMAND).install();
} else {
// Fallback to simple codec if server does not support clustering
SimpleSessionIdentifierCodecService.build(target, codecServiceName).setInitialMode(Mode.ON_DEMAND).install();
}
}
use of org.wildfly.extension.undertow.session.SimpleDistributableSessionManagerConfiguration in project wildfly by wildfly.
the class UndertowDeploymentProcessor method installSessionManagerFactory.
private static ServiceName installSessionManagerFactory(CapabilityServiceSupport support, ServiceTarget target, ServiceName deploymentServiceName, String deploymentName, Module module, JBossWebMetaData metaData, ServletContainerService servletContainerService) {
Integer maxActiveSessions = metaData.getMaxActiveSessions();
if (maxActiveSessions == null && servletContainerService != null) {
maxActiveSessions = servletContainerService.getMaxSessions();
}
ServiceName name = deploymentServiceName.append("session");
if (metaData.getDistributable() != null) {
DistributableSessionManagerFactoryBuilder sessionManagerFactoryBuilder = new DistributableSessionManagerFactoryBuilderValue().getValue();
if (sessionManagerFactoryBuilder != null) {
sessionManagerFactoryBuilder.build(support, target, name, new SimpleDistributableSessionManagerConfiguration(maxActiveSessions, metaData.getReplicationConfig(), deploymentName, module)).setInitialMode(Mode.ON_DEMAND).install();
return name;
}
// Fallback to local session manager if server does not support clustering
UndertowLogger.ROOT_LOGGER.clusteringNotSupported();
}
InMemorySessionManagerFactory factory = (maxActiveSessions != null) ? new InMemorySessionManagerFactory(maxActiveSessions) : new InMemorySessionManagerFactory();
target.addService(name, new ValueService<>(new ImmediateValue<>(factory))).setInitialMode(Mode.ON_DEMAND).install();
return name;
}
Aggregations