Search in sources :

Example 1 with Session

use of org.wildfly.clustering.web.session.Session in project wildfly by wildfly.

the class DistributableSession method invalidate.

@Override
public void invalidate(HttpServerExchange exchange) {
    Map.Entry<Session<Map<String, Object>>, SessionConfig> entry = this.getSessionEntry();
    @SuppressWarnings("resource") Session<Map<String, Object>> session = entry.getKey();
    if (session.isValid()) {
        // Invoke listeners outside of the context of the batch associated with this session
        // Trigger attribute listeners
        this.manager.getSessionListeners().sessionDestroyed(this, exchange, SessionDestroyedReason.INVALIDATED);
        ImmutableSessionAttributes attributes = session.getAttributes();
        for (String name : attributes.getAttributeNames()) {
            Object value = attributes.getAttribute(name);
            this.manager.getSessionListeners().attributeRemoved(this, name, value);
        }
    }
    try (BatchContext context = this.resumeBatch()) {
        session.invalidate();
        if (exchange != null) {
            String id = session.getId();
            entry.getValue().clearSession(exchange, id);
        }
        // An OOB session has no batch
        if (this.batch != null) {
            this.batch.close();
        }
    } catch (IllegalStateException e) {
        // If Session.invalidate() fails due to concurrent invalidation, close this session
        if (!session.isValid()) {
            session.close();
        }
        throw e;
    } finally {
        this.closeTask.accept(exchange);
    }
}
Also used : ImmutableSessionAttributes(org.wildfly.clustering.web.session.ImmutableSessionAttributes) SessionConfig(io.undertow.server.session.SessionConfig) BatchContext(org.wildfly.clustering.ee.BatchContext) Map(java.util.Map) Session(org.wildfly.clustering.web.session.Session) OOBSession(org.wildfly.clustering.web.session.oob.OOBSession) AuthenticatedSession(io.undertow.security.api.AuthenticatedSessionManager.AuthenticatedSession)

Aggregations

AuthenticatedSession (io.undertow.security.api.AuthenticatedSessionManager.AuthenticatedSession)1 SessionConfig (io.undertow.server.session.SessionConfig)1 Map (java.util.Map)1 BatchContext (org.wildfly.clustering.ee.BatchContext)1 ImmutableSessionAttributes (org.wildfly.clustering.web.session.ImmutableSessionAttributes)1 Session (org.wildfly.clustering.web.session.Session)1 OOBSession (org.wildfly.clustering.web.session.oob.OOBSession)1