public abstract class AbstractSessionCache extends ContainerLifeCycle implements SessionCache
Modifier and Type | Class and Description |
---|---|
protected class |
AbstractSessionCache.PlaceHolderSession
PlaceHolder
|
AbstractLifeCycle.AbstractLifeCycleListener
LifeCycle.Listener
Container.InheritedListener, Container.Listener
Modifier and Type | Field and 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 |
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 and Description |
---|
AbstractSessionCache(SessionHandler handler) |
Modifier and Type | Method and Description |
---|---|
Set<String> |
checkExpiration(Set<String> candidates) |
void |
checkInactiveSession(Session session)
Check a session for being inactive and
thus being able to be evicted, if eviction
is enabled.
|
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
|
abstract Session |
doGet(String id)
Get the session matching the key
|
abstract Session |
doPutIfAbsent(String id,
Session session)
Put the session into the map if it wasn't already there
|
abstract boolean |
doReplace(String id,
Session oldValue,
Session newValue)
Replace the mapping from id to oldValue with newValue
|
protected void |
doStart()
Starts the managed lifecycle beans in the order they were added.
|
protected void |
doStop()
Stops the managed lifecycle beans in the reverse order they were added.
|
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 |
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(javax.servlet.http.HttpServletRequest request,
SessionData data)
Create a new Session for a request.
|
Session |
newSession(javax.servlet.http.HttpServletRequest request,
String id,
long time,
long maxInactiveMs) |
abstract Session |
newSession(SessionData data)
Create a new Session object from pre-existing session data
|
void |
put(String id,
Session session)
Put the Session object back into the session store.
|
Session |
renewSessionId(String oldId,
String newId) |
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) |
void |
setSaveOnInactiveEviction(boolean saveOnEvict) |
void |
setSessionDataStore(SessionDataStore sessionStore) |
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, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
shutdown
addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
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(String id)
id
- session idpublic abstract Session doPutIfAbsent(String id, Session session)
id
- the identity of the sessionsession
- the session objectpublic abstract boolean doReplace(String id, Session oldValue, Session newValue)
id
- the idoldValue
- the old valuenewValue
- the new valuepublic abstract Session doDelete(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 Exception
ContainerLifeCycle
doStart
in class ContainerLifeCycle
Exception
AbstractLifeCycle.doStart()
protected void doStop() throws Exception
ContainerLifeCycle
doStop
in class ContainerLifeCycle
Exception
AbstractLifeCycle.doStop()
public SessionDataStore getSessionDataStore()
getSessionDataStore
in interface SessionCache
public void setSessionDataStore(SessionDataStore sessionStore)
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
SessionCache.setEvictionPolicy(int)
public boolean isSaveOnCreate()
isSaveOnCreate
in interface SessionCache
public void setSaveOnCreate(boolean saveOnCreate)
setSaveOnCreate
in interface SessionCache
public boolean isRemoveUnloadableSessions()
isRemoveUnloadableSessions
in interface SessionCache
public void setRemoveUnloadableSessions(boolean removeUnloadableSessions)
setRemoveUnloadableSessions
in interface SessionCache
removeUnloadableSessions
- public Session get(String id) throws Exception
get
in interface SessionCache
Exception
SessionCache.get(java.lang.String)
public void put(String id, Session session) throws Exception
put
in interface SessionCache
Exception
SessionCache.put(java.lang.String, org.eclipse.jetty.server.session.Session)
public boolean exists(String id) throws Exception
exists
in interface SessionCache
Exception
- the ExceptionSessionCache.exists(java.lang.String)
public boolean contains(String id) throws Exception
contains
in interface SessionCache
Exception
SessionCache.contains(java.lang.String)
public Session delete(String id) throws Exception
delete
in interface SessionCache
Exception
SessionCache.delete(java.lang.String)
public Set<String> checkExpiration(Set<String> candidates)
checkExpiration
in interface SessionCache
SessionCache.checkExpiration(Set)
public void checkInactiveSession(Session session)
checkInactiveSession
in interface SessionCache
session
- session to checkpublic Session renewSessionId(String oldId, String newId) throws Exception
renewSessionId
in interface SessionCache
Exception
SessionCache.renewSessionId(java.lang.String, java.lang.String)
public void setSaveOnInactiveEviction(boolean saveOnEvict)
setSaveOnInactiveEviction
in interface SessionCache
SessionCache.setSaveOnInactiveEviction(boolean)
public boolean isSaveOnInactiveEviction()
isSaveOnInactiveEviction
in interface SessionCache
public Session newSession(javax.servlet.http.HttpServletRequest request, String id, long time, long maxInactiveMs)
newSession
in interface SessionCache
SessionCache.newSession(javax.servlet.http.HttpServletRequest, java.lang.String, long, long)
Copyright © 1995–2016 Mort Bay Consulting. All rights reserved.