Class AbstractSessionDataStore
- java.lang.Object
-
- com.aspectran.core.component.AbstractComponent
-
- com.aspectran.core.component.session.AbstractSessionDataStore
-
- All Implemented Interfaces:
Component
,SessionDataStore
- Direct Known Subclasses:
FileSessionDataStore
public abstract class AbstractSessionDataStore extends AbstractComponent implements SessionDataStore
Created: 2017. 9. 10.
-
-
Field Summary
Fields Modifier and Type Field Description protected int
gracePeriodSec
protected long
lastExpiryCheckTime
protected int
savePeriodSec
-
Constructor Summary
Constructors Constructor Description AbstractSessionDataStore()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
checkInitialized()
protected void
doDestroy()
abstract java.util.Set<java.lang.String>
doGetExpired(java.util.Set<java.lang.String> candidates)
Implemented by subclasses to resolve which sessions this node should attempt to expire.protected void
doInitialize()
abstract void
doStore(java.lang.String id, SessionData data, long lastSaveTime)
Store the session data persistently.java.util.Set<java.lang.String>
getExpired(java.util.Set<java.lang.String> candidates)
Called periodically, this method should search the data store for sessions that have been expired for a 'reasonable' amount of time.int
getGracePeriodSec()
int
getSavePeriodSec()
SessionData
newSessionData(java.lang.String id, long createdTime, long accessedTime, long lastAccessedTime, long maxInactiveIntervalMS)
Create a new SessionData.void
setGracePeriodSec(int sec)
Sets the interval in secs to prevent too eager session scavenging.void
setSavePeriodSec(int savePeriodSec)
The minimum time in seconds between save operations.void
store(java.lang.String id, SessionData data)
Store the session data.-
Methods inherited from class com.aspectran.core.component.AbstractComponent
destroy, getComponentName, initialize, isAvailable, isDestroyed, isInitialized
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.aspectran.core.component.Component
destroy, getComponentName, initialize, isAvailable, isDestroyed, isInitialized
-
Methods inherited from interface com.aspectran.core.component.session.SessionDataStore
delete, exists, isPassivating, load
-
-
-
-
Method Detail
-
doStore
public abstract void doStore(java.lang.String id, SessionData data, long lastSaveTime) throws java.lang.Exception
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:
java.lang.Exception
- if unable to store data
-
doGetExpired
public abstract java.util.Set<java.lang.String> doGetExpired(java.util.Set<java.lang.String> candidates)
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
-
store
public void store(java.lang.String id, SessionData data) throws java.lang.Exception
Description copied from interface:SessionDataStore
Store the session data.- Specified by:
store
in interfaceSessionDataStore
- Parameters:
id
- identity of session to storedata
- info of session to store- Throws:
java.lang.Exception
- if unable to write session data
-
getExpired
public java.util.Set<java.lang.String> getExpired(java.util.Set<java.lang.String> candidates)
Description copied from interface:SessionDataStore
Called periodically, this method should search the data store for sessions that have been expired for a 'reasonable' amount of time.- Specified by:
getExpired
in 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(java.lang.String id, long createdTime, long accessedTime, long lastAccessedTime, long maxInactiveIntervalMS)
Description copied from interface:SessionDataStore
Create a new SessionData.- Specified by:
newSessionData
in interfaceSessionDataStore
- Parameters:
id
- the idcreatedTime
- the timestamp when createdaccessedTime
- the timestamp when accessedlastAccessedTime
- the timestamp when last accessedmaxInactiveIntervalMS
- the max inactive time in milliseconds- Returns:
- a new SessionData object
-
getGracePeriodSec
public int getGracePeriodSec()
-
setGracePeriodSec
public void setGracePeriodSec(int sec)
Sets the interval in secs to prevent too eager session scavenging.- Parameters:
sec
- interval in secs to prevent too eager session scavenging
-
getSavePeriodSec
public int getSavePeriodSec()
-
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
-
doInitialize
protected void doInitialize() throws java.lang.Exception
- Specified by:
doInitialize
in classAbstractComponent
- Throws:
java.lang.Exception
-
doDestroy
protected void doDestroy()
- Specified by:
doDestroy
in classAbstractComponent
-
checkInitialized
protected void checkInitialized() throws java.lang.IllegalStateException
- Throws:
java.lang.IllegalStateException
-
-