Package org.eclipse.jetty.server.session
Interface SessionCache
-
- All Superinterfaces:
LifeCycle
- All Known Implementing Classes:
AbstractSessionCache
,DefaultSessionCache
,NullSessionCache
@Deprecated(since="2021-05-27") public interface SessionCache extends LifeCycle
Deprecated.The Eclipse Jetty and Apache Felix Http Jetty packages are no longer supported.SessionCache A working set ofSession
objects for a context. Ideally, multiple requests for the same session id in the same context will always share the same Session object from the SessionCache, but it would be possible for implementations of SessionCache to create a fresh object for each request. The SessionData pertaining to the Session objects is obtained from/written to a SessionDataStore. The SessionDataStore is the authoritative source of session data:- if the session data is not present in the SessionDataStore the session does not exist.
- if the session data is present in the SessionDataStore but its expiry time has passed then the session is deemed to have expired and is therefore invalid
- whenever the last request exits a Session
- whenever the Session has not been accessed for a configurable number of seconds
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
LifeCycle.Listener
-
-
Field Summary
Fields Modifier and Type Field Description static int
EVICT_ON_INACTIVITY
Deprecated.static int
EVICT_ON_SESSION_EXIT
Deprecated.static int
NEVER_EVICT
Deprecated.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description void
add(java.lang.String id, Session session)
Deprecated.Adds a new Session, with a never-before-used id, to the cache.java.util.Set<java.lang.String>
checkExpiration(java.util.Set<java.lang.String> candidates)
Deprecated.Check a list of session ids that belong to potentially expired sessions.void
checkInactiveSession(Session session)
Deprecated.Check a Session to see if it might be appropriate to evict or expire.void
commit(Session session)
Deprecated.Called when a response is about to be committed.boolean
contains(java.lang.String id)
Deprecated.Check to see if a Session is in the cache.Session
delete(java.lang.String id)
Deprecated.Remove a Session completely: from both this cache and the SessionDataStore.boolean
exists(java.lang.String id)
Deprecated.Check to see if a session exists: WILL consult the SessionDataStore.Session
get(java.lang.String id)
Deprecated.Get an existing Session.int
getEvictionPolicy()
Deprecated.SessionDataStore
getSessionDataStore()
Deprecated.SessionHandler
getSessionHandler()
Deprecated.void
initialize(SessionContext context)
Deprecated.boolean
isFlushOnResponseCommit()
Deprecated.boolean
isInvalidateOnShutdown()
Deprecated.boolean
isRemoveUnloadableSessions()
Deprecated.boolean
isSaveOnCreate()
Deprecated.boolean
isSaveOnInactiveEviction()
Deprecated.Session
newSession(HttpServletRequest request, java.lang.String id, long time, long maxInactiveMs)
Deprecated.Create an entirely new Session.Session
newSession(SessionData data)
Deprecated.Re-materialize a Session that has previously existed.void
put(java.lang.String id, Session session)
Deprecated.void
release(java.lang.String id, Session session)
Deprecated.Finish using a Session.default Session
renewSessionId(java.lang.String oldId, java.lang.String newId)
default Session
renewSessionId(java.lang.String oldId, java.lang.String newId, java.lang.String oldExtendedId, java.lang.String newExtendedId)
Deprecated.Change the id of a Session.void
setEvictionPolicy(int policy)
Deprecated.Sessions in this cache can be: never evicted evicted once the last request exits evicted after a configurable period of inactivityvoid
setFlushOnResponseCommit(boolean flushOnResponse)
Deprecated.If true, a dirty session will be written to the SessionDataStore just before a response is returned to the client.void
setInvalidateOnShutdown(boolean invalidateOnShutdown)
Deprecated.If true, all existing sessions in the cache will be invalidated when the server shuts down.void
setRemoveUnloadableSessions(boolean removeUnloadableSessions)
Deprecated.If the data for a session exists but is unreadable, the SessionCache can instruct the SessionDataStore to delete it.void
setSaveOnCreate(boolean saveOnCreate)
Deprecated.Whether or not a session that is newly created should be immediately saved.void
setSaveOnInactiveEviction(boolean saveOnEvict)
Deprecated.Whether or not a a session that is about to be evicted should be saved before being evicted.void
setSessionDataStore(SessionDataStore sds)
Deprecated.A SessionDataStore that is the authoritative source of session information.void
shutdown()
Deprecated.-
Methods inherited from interface org.eclipse.jetty.util.component.LifeCycle
addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
-
-
-
-
Field Detail
-
NEVER_EVICT
static final int NEVER_EVICT
Deprecated.- See Also:
- Constant Field Values
-
EVICT_ON_SESSION_EXIT
static final int EVICT_ON_SESSION_EXIT
Deprecated.- See Also:
- Constant Field Values
-
EVICT_ON_INACTIVITY
static final int EVICT_ON_INACTIVITY
Deprecated.- See Also:
- Constant Field Values
-
-
Method Detail
-
initialize
void initialize(SessionContext context)
Deprecated.- Parameters:
context
- theSessionContext
to use for this cache
-
shutdown
void shutdown()
Deprecated.
-
getSessionHandler
SessionHandler getSessionHandler()
Deprecated.
-
newSession
Session newSession(HttpServletRequest request, java.lang.String id, long time, long maxInactiveMs)
Deprecated.Create an entirely new Session.- 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
-
newSession
Session newSession(SessionData data)
Deprecated.Re-materialize a Session that has previously existed.- Parameters:
data
- the data associated with the session- Returns:
- a Session object for the data supplied
-
renewSessionId
@Deprecated default Session renewSessionId(java.lang.String oldId, java.lang.String newId) throws java.lang.Exception
Deprecated.Change the id of a session. This method has been superceded by the 4 arg renewSessionId method and should no longer be called.- Parameters:
oldId
- the old idnewId
- the new id- Returns:
- the changed Session
- Throws:
java.lang.Exception
- if anything went wrong
-
renewSessionId
default Session renewSessionId(java.lang.String oldId, java.lang.String newId, java.lang.String oldExtendedId, java.lang.String newExtendedId) throws java.lang.Exception
Deprecated.Change the id of a Session.- 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:
java.lang.Exception
- if any error occurred
-
add
void add(java.lang.String id, Session session) throws java.lang.Exception
Deprecated.Adds a new Session, with a never-before-used id, to the cache.- Parameters:
id
-session
-- Throws:
java.lang.Exception
-
get
Session get(java.lang.String id) throws java.lang.Exception
Deprecated.Get an existing Session. If necessary, the cache will load the data for the session from the configured SessionDataStore.- Parameters:
id
- the session id- Returns:
- the Session if one exists, null otherwise
- Throws:
java.lang.Exception
- if any error occurred
-
put
void put(java.lang.String id, Session session) throws java.lang.Exception
Deprecated.Finish 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.- Parameters:
id
- the session idsession
- the current session object- Throws:
java.lang.Exception
- if any error occurred- See Also:
release(java.lang.String,org.eclipse.jetty.server.session.Session)
-
release
void release(java.lang.String id, Session session) throws java.lang.Exception
Deprecated.Finish 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.- Parameters:
id
- the session idsession
- the current session object- Throws:
java.lang.Exception
- if any error occurred
-
commit
void commit(Session session) throws java.lang.Exception
Deprecated.Called when a response is about to be committed. The cache can write the session to ensure that the SessionDataStore contains changes to the session that occurred during the lifetime of the request. This can help ensure that if a subsequent request goes to a different server, it will be able to see the session changes via the shared store.- Throws:
java.lang.Exception
-
contains
boolean contains(java.lang.String id) throws java.lang.Exception
Deprecated.Check to see if a Session is in the cache. Does NOT consult the SessionDataStore.- Parameters:
id
- the session id- Returns:
- true if a Session object matching the id is present in the cache, false otherwise
- Throws:
java.lang.Exception
- if any error occurred
-
exists
boolean exists(java.lang.String id) throws java.lang.Exception
Deprecated.Check to see if a session exists: WILL consult the SessionDataStore.- Parameters:
id
- the session id- Returns:
- true if the session exists, false otherwise
- Throws:
java.lang.Exception
- if any error occurred
-
delete
Session delete(java.lang.String id) throws java.lang.Exception
Deprecated.Remove a Session completely: from both this cache and the SessionDataStore.- Parameters:
id
- the session id- Returns:
- the Session that was removed, null otherwise
- Throws:
java.lang.Exception
- if any error occurred
-
checkExpiration
java.util.Set<java.lang.String> checkExpiration(java.util.Set<java.lang.String> candidates)
Deprecated.Check 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.- 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.
-
checkInactiveSession
void checkInactiveSession(Session session)
Deprecated.Check a Session to see if it might be appropriate to evict or expire.- Parameters:
session
- the session to check
-
setSessionDataStore
void setSessionDataStore(SessionDataStore sds)
Deprecated.A SessionDataStore that is the authoritative source of session information.- Parameters:
sds
- theSessionDataStore
to use
-
getSessionDataStore
SessionDataStore getSessionDataStore()
Deprecated.- Returns:
- the
SessionDataStore
used
-
setEvictionPolicy
void setEvictionPolicy(int policy)
Deprecated.Sessions in this cache can be:- never evicted
- evicted once the last request exits
- evicted after a configurable period of inactivity
- Parameters:
policy
- -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.
-
getEvictionPolicy
int getEvictionPolicy()
Deprecated.- Returns:
- the eviction policy
-
setSaveOnInactiveEviction
void setSaveOnInactiveEviction(boolean saveOnEvict)
Deprecated.Whether or not a a session that is about to be evicted should be saved before being evicted.- Parameters:
saveOnEvict
-true
if the session should be saved before being evicted
-
isSaveOnInactiveEviction
boolean isSaveOnInactiveEviction()
Deprecated.- Returns:
true
if the session should be saved before being evicted
-
setSaveOnCreate
void setSaveOnCreate(boolean saveOnCreate)
Deprecated.Whether 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.- Parameters:
saveOnCreate
-true
to immediately save the newly created session
-
isSaveOnCreate
boolean isSaveOnCreate()
Deprecated.- Returns:
- if
true
the newly created session will be saved immediately
-
setRemoveUnloadableSessions
void setRemoveUnloadableSessions(boolean removeUnloadableSessions)
Deprecated.If the data for a session exists but is unreadable, the SessionCache can instruct the SessionDataStore to delete it.- Parameters:
removeUnloadableSessions
-true
to delete session which cannot be loaded
-
isRemoveUnloadableSessions
boolean isRemoveUnloadableSessions()
Deprecated.- Returns:
- if
true
unloadable session will be deleted
-
setFlushOnResponseCommit
void setFlushOnResponseCommit(boolean flushOnResponse)
Deprecated.If 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.
-
isFlushOnResponseCommit
boolean isFlushOnResponseCommit()
Deprecated.- Returns:
true
if dirty sessions should be written before the response is committed.
-
setInvalidateOnShutdown
void setInvalidateOnShutdown(boolean invalidateOnShutdown)
Deprecated.If true, all existing sessions in the cache will be invalidated when the server shuts down. Default is false.- Parameters:
invalidateOnShutdown
-
-
isInvalidateOnShutdown
boolean isInvalidateOnShutdown()
Deprecated.
-
-