/** * Extracts the session id from the current request ({@code exchange}). * * @param exchange * @return */ default String retrieveSessionIdFrom(HttpServerExchange exchange ) { return retrieveSessionIdFrom( exchange, () -> createNewSessionId(exchange) ); }
@Override public Session createOrRetrieveSession( HttpServerExchange exchange, SessionIdManager sessionIdManager ) { final String sessionId = sessionIdManager.retrieveSessionIdFrom( exchange ); Session session = getSessionFromCache( sessionId ); if ( session == null ) synchronized ( cache ) { session = tryToCreateAndStoreNewSession(sessionId, exchange, sessionIdManager); } return session; }
@Override public Session createOrRetrieveSession(HttpServerExchange exchange, SessionIdManager sessionIdManager) { final String sessionId = sessionIdManager.retrieveSessionIdFrom( exchange ); Session session = getSessionFromCache( sessionId ); if ( session == null && shouldNotStoreSession( exchange ) ) return new DefaultSession(SESSION_ID); else if ( session == null ) session = getSessionStore().createOrRetrieveSession(exchange, sessionIdManager); return session; }