SessionCache
, org.eclipse.jetty.util.component.LifeCycle
DefaultSessionCache
, NullSessionCache
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, STOPPING
EVICT_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(javax.servlet.http.HttpServletRequest request,
java.lang.String id,
long time,
long maxInactiveMs) |
Create an entirely new Session.
|
abstract Session |
newSession(javax.servlet.http.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, stop
addBean, addBean, addBean, addEventListener, addManaged, contains, destroy, dump, dump, dump, dump, dump, dumpBeans, dumpObject, dumpStdErr, dumpThis, getBean, getBeans, getBeans, isManaged, manage, removeBean, removeBeans, removeEventListener, setBeans, setStopTimeout, start, stop, unmanage, updateBean, updateBean, updateBeans
addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
shutdown
protected 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)
public abstract Session newSession(SessionData data)
newSession
in interface SessionCache
data
- the session datapublic abstract Session newSession(javax.servlet.http.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 SessionCache
public void initialize(SessionContext context)
initialize
in interface SessionCache
SessionCache.initialize(org.eclipse.jetty.server.session.SessionContext)
protected void doStart() throws java.lang.Exception
doStart
in class org.eclipse.jetty.util.component.ContainerLifeCycle
java.lang.Exception
AbstractLifeCycle.doStart()
protected void doStop() throws java.lang.Exception
doStop
in class org.eclipse.jetty.util.component.ContainerLifeCycle
java.lang.Exception
AbstractLifeCycle.doStop()
public SessionDataStore getSessionDataStore()
getSessionDataStore
in interface SessionCache
public void setSessionDataStore(SessionDataStore sessionStore)
SessionCache
setSessionDataStore
in interface SessionCache
SessionCache.setSessionDataStore(org.eclipse.jetty.server.session.SessionDataStore)
public int getEvictionPolicy()
getEvictionPolicy
in interface SessionCache
SessionCache.getEvictionPolicy()
public void setEvictionPolicy(int evictionTimeout)
setEvictionPolicy
in interface SessionCache
evictionTimeout
- -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)
public boolean isSaveOnCreate()
isSaveOnCreate
in interface SessionCache
public void setSaveOnCreate(boolean saveOnCreate)
SessionCache
setSaveOnCreate
in interface SessionCache
public boolean isRemoveUnloadableSessions()
isRemoveUnloadableSessions
in interface SessionCache
public void setRemoveUnloadableSessions(boolean removeUnloadableSessions)
setRemoveUnloadableSessions
in interface SessionCache
removeUnloadableSessions
- public Session get(java.lang.String id) throws java.lang.Exception
get
in interface SessionCache
java.lang.Exception
SessionCache.get(java.lang.String)
public void put(java.lang.String id, Session session) throws java.lang.Exception
put
in interface SessionCache
java.lang.Exception
SessionCache.put(java.lang.String, org.eclipse.jetty.server.session.Session)
public boolean exists(java.lang.String id) throws java.lang.Exception
exists
in interface SessionCache
java.lang.Exception
- the ExceptionSessionCache.exists(java.lang.String)
public boolean contains(java.lang.String id) throws java.lang.Exception
contains
in interface SessionCache
java.lang.Exception
SessionCache.contains(java.lang.String)
public Session delete(java.lang.String id) throws java.lang.Exception
delete
in interface SessionCache
java.lang.Exception
SessionCache.delete(java.lang.String)
public java.util.Set<java.lang.String> checkExpiration(java.util.Set<java.lang.String> candidates)
SessionCache
checkExpiration
in interface SessionCache
candidates
- the session ids to checkSessionCache.checkExpiration(Set)
public void checkInactiveSession(Session session)
checkInactiveSession
in interface SessionCache
session
- session to checkpublic Session renewSessionId(java.lang.String oldId, java.lang.String newId) throws java.lang.Exception
SessionCache
renewSessionId
in interface SessionCache
java.lang.Exception
SessionCache.renewSessionId(java.lang.String, java.lang.String)
public void setSaveOnInactiveEviction(boolean saveOnEvict)
SessionCache
setSaveOnInactiveEviction
in interface SessionCache
SessionCache.setSaveOnInactiveEviction(boolean)
public boolean isSaveOnInactiveEviction()
isSaveOnInactiveEviction
in interface SessionCache
public Session newSession(javax.servlet.http.HttpServletRequest request, java.lang.String id, long time, long maxInactiveMs)
SessionCache
newSession
in interface SessionCache
SessionCache.newSession(javax.servlet.http.HttpServletRequest, java.lang.String, long, long)
public java.lang.String toString()
toString
in class java.lang.Object
Copyright © 1995–2018 Webtide. All rights reserved.