Top Description Fields Constructors Methods
org.eclipse.jetty.session

public Class DefaultSessionCache

extends AbstractSessionCache
Class Inheritance
Annotations
@ManagedObject
Imports
java.util.Objects, java.util.concurrent.ConcurrentHashMap, .ConcurrentMap, java.util.function.Function, org.eclipse.jetty.server.Session, org.eclipse.jetty.util.annotation.ManagedAttribute, .ManagedObject, .ManagedOperation, org.eclipse.jetty.util.statistic.CounterStatistic, org.slf4j.Logger, .LoggerFactory

DefaultSessionCache A session store that keeps its sessions in memory within a concurrent map

Field Summary

Modifier and TypeField and Description
private final ConcurrentMap<String, ManagedSession>
_sessions

The cache of sessions in a concurrent map

private final CounterStatistic
private static final Logger
Inherited from org.eclipse.jetty.session.AbstractSessionCache:
_context_evictionPolicy_flushOnResponseCommit_invalidateOnShutdown_manager_removeUnloadableSessions_saveOnCreate_saveOnInactiveEviction_sessionDataStore

Constructor Summary

AccessConstructor and Description
public
DefaultSessionCache(SessionManager
The SessionHandler related to this SessionCache
manager
)

public
DefaultSessionCache(SessionManager
The SessionHandler related to this SessionCache
manager
,
ConcurrentMap<String, ManagedSession>
The session map implementation to use
sessions
)

Method Summary

Modifier and TypeMethod and Description
protected ManagedSession
doComputeIfAbsent(String
the session id
id
,
Function<String, ManagedSession>
the function to load the data for the session
mappingFunction
)

Implements abstract org.eclipse.jetty.session.AbstractSessionCache.doComputeIfAbsent.

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.

public ManagedSession
doDelete(String
the id
id
)

Implements abstract org.eclipse.jetty.session.AbstractSessionCache.doDelete.

Remove the session with this identity from the store

public ManagedSession
doGet(String
session id
id
)

Implements abstract org.eclipse.jetty.session.AbstractSessionCache.doGet.

Get the session matching the key from the cache.

public Session
doPutIfAbsent(String
the identity of the session
id
,
ManagedSession
the session object
session
)

Implements abstract org.eclipse.jetty.session.AbstractSessionCache.doPutIfAbsent.

Put the session into the map if it wasn't already there

public boolean
doReplace(String
the id
id
,
ManagedSession
the old value
oldValue
,
ManagedSession
the new value
newValue
)

Implements abstract org.eclipse.jetty.session.AbstractSessionCache.doReplace.

Replace the mapping from id to oldValue with newValue

public long
getSessionsCurrent()

Returns: the number of sessions in the cache

public long
getSessionsMax()

Returns: the max number of sessions in the cache

public long
getSessionsTotal()

Returns: a running total of sessions in the cache

public ManagedSession
newSession(SessionData
the session data
data
)

Implements abstract org.eclipse.jetty.session.AbstractSessionCache.newSession.

Implements org.eclipse.jetty.session.SessionCache.newSession.

Create a new Session object from pre-existing session data

public void
public void
Inherited from org.eclipse.jetty.session.AbstractSessionCache:
addcheckExpirationcheckInactiveSessioncommitcontainsdeletedoStartdoStopexistsgetgetAndEntergetEvictionPolicygetSessionDataStoregetSessionManagerinitializeisFlushOnResponseCommitisInvalidateOnShutdownisRemoveUnloadableSessionsisSaveOnCreateisSaveOnInactiveEvictionnewSessionreleaserenewSessionIdrenewSessionIdsetEvictionPolicysetFlushOnResponseCommitsetInvalidateOnShutdownsetRemoveUnloadableSessionssetSaveOnCreatesetSaveOnInactiveEvictionsetSessionDataStoretoString

Field Detail

_sessionsback to summary
private final ConcurrentMap<String, ManagedSession> _sessions

The cache of sessions in a concurrent map

_statsback to summary
private final CounterStatistic _stats
LOGback to summary
private static final Logger LOG

Hides org.eclipse.jetty.session.AbstractSessionCache.LOG.

Constructor Detail

DefaultSessionCacheback to summary
public DefaultSessionCache(SessionManager manager)
Parameters
manager:SessionManager

The SessionHandler related to this SessionCache

DefaultSessionCacheback to summary
public DefaultSessionCache(SessionManager manager, ConcurrentMap<String, ManagedSession> sessions)
Parameters
manager:SessionManager

The SessionHandler related to this SessionCache

sessions:ConcurrentMap<String, ManagedSession>

The session map implementation to use

Method Detail

doComputeIfAbsentback to summary
protected ManagedSession doComputeIfAbsent(String id, Function<String, ManagedSession> mappingFunction)

Implements abstract org.eclipse.jetty.session.AbstractSessionCache.doComputeIfAbsent.

Doc from org.eclipse.jetty.session.AbstractSessionCache.doComputeIfAbsent.

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. This method is expected to have precisely the same behaviour as java.util.concurrent.ConcurrentHashMap#computeIfAbsent

Parameters
id:String

the session id

mappingFunction:Function<String, ManagedSession>

the function to load the data for the session

Returns:ManagedSession

an existing Session from the cache

Annotations
@Override
doDeleteback to summary
public ManagedSession doDelete(String id)

Implements abstract org.eclipse.jetty.session.AbstractSessionCache.doDelete.

Doc from org.eclipse.jetty.session.AbstractSessionCache.doDelete.

Remove the session with this identity from the store

Parameters
id:String

the id

Returns:ManagedSession

Session that was removed or null

Annotations
@Override
doGetback to summary
public ManagedSession doGet(String id)

Implements abstract org.eclipse.jetty.session.AbstractSessionCache.doGet.

Doc from org.eclipse.jetty.session.AbstractSessionCache.doGet.

Get the session matching the key from the cache. Does not load the session.

Parameters
id:String

session id

Returns:ManagedSession

the Session object matching the id

Annotations
@Override
doPutIfAbsentback to summary
public Session doPutIfAbsent(String id, ManagedSession session)

Implements abstract org.eclipse.jetty.session.AbstractSessionCache.doPutIfAbsent.

Doc from org.eclipse.jetty.session.AbstractSessionCache.doPutIfAbsent.

Put the session into the map if it wasn't already there

Parameters
id:String

the identity of the session

session:ManagedSession

the session object

Returns:Session

null if the session wasn't already in the map, or the existing entry otherwise

Annotations
@Override
doReplaceback to summary
public boolean doReplace(String id, ManagedSession oldValue, ManagedSession newValue)

Implements abstract org.eclipse.jetty.session.AbstractSessionCache.doReplace.

Doc from org.eclipse.jetty.session.AbstractSessionCache.doReplace.

Replace the mapping from id to oldValue with newValue

Parameters
id:String

the id

oldValue:ManagedSession

the old value

newValue:ManagedSession

the new value

Returns:boolean

true if replacement was done

Annotations
@Override
getSessionsCurrentback to summary
public long getSessionsCurrent()
Returns:long

the number of sessions in the cache

Annotations
@ManagedAttribute:current sessions in cache
readonly:true
getSessionsMaxback to summary
public long getSessionsMax()
Returns:long

the max number of sessions in the cache

Annotations
@ManagedAttribute:max sessions in cache
readonly:true
getSessionsTotalback to summary
public long getSessionsTotal()
Returns:long

a running total of sessions in the cache

Annotations
@ManagedAttribute:total sessions in cache
readonly:true
newSessionback to summary
public ManagedSession newSession(SessionData data)

Implements abstract org.eclipse.jetty.session.AbstractSessionCache.newSession.

Implements org.eclipse.jetty.session.SessionCache.newSession.

Doc from org.eclipse.jetty.session.AbstractSessionCache.newSession.

Create a new Session object from pre-existing session data

Parameters
data:SessionData

the session data

Returns:ManagedSession

a new Session object

Annotations
@Override
resetStatsback to summary
public void resetStats()
Annotations
@ManagedOperation:reset statistics
impact:ACTION
shutdownback to summary
public void shutdown()

Implements org.eclipse.jetty.session.SessionCache.shutdown.

Annotations
@Override