SessionCache, org.eclipse.jetty.util.component.LifeCycleDefaultSessionCache, NullSessionCache@ManagedObject public abstract class AbstractSessionCache extends org.eclipse.jetty.util.component.ContainerLifeCycle implements SessionCache
SessionCache interface for managing a set of
Session objects pertaining to a context in memory.
This implementation ensures that multiple requests for the same session id
always return the same Session object.
It will delay writing out a session to the SessionDataStore until the
last request exits the session. If the SessionDataStore supports passivation
then the session passivation and activation listeners are called appropriately as
the session is written.
This implementation also supports evicting idle Session objects. An idle Session
is one that is still valid, has not expired, but has not been accessed by a
request for a configurable amount of time. An idle session will be first
passivated before it is evicted from the cache.| Modifier and Type | Class | Description |
|---|---|---|
protected class |
AbstractSessionCache.PlaceHolderSession |
PlaceHolder
|
org.eclipse.jetty.util.component.AbstractLifeCycle.AbstractLifeCycleListener| Modifier and Type | Field | Description |
|---|---|---|
protected SessionContext |
_context |
Information about the context to which this SessionCache pertains
|
protected int |
_evictionPolicy |
When, if ever, to evict sessions: never; only when the last request for them finishes; after inactivity time (expressed as secs)
|
protected SessionHandler |
_handler |
The SessionHandler related to this SessionCache
|
protected boolean |
_removeUnloadableSessions |
If true, a Session whose data cannot be read will be
deleted from the SessionDataStore.
|
protected boolean |
_saveOnCreate |
If true, as soon as a new session is created, it will be persisted to the SessionDataStore
|
protected boolean |
_saveOnInactiveEviction |
If true, a session that will be evicted from the cache because it has been
inactive too long will be saved before being evicted.
|
protected SessionDataStore |
_sessionDataStore |
The authoritative source of session data
|
FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPINGEVICT_ON_INACTIVITY, EVICT_ON_SESSION_EXIT, NEVER_EVICT| Constructor | Description |
|---|---|
AbstractSessionCache(SessionHandler handler) |
| Modifier and Type | Method | Description |
|---|---|---|
java.util.Set<java.lang.String> |
checkExpiration(java.util.Set<java.lang.String> candidates) |
Check a list of session ids that belong to potentially expired
sessions.
|
void |
checkInactiveSession(Session session) |
Check a session for being inactive and
thus being able to be evicted, if eviction
is enabled.
|
boolean |
contains(java.lang.String id) |
Check to see if this cache contains an entry for the session
corresponding to the session id.
|
Session |
delete(java.lang.String id) |
Remove a session object from this store and from any backing store.
|
abstract Session |
doDelete(java.lang.String id) |
Remove the session with this identity from the store
|
abstract Session |
doGet(java.lang.String id) |
Get the session matching the key
|
abstract Session |
doPutIfAbsent(java.lang.String id,
Session session) |
Put the session into the map if it wasn't already there
|
abstract boolean |
doReplace(java.lang.String id,
Session oldValue,
Session newValue) |
Replace the mapping from id to oldValue with newValue
|
protected void |
doStart() |
|
protected void |
doStop() |
|
boolean |
exists(java.lang.String id) |
Check to see if a session corresponding to the id exists.
|
Session |
get(java.lang.String id) |
Get a session object.
|
int |
getEvictionPolicy() |
|
SessionDataStore |
getSessionDataStore() |
|
SessionHandler |
getSessionHandler() |
|
void |
initialize(SessionContext context) |
|
boolean |
isRemoveUnloadableSessions() |
|
boolean |
isSaveOnCreate() |
|
boolean |
isSaveOnInactiveEviction() |
Whether we should save a session that has been inactive before
we boot it from the cache.
|
Session |
newSession(HttpServletRequest request,
java.lang.String id,
long time,
long maxInactiveMs) |
Create an entirely new Session.
|
abstract Session |
newSession(HttpServletRequest request,
SessionData data) |
Create a new Session for a request.
|
abstract Session |
newSession(SessionData data) |
Create a new Session object from pre-existing session data
|
void |
put(java.lang.String id,
Session session) |
Put the Session object back into the session store.
|
Session |
renewSessionId(java.lang.String oldId,
java.lang.String newId) |
Change the id of a Session.
|
void |
setEvictionPolicy(int evictionTimeout) |
-1 means we never evict inactive sessions.
|
void |
setRemoveUnloadableSessions(boolean removeUnloadableSessions) |
If a session's data cannot be loaded from the store without error, remove
it from the persistent store.
|
void |
setSaveOnCreate(boolean saveOnCreate) |
Whether or not a session that is newly created should be
immediately saved.
|
void |
setSaveOnInactiveEviction(boolean saveOnEvict) |
Whether or not a a session that is about to be evicted should
be saved before being evicted.
|
void |
setSessionDataStore(SessionDataStore sessionStore) |
A SessionDataStore that is the authoritative source
of session information.
|
java.lang.String |
toString() |
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stopaddBean, addBean, addBean, addEventListener, addManaged, contains, destroy, dump, dump, dump, dump, dump, dumpBeans, dumpObject, dumpStdErr, dumpThis, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, isManaged, manage, removeBean, removeBeans, removeEventListener, setBeans, setStopTimeout, start, stop, unmanage, updateBean, updateBean, updateBeansaddLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, start, stop, stopclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitshutdownprotected SessionDataStore _sessionDataStore
protected final SessionHandler _handler
protected SessionContext _context
protected int _evictionPolicy
protected boolean _saveOnCreate
protected boolean _saveOnInactiveEviction
protected boolean _removeUnloadableSessions
public AbstractSessionCache(SessionHandler handler)
handler - the SessionHandler to usepublic abstract Session newSession(SessionData data)
newSession in interface SessionCachedata - the session datapublic abstract Session newSession(HttpServletRequest request, SessionData data)
request - the requestdata - the session datapublic abstract Session doGet(java.lang.String id)
id - session idpublic abstract Session doPutIfAbsent(java.lang.String id, Session session)
id - the identity of the sessionsession - the session objectpublic abstract boolean doReplace(java.lang.String id,
Session oldValue,
Session newValue)
id - the idoldValue - the old valuenewValue - the new valuepublic abstract Session doDelete(java.lang.String id)
id - the idpublic SessionHandler getSessionHandler()
getSessionHandler in interface SessionCachepublic void initialize(SessionContext context)
initialize in interface SessionCachecontext - the SessionContext to use for this cacheSessionCache.initialize(org.eclipse.jetty.server.session.SessionContext)protected void doStart()
throws java.lang.Exception
doStart in class org.eclipse.jetty.util.component.ContainerLifeCyclejava.lang.ExceptionAbstractLifeCycle.doStart()protected void doStop()
throws java.lang.Exception
doStop in class org.eclipse.jetty.util.component.ContainerLifeCyclejava.lang.ExceptionAbstractLifeCycle.doStop()public SessionDataStore getSessionDataStore()
getSessionDataStore in interface SessionCachepublic void setSessionDataStore(SessionDataStore sessionStore)
SessionCachesetSessionDataStore in interface SessionCachesessionStore - the SessionDataStore to useSessionCache.setSessionDataStore(org.eclipse.jetty.server.session.SessionDataStore)@ManagedAttribute(value="session eviction policy",
readonly=true)
public int getEvictionPolicy()
getEvictionPolicy in interface SessionCacheSessionCache.getEvictionPolicy()public void setEvictionPolicy(int evictionTimeout)
setEvictionPolicy in interface SessionCacheevictionTimeout - -1 is never evict; 0 is evict-on-exit; and any other positive
value is the time in seconds that a session can be idle before it can
be evicted.SessionCache.setEvictionPolicy(int)@ManagedAttribute(value="immediately save new sessions",
readonly=true)
public boolean isSaveOnCreate()
isSaveOnCreate in interface SessionCachetrue the newly created session will be saved immediatelypublic void setSaveOnCreate(boolean saveOnCreate)
SessionCachesetSaveOnCreate in interface SessionCachesaveOnCreate - true to immediately save the newly created session@ManagedAttribute(value="delete unreadable stored sessions",
readonly=true)
public boolean isRemoveUnloadableSessions()
isRemoveUnloadableSessions in interface SessionCachepublic void setRemoveUnloadableSessions(boolean removeUnloadableSessions)
setRemoveUnloadableSessions in interface SessionCacheremoveUnloadableSessions - if true unloadable sessions will be removed from session storepublic Session get(java.lang.String id) throws java.lang.Exception
get in interface SessionCacheid - the session idjava.lang.Exception - if any error occurredSessionCache.get(java.lang.String)public void put(java.lang.String id,
Session session)
throws java.lang.Exception
put in interface SessionCacheid - the session idsession - the current session objectjava.lang.Exception - if any error occurredSessionCache.put(java.lang.String, org.eclipse.jetty.server.session.Session)public boolean exists(java.lang.String id)
throws java.lang.Exception
exists in interface SessionCacheid - the session idjava.lang.Exception - the ExceptionSessionCache.exists(java.lang.String)public boolean contains(java.lang.String id)
throws java.lang.Exception
contains in interface SessionCacheid - the session idjava.lang.Exception - if any error occurredSessionCache.contains(java.lang.String)public Session delete(java.lang.String id) throws java.lang.Exception
delete in interface SessionCacheid - the session idjava.lang.Exception - if any error occurredSessionCache.delete(java.lang.String)public java.util.Set<java.lang.String> checkExpiration(java.util.Set<java.lang.String> candidates)
SessionCachecheckExpiration in interface SessionCachecandidates - the session ids to checkSessionCache.checkExpiration(Set)public void checkInactiveSession(Session session)
checkInactiveSession in interface SessionCachesession - session to checkpublic Session renewSessionId(java.lang.String oldId, java.lang.String newId) throws java.lang.Exception
SessionCacherenewSessionId in interface SessionCacheoldId - the current session idnewId - the new session idjava.lang.Exception - if any error occurredSessionCache.renewSessionId(java.lang.String, java.lang.String)public void setSaveOnInactiveEviction(boolean saveOnEvict)
SessionCachesetSaveOnInactiveEviction in interface SessionCachesaveOnEvict - true if the session should be saved before being evictedSessionCache.setSaveOnInactiveEviction(boolean)@ManagedAttribute(value="save sessions before evicting from cache",
readonly=true)
public boolean isSaveOnInactiveEviction()
isSaveOnInactiveEviction in interface SessionCachepublic Session newSession(HttpServletRequest request, java.lang.String id, long time, long maxInactiveMs)
SessionCachenewSession in interface SessionCacherequest - the requestid - the unique id associated to the sessiontime - the timestamp of the session creationmaxInactiveMs - the max inactive time in millisecondsSessionCache.newSession(javax.servlet.http.HttpServletRequest, java.lang.String, long, long)public java.lang.String toString()
toString in class org.eclipse.jetty.util.component.AbstractLifeCycleCopyright © 1995–2018 Webtide. All rights reserved.