Class DefaultSessionCache
java.lang.Object
org.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.util.component.ContainerLifeCycle
org.eclipse.jetty.session.AbstractSessionCache
org.eclipse.jetty.session.DefaultSessionCache
- All Implemented Interfaces:
SessionCache, Container, Destroyable, Dumpable, Dumpable.DumpableContainer, LifeCycle
DefaultSessionCache
A session store that keeps its sessions in memory within a concurrent map
-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListener, AbstractLifeCycle.StopExceptionNested classes/interfaces inherited from interface Container
Container.InheritedListener, Container.ListenerNested classes/interfaces inherited from interface Dumpable
Dumpable.DumpableContainerNested classes/interfaces inherited from interface LifeCycle
LifeCycle.Listener -
Field Summary
Fields inherited from class AbstractSessionCache
_context, _evictionPolicy, _flushOnResponseCommit, _invalidateOnShutdown, _manager, _removeUnloadableSessions, _saveOnCreate, _saveOnInactiveEviction, _sessionDataStoreFields inherited from interface SessionCache
EVICT_ON_INACTIVITY, EVICT_ON_SESSION_EXIT, NEVER_EVICT -
Constructor Summary
ConstructorsConstructorDescriptionDefaultSessionCache(SessionManager manager) DefaultSessionCache(SessionManager manager, ConcurrentMap<String, ManagedSession> sessions) -
Method Summary
Modifier and TypeMethodDescriptionprotected ManagedSessiondoComputeIfAbsent(String id, Function<String, ManagedSession> mappingFunction) Compute the mappingFunction to create a Session object iff the session with the given id isn't already in the map, otherwise return the existing Session.Remove the session with this identity from the storeGet the session matching the key from the cache.doPutIfAbsent(String id, ManagedSession session) Put the session into the map if it wasn't already therebooleandoReplace(String id, ManagedSession oldValue, ManagedSession newValue) Replace the mapping from id to oldValue with newValuelonglonglongnewSession(SessionData data) Create a new Session object from pre-existing session datavoidvoidshutdown()Methods inherited from class AbstractSessionCache
add, checkExpiration, checkInactiveSession, commit, contains, delete, doStart, doStop, exists, get, getAndEnter, getEvictionPolicy, getSessionDataStore, getSessionManager, initialize, isFlushOnResponseCommit, isInvalidateOnShutdown, isRemoveUnloadableSessions, isSaveOnCreate, isSaveOnInactiveEviction, newSession, release, renewSessionId, renewSessionId, setEvictionPolicy, setFlushOnResponseCommit, setInvalidateOnShutdown, setRemoveUnloadableSessions, setSaveOnCreate, setSaveOnInactiveEviction, setSessionDataStore, toStringMethods inherited from class ContainerLifeCycle
addBean, addBean, addEventListener, addManaged, contains, destroy, dump, dump, dump, dumpObjects, dumpStdErr, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, installBean, installBean, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, removeEventListener, setBeans, start, stop, unmanage, updateBean, updateBean, updateBeans, updateBeansMethods inherited from class AbstractLifeCycle
getEventListeners, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, setEventListeners, start, stopMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Container
getCachedBeans, getEventListenersMethods inherited from interface Dumpable.DumpableContainer
isDumpableMethods inherited from interface LifeCycle
addEventListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeEventListener, start, stop
-
Constructor Details
-
DefaultSessionCache
- Parameters:
manager- The SessionHandler related to this SessionCache
-
DefaultSessionCache
- Parameters:
manager- The SessionHandler related to this SessionCachesessions- The session map implementation to use
-
-
Method Details
-
getSessionsCurrent
@ManagedAttribute(value="current sessions in cache", readonly=true) public long getSessionsCurrent()- Returns:
- the number of sessions in the cache
-
getSessionsMax
- Returns:
- the max number of sessions in the cache
-
getSessionsTotal
- Returns:
- a running total of sessions in the cache
-
resetStats
-
doGet
Description copied from class:AbstractSessionCacheGet the session matching the key from the cache. Does not load the session.- Specified by:
doGetin classAbstractSessionCache- Parameters:
id- session id- Returns:
- the Session object matching the id
-
doPutIfAbsent
Description copied from class:AbstractSessionCachePut the session into the map if it wasn't already there- Specified by:
doPutIfAbsentin classAbstractSessionCache- Parameters:
id- the identity of the sessionsession- the session object- Returns:
- null if the session wasn't already in the map, or the existing entry otherwise
-
doComputeIfAbsent
protected ManagedSession doComputeIfAbsent(String id, Function<String, ManagedSession> mappingFunction) Description copied from class:AbstractSessionCacheCompute the mappingFunction to create a Session object iff the session with the given id isn't already in the map, otherwise return the existing Session. This method is expected to have precisely the same behaviour asConcurrentHashMap.computeIfAbsent(K, Function)- Specified by:
doComputeIfAbsentin classAbstractSessionCache- Parameters:
id- the session idmappingFunction- the function to load the data for the session- Returns:
- an existing Session from the cache
-
doDelete
Description copied from class:AbstractSessionCacheRemove the session with this identity from the store- Specified by:
doDeletein classAbstractSessionCache- Parameters:
id- the id- Returns:
- Session that was removed or null
-
shutdown
public void shutdown() -
newSession
Description copied from class:AbstractSessionCacheCreate a new Session object from pre-existing session data- Specified by:
newSessionin interfaceSessionCache- Specified by:
newSessionin classAbstractSessionCache- Parameters:
data- the session data- Returns:
- a new Session object
-
doReplace
Description copied from class:AbstractSessionCacheReplace the mapping from id to oldValue with newValue- Specified by:
doReplacein classAbstractSessionCache- Parameters:
id- the idoldValue- the old valuenewValue- the new value- Returns:
- true if replacement was done
-