@ManagedObject public abstract class AbstractSessionCache extends 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.AbstractLifeCycle.AbstractLifeCycleListenerLifeCycle.ListenerContainer.InheritedListener, Container.ListenerFAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPINGEVICT_ON_INACTIVITY, EVICT_ON_SESSION_EXIT, NEVER_EVICT| Constructor and Description |
|---|
AbstractSessionCache(SessionHandler handler) |
| Modifier and Type | Method and Description |
|---|---|
void |
add(String id,
Session session)
Add an entirely new session (created by the application calling Request.getSession(true))
to the cache.
|
Set<String> |
checkExpiration(Set<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.
|
void |
commit(Session session)
A response that has accessed this session is about to
be returned to the client.
|
boolean |
contains(String id)
Check to see if this cache contains an entry for the session
corresponding to the session id.
|
Session |
delete(String id)
Remove a session object from this store and from any backing store.
|
abstract Session |
doDelete(String id)
Remove the session with this identity from the store
|
boolean |
exists(String id)
Check to see if a session corresponding to the id exists.
|
Session |
get(String id)
Get a session object.
|
int |
getEvictionPolicy() |
SessionDataStore |
getSessionDataStore() |
SessionHandler |
getSessionHandler() |
void |
initialize(SessionContext context) |
boolean |
isFlushOnResponseCommit() |
boolean |
isRemoveUnloadableSessions() |
boolean |
isSaveOnCreate() |
boolean |
isSaveOnInactiveEviction()
Whether we should save a session that has been inactive before
we boot it from the cache.
|
abstract Session |
newSession(HttpServletRequest request,
SessionData data)
Create a new Session for a request.
|
Session |
newSession(HttpServletRequest request,
String id,
long time,
long maxInactiveMs)
Create an entirely new Session.
|
abstract Session |
newSession(SessionData data)
Create a new Session object from pre-existing session data
|
void |
put(String id,
Session session)
Deprecated.
use
release(String, Session) instead |
void |
release(String id,
Session session)
Finish using the Session object.
|
Session |
renewSessionId(String oldId,
String newId,
String oldExtendedId,
String newExtendedId)
Change the id of a Session.
|
void |
setEvictionPolicy(int evictionTimeout)
-1 means we never evict inactive sessions.
|
void |
setFlushOnResponseCommit(boolean flushOnResponseCommit)
If true, a dirty session will be written to the SessionDataStore
just before a response is returned to the client.
|
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.
|
String |
toString() |
addBean, addBean, addEventListener, addManaged, contains, destroy, dump, dump, dump, dump, dump, dumpObject, dumpStdErr, getBean, getBeans, getBeans, getContainedBeans, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, removeEventListener, setBeans, setStopTimeout, unmanage, updateBean, updateBean, updateBeansaddLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stopequals, getClass, hashCode, notify, notifyAll, wait, wait, waitrenewSessionId, shutdownaddLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, start, stop, stopdumpContainer, dumpIterable, dumpMapEntries, dumpObjects, dumpSelf, namedpublic 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 doDelete(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)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 void setFlushOnResponseCommit(boolean flushOnResponseCommit)
SessionCachesetFlushOnResponseCommit in interface SessionCachepublic boolean isFlushOnResponseCommit()
isFlushOnResponseCommit in interface SessionCachetrue if dirty sessions should be written
before the response is committed.public Session get(String id) throws Exception
get in interface SessionCacheid - the session idException - if any error occurredSessionCache.get(java.lang.String)public void add(String id, Session session) throws Exception
add in interface SessionCacheid - the idsession - Exceptionpublic void commit(Session session) throws Exception
commit in interface SessionCacheException@Deprecated public void put(String id, Session session) throws Exception
release(String, Session) insteadSessionCacheput in interface SessionCacheid - the session idsession - the current session objectException - if any error occurredpublic void release(String id, Session session) throws Exception
release in interface SessionCacheid - the session idsession - the current session objectException - if any error occurredSessionCache.release(java.lang.String, org.eclipse.jetty.server.session.Session)public boolean exists(String id) throws Exception
exists in interface SessionCacheid - the session idException - the ExceptionSessionCache.exists(java.lang.String)public boolean contains(String id) throws Exception
contains in interface SessionCacheid - the session idException - if any error occurredSessionCache.contains(java.lang.String)public Session delete(String id) throws Exception
delete in interface SessionCacheid - the session idException - if any error occurredSessionCache.delete(java.lang.String)public Set<String> checkExpiration(Set<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(String oldId, String newId, String oldExtendedId, String newExtendedId) throws Exception
SessionCacherenewSessionId in interface SessionCacheoldId - the current session idnewId - the new session idoldExtendedId - the current extended session idnewExtendedId - the new extended session idException - if any error occurredpublic 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, 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 String toString()
toString in class AbstractLifeCycleCopyright © 2010 - 2020 Adobe. All Rights Reserved