Package org.eclipse.jetty.server.session
Class AbstractSessionCache
java.lang.Object
org.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.util.component.ContainerLifeCycle
org.eclipse.jetty.server.session.AbstractSessionCache
- All Implemented Interfaces:
SessionCache,Container,Destroyable,Dumpable,Dumpable.DumpableContainer,LifeCycle
- Direct Known Subclasses:
DefaultSessionCache,NullSessionCache
@ManagedObject
@Deprecated(since="2021-05-27")
public abstract class AbstractSessionCache
extends ContainerLifeCycle
implements SessionCache
Deprecated.
The Eclipse Jetty and Apache Felix Http Jetty packages are no longer supported.
AbstractSessionCache
A base implementation of the
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.-
Nested Class Summary
Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListenerNested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container
Container.InheritedListener, Container.ListenerNested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
Dumpable.DumpableContainerNested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
LifeCycle.Listener -
Field Summary
Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPINGFields inherited from interface org.eclipse.jetty.server.session.SessionCache
EVICT_ON_INACTIVITY, EVICT_ON_SESSION_EXIT, NEVER_EVICT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidDeprecated.Add an entirely new session (created by the application calling Request.getSession(true)) to the cache.checkExpiration(Set<String> candidates) Deprecated.Check a list of session ids that belong to potentially expired sessions.voidcheckInactiveSession(Session session) Deprecated.Check a session for being inactive and thus being able to be evicted, if eviction is enabled.voidDeprecated.A response that has accessed this session is about to be returned to the client.booleanDeprecated.Check to see if this cache contains an entry for the session corresponding to the session id.Deprecated.Remove a session object from this store and from any backing store.abstract SessionDeprecated.Remove the session with this identity from the storebooleanDeprecated.Check to see if a session corresponding to the id exists.Deprecated.Get a session object.intDeprecated.Deprecated.Deprecated.voidinitialize(SessionContext context) Deprecated.booleanDeprecated.booleanDeprecated.booleanDeprecated.booleanDeprecated.booleanDeprecated.Whether we should save a session that has been inactive before we boot it from the cache.newSession(HttpServletRequest request, String id, long time, long maxInactiveMs) Deprecated.Create an entirely new Session.abstract SessionnewSession(HttpServletRequest request, SessionData data) Deprecated.Create a new Session for a request.abstract SessionnewSession(SessionData data) Deprecated.Create a new Session object from pre-existing session datavoidDeprecated.userelease(String, Session)insteadvoidDeprecated.Finish using the Session object.renewSessionId(String oldId, String newId, String oldExtendedId, String newExtendedId) Deprecated.Change the id of a Session.voidsetEvictionPolicy(int evictionTimeout) Deprecated.-1 means we never evict inactive sessions.voidsetFlushOnResponseCommit(boolean flushOnResponseCommit) Deprecated.If true, a dirty session will be written to the SessionDataStore just before a response is returned to the client.voidsetInvalidateOnShutdown(boolean invalidateOnShutdown) Deprecated.If true, all existing sessions in the cache will be invalidated when the server shuts down.voidsetRemoveUnloadableSessions(boolean removeUnloadableSessions) Deprecated.If a session's data cannot be loaded from the store without error, remove it from the persistent store.voidsetSaveOnCreate(boolean saveOnCreate) Deprecated.Whether or not a session that is newly created should be immediately saved.voidsetSaveOnInactiveEviction(boolean saveOnEvict) Deprecated.Whether or not a a session that is about to be evicted should be saved before being evicted.voidsetSessionDataStore(SessionDataStore sessionStore) Deprecated.A SessionDataStore that is the authoritative source of session information.toString()Deprecated.Methods inherited from class org.eclipse.jetty.util.component.ContainerLifeCycle
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, updateBeansMethods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stopMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.eclipse.jetty.util.component.Dumpable.DumpableContainer
isDumpableMethods inherited from interface org.eclipse.jetty.util.component.LifeCycle
addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stopMethods inherited from interface org.eclipse.jetty.server.session.SessionCache
renewSessionId, shutdown
-
Constructor Details
-
AbstractSessionCache
Deprecated.- Parameters:
handler- theSessionHandlerto use
-
-
Method Details
-
newSession
Deprecated.Create a new Session object from pre-existing session data- Specified by:
newSessionin interfaceSessionCache- Parameters:
data- the session data- Returns:
- a new Session object
-
newSession
Deprecated.Create a new Session for a request.- Parameters:
request- the requestdata- the session data- Returns:
- the new session
-
doDelete
Deprecated.Remove the session with this identity from the store- Parameters:
id- the id- Returns:
- Session that was removed or null
-
getSessionHandler
Deprecated.- Specified by:
getSessionHandlerin interfaceSessionCache- Returns:
- the SessionManger
-
initialize
Deprecated.- Specified by:
initializein interfaceSessionCache- Parameters:
context- theSessionContextto use for this cache- See Also:
-
getSessionDataStore
Deprecated.- Specified by:
getSessionDataStorein interfaceSessionCache- Returns:
- the SessionDataStore or null if there isn't one
-
setSessionDataStore
Deprecated.Description copied from interface:SessionCacheA SessionDataStore that is the authoritative source of session information.- Specified by:
setSessionDataStorein interfaceSessionCache- Parameters:
sessionStore- theSessionDataStoreto use- See Also:
-
getEvictionPolicy
Deprecated.- Specified by:
getEvictionPolicyin interfaceSessionCache- Returns:
- the eviction policy
- See Also:
-
setEvictionPolicy
public void setEvictionPolicy(int evictionTimeout) Deprecated.-1 means we never evict inactive sessions. 0 means we evict a session after the last request for it exits >0 is the number of seconds after which we evict inactive sessions from the cache- Specified by:
setEvictionPolicyin interfaceSessionCache- Parameters:
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.- See Also:
-
isSaveOnCreate
@ManagedAttribute(value="immediately save new sessions", readonly=true) public boolean isSaveOnCreate()Deprecated.- Specified by:
isSaveOnCreatein interfaceSessionCache- Returns:
- if
truethe newly created session will be saved immediately
-
setSaveOnCreate
public void setSaveOnCreate(boolean saveOnCreate) Deprecated.Description copied from interface:SessionCacheWhether or not a session that is newly created should be immediately saved. If false, a session that is created and invalidated within a single request is never persisted.- Specified by:
setSaveOnCreatein interfaceSessionCache- Parameters:
saveOnCreate-trueto immediately save the newly created session
-
isRemoveUnloadableSessions
@ManagedAttribute(value="delete unreadable stored sessions", readonly=true) public boolean isRemoveUnloadableSessions()Deprecated.- Specified by:
isRemoveUnloadableSessionsin interfaceSessionCache- Returns:
- true if sessions that can't be loaded are deleted from the store
-
setRemoveUnloadableSessions
public void setRemoveUnloadableSessions(boolean removeUnloadableSessions) Deprecated.If a session's data cannot be loaded from the store without error, remove it from the persistent store.- Specified by:
setRemoveUnloadableSessionsin interfaceSessionCache- Parameters:
removeUnloadableSessions- iftrueunloadable sessions will be removed from session store
-
setFlushOnResponseCommit
public void setFlushOnResponseCommit(boolean flushOnResponseCommit) Deprecated.Description copied from interface:SessionCacheIf true, a dirty session will be written to the SessionDataStore just before a response is returned to the client. This ensures that subsequent requests to either the same node or a different node see the changed session data.- Specified by:
setFlushOnResponseCommitin interfaceSessionCache
-
isFlushOnResponseCommit
public boolean isFlushOnResponseCommit()Deprecated.- Specified by:
isFlushOnResponseCommitin interfaceSessionCache- Returns:
trueif dirty sessions should be written before the response is committed.
-
get
Deprecated.Get a session object. If the session object is not in this session store, try getting the data for it from a SessionDataStore associated with the session manager. The usage count of the session is incremented.- Specified by:
getin interfaceSessionCache- Parameters:
id- the session id- Returns:
- the Session if one exists, null otherwise
- Throws:
Exception- if any error occurred- See Also:
-
add
Deprecated.Add an entirely new session (created by the application calling Request.getSession(true)) to the cache. The usage count of the fresh session is incremented.- Specified by:
addin interfaceSessionCache- Parameters:
id- the idsession-- Throws:
Exception
-
commit
Deprecated.A response that has accessed this session is about to be returned to the client. Pass the session to the store to persist, so that any changes will be visible to subsequent requests on the same node (if using NullSessionCache), or on other nodes.- Specified by:
commitin interfaceSessionCache- Throws:
Exception
-
put
Deprecated.userelease(String, Session)insteadDescription copied from interface:SessionCacheFinish using a Session. This is called by the SessionHandler once a request is finished with a Session. SessionCache implementations may want to delay writing out Session contents until the last request exits a Session.- Specified by:
putin interfaceSessionCache- Parameters:
id- the session idsession- the current session object- Throws:
Exception- if any error occurred
-
release
Deprecated.Finish using the Session object. This should be called when a request exists the session. Only when the last simultaneous request exists the session will any action be taken. If there is a SessionDataStore write the session data through to it. If the SessionDataStore supports passivation, call the passivate/active listeners. If the evictionPolicy == SessionCache.EVICT_ON_SESSION_EXIT then after we have saved the session, we evict it from the cache.- Specified by:
releasein interfaceSessionCache- Parameters:
id- the session idsession- the current session object- Throws:
Exception- if any error occurred- See Also:
-
exists
Deprecated.Check to see if a session corresponding to the id exists. This method will first check with the object store. If it doesn't exist in the object store (might be passivated etc), it will check with the data store.- Specified by:
existsin interfaceSessionCache- Parameters:
id- the session id- Returns:
- true if the session exists, false otherwise
- Throws:
Exception- the Exception- See Also:
-
contains
Deprecated.Check to see if this cache contains an entry for the session corresponding to the session id.- Specified by:
containsin interfaceSessionCache- Parameters:
id- the session id- Returns:
- true if a Session object matching the id is present in the cache, false otherwise
- Throws:
Exception- if any error occurred- See Also:
-
delete
Deprecated.Remove a session object from this store and from any backing store.- Specified by:
deletein interfaceSessionCache- Parameters:
id- the session id- Returns:
- the Session that was removed, null otherwise
- Throws:
Exception- if any error occurred- See Also:
-
checkExpiration
Deprecated.Description copied from interface:SessionCacheCheck a list of session ids that belong to potentially expired sessions. The Session in the cache should be checked, but also the SessionDataStore, as that is the authoritative source of all session information.- Specified by:
checkExpirationin interfaceSessionCache- Parameters:
candidates- the session ids to check- Returns:
- the set of session ids that have actually expired: this can be a superset of the original candidate list.
- See Also:
-
checkInactiveSession
Deprecated.Check a session for being inactive and thus being able to be evicted, if eviction is enabled.- Specified by:
checkInactiveSessionin interfaceSessionCache- Parameters:
session- session to check
-
renewSessionId
public Session renewSessionId(String oldId, String newId, String oldExtendedId, String newExtendedId) throws Exception Deprecated.Description copied from interface:SessionCacheChange the id of a Session.- Specified by:
renewSessionIdin interfaceSessionCache- Parameters:
oldId- the current session idnewId- the new session idoldExtendedId- the current extended session idnewExtendedId- the new extended session id- Returns:
- the Session after changing its id
- Throws:
Exception- if any error occurred
-
setSaveOnInactiveEviction
public void setSaveOnInactiveEviction(boolean saveOnEvict) Deprecated.Description copied from interface:SessionCacheWhether or not a a session that is about to be evicted should be saved before being evicted.- Specified by:
setSaveOnInactiveEvictionin interfaceSessionCache- Parameters:
saveOnEvict-trueif the session should be saved before being evicted- See Also:
-
setInvalidateOnShutdown
public void setInvalidateOnShutdown(boolean invalidateOnShutdown) Deprecated.Description copied from interface:SessionCacheIf true, all existing sessions in the cache will be invalidated when the server shuts down. Default is false.- Specified by:
setInvalidateOnShutdownin interfaceSessionCache- Parameters:
invalidateOnShutdown-
-
isInvalidateOnShutdown
public boolean isInvalidateOnShutdown()Deprecated.- Specified by:
isInvalidateOnShutdownin interfaceSessionCache
-
isSaveOnInactiveEviction
@ManagedAttribute(value="save sessions before evicting from cache", readonly=true) public boolean isSaveOnInactiveEviction()Deprecated.Whether we should save a session that has been inactive before we boot it from the cache.- Specified by:
isSaveOnInactiveEvictionin interfaceSessionCache- Returns:
- true if an inactive session will be saved before being evicted
-
newSession
Deprecated.Description copied from interface:SessionCacheCreate an entirely new Session.- Specified by:
newSessionin interfaceSessionCache- Parameters:
request- the requestid- the unique id associated to the sessiontime- the timestamp of the session creationmaxInactiveMs- the max inactive time in milliseconds- Returns:
- a new Session
- See Also:
-
toString
Deprecated.- Overrides:
toStringin classAbstractLifeCycle
-