Search in sources :

Example 1 with DistributableSessionManagerFactoryBuilderValue

use of org.wildfly.extension.undertow.session.DistributableSessionManagerFactoryBuilderValue 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;
}
Also used : SimpleDistributableSessionManagerConfiguration(org.wildfly.extension.undertow.session.SimpleDistributableSessionManagerConfiguration) DistributableSessionManagerFactoryBuilder(org.wildfly.extension.undertow.session.DistributableSessionManagerFactoryBuilder) ServiceName(org.jboss.msc.service.ServiceName) InMemorySessionManagerFactory(io.undertow.servlet.core.InMemorySessionManagerFactory) DistributableSessionManagerFactoryBuilderValue(org.wildfly.extension.undertow.session.DistributableSessionManagerFactoryBuilderValue) ImmediateValue(org.jboss.msc.value.ImmediateValue)

Aggregations

InMemorySessionManagerFactory (io.undertow.servlet.core.InMemorySessionManagerFactory)1 ServiceName (org.jboss.msc.service.ServiceName)1 ImmediateValue (org.jboss.msc.value.ImmediateValue)1 DistributableSessionManagerFactoryBuilder (org.wildfly.extension.undertow.session.DistributableSessionManagerFactoryBuilder)1 DistributableSessionManagerFactoryBuilderValue (org.wildfly.extension.undertow.session.DistributableSessionManagerFactoryBuilderValue)1 SimpleDistributableSessionManagerConfiguration (org.wildfly.extension.undertow.session.SimpleDistributableSessionManagerConfiguration)1