Class AbstractSessionDataStore
java.lang.Object
org.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.util.component.ContainerLifeCycle
org.eclipse.jetty.server.session.AbstractSessionDataStore
- All Implemented Interfaces:
SessionDataMap, SessionDataStore, Container, Destroyable, Dumpable, Dumpable.DumpableContainer, LifeCycle
- Direct Known Subclasses:
FileSessionDataStore, JDBCSessionDataStore, NullSessionDataStore
@ManagedObject
public abstract class AbstractSessionDataStore
extends ContainerLifeCycle
implements SessionDataStore
AbstractSessionDataStore
-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListenerNested classes/interfaces inherited from interface Container
Container.InheritedListener, Container.ListenerNested classes/interfaces inherited from interface Dumpable
Dumpable.DumpableContainerNested classes/interfaces inherited from interface LifeCycle
LifeCycle.Listener -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected SessionContextprotected intprotected longprotected int(package private) static final Logger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoGetExpired(Set<String> candidates) Implemented by subclasses to resolve which sessions this node should attempt to expire.abstract SessionDataLoad the session from persistent store.protected voiddoStart()Starts the managed lifecycle beans in the order they were added.abstract voiddoStore(String id, SessionData data, long lastSaveTime) Store the session data persistently.getExpired(Set<String> candidates) Called periodically, this method should search the data store for sessions that have been expired for a 'reasonable' amount of time.intintvoidinitialize(SessionContext context) Initialize this data map for the given context.Read in session data.newSessionData(String id, long created, long accessed, long lastAccessed, long maxInactiveMs) Create a new SessionDatavoidsetGracePeriodSec(int sec) voidsetSavePeriodSec(int savePeriodSec) The minimum time in seconds between save operations.voidstore(String id, SessionData data) Store the session data.toString()Methods inherited from class ContainerLifeCycle
addBean, addBean, addEventListener, addManaged, contains, destroy, doStop, dump, dump, dump, dump, dump, dumpBeans, dumpObject, dumpObjects, dumpStdErr, dumpThis, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, removeEventListener, setBeans, setStopTimeout, start, stop, unmanage, updateBean, updateBean, updateBeansMethods inherited from class AbstractLifeCycle
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stopMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Dumpable.DumpableContainer
isDumpableMethods inherited from interface LifeCycle
addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stopMethods inherited from interface SessionDataMap
deleteMethods inherited from interface SessionDataStore
exists, isPassivating
-
Field Details
-
LOG
-
_context
-
_gracePeriodSec
protected int _gracePeriodSec -
_lastExpiryCheckTime
protected long _lastExpiryCheckTime -
_savePeriodSec
protected int _savePeriodSec
-
-
Constructor Details
-
AbstractSessionDataStore
public AbstractSessionDataStore()
-
-
Method Details
-
doStore
Store the session data persistently.- Parameters:
id- identity of session to storedata- info of the sessionlastSaveTime- time of previous save or 0 if never saved- Throws:
Exception- if unable to store data
-
doLoad
Load the session from persistent store.- Parameters:
id- the id of the session to load- Returns:
- the re-inflated session
- Throws:
Exception- if unable to load the session
-
doGetExpired
Implemented by subclasses to resolve which sessions this node should attempt to expire.- Parameters:
candidates- the ids of sessions the SessionDataStore thinks has expired- Returns:
- the reconciled set of session ids that this node should attempt to expire
-
initialize
Description copied from interface:SessionDataMapInitialize this data map for the given context. A SessionDataMap can only be used by one context(/session manager).- Specified by:
initializein interfaceSessionDataMap- Parameters:
context- context associated- Throws:
Exception- if unable to initialize the
-
load
Description copied from interface:SessionDataMapRead in session data.- Specified by:
loadin interfaceSessionDataMap- Parameters:
id- identity of session to load- Returns:
- the SessionData matching the id
- Throws:
Exception- if unable to load session data
-
store
Description copied from interface:SessionDataMapStore the session data.- Specified by:
storein interfaceSessionDataMap- Parameters:
id- identity of session to storedata- info of session to store- Throws:
Exception- if unable to write session data
-
getExpired
Description copied from interface:SessionDataStoreCalled periodically, this method should search the data store for sessions that have been expired for a 'reasonable' amount of time.- Specified by:
getExpiredin interfaceSessionDataStore- Parameters:
candidates- if provided, these are keys of sessions that the SessionDataStore thinks has expired and should be verified by the SessionDataStore- Returns:
- set of session ids
-
newSessionData
public SessionData newSessionData(String id, long created, long accessed, long lastAccessed, long maxInactiveMs) Description copied from interface:SessionDataStoreCreate a new SessionData- Specified by:
newSessionDatain interfaceSessionDataStore- Parameters:
id- the idcreated- the timestamp when createdaccessed- the timestamp when accessedlastAccessed- the timestamp when last accessedmaxInactiveMs- the max inactive time in milliseconds- Returns:
- a new SessionData object
-
checkStarted
- Throws:
IllegalStateException
-
doStart
Description copied from class:ContainerLifeCycleStarts the managed lifecycle beans in the order they were added.- Overrides:
doStartin classContainerLifeCycle- Throws:
Exception
-
getGracePeriodSec
@ManagedAttribute(value="interval in secs to prevent too eager session scavenging", readonly=true) public int getGracePeriodSec() -
setGracePeriodSec
public void setGracePeriodSec(int sec) -
getSavePeriodSec
- Returns:
- the savePeriodSec
-
setSavePeriodSec
public void setSavePeriodSec(int savePeriodSec) The minimum time in seconds between save operations. Saves normally occur every time the last request exits as session. If nothing changes on the session except for the access time and the persistence technology is slow, this can cause delays.By default the value is 0, which means we save after the last request exists. A non zero value means that we will skip doing the save if the session isn't dirty if the elapsed time since the session was last saved does not exceed this value.
- Parameters:
savePeriodSec- the savePeriodSec to set
-
toString
- Overrides:
toStringin classAbstractLifeCycle
-