Class AbstractSessionStore
java.lang.Object
com.aspectran.core.component.AbstractComponent
com.aspectran.core.component.session.AbstractSessionStore
- All Implemented Interfaces:
Component
,SessionStore
- Direct Known Subclasses:
AbstractLettuceSessionStore
,FileSessionStore
Abstract Implementation for SessionStore.
Created: 2017. 9. 10.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
protected boolean
checkExpiry
(SessionData data, long time) Checks whether the given session has not expired.protected void
void
cleanOrphans
(long time) Remove all unmanaged sessions that expired at or before the given time.abstract void
doCleanOrphans
(long time) Implemented by subclasses to delete unmanaged sessions that expired before a specified time.doGetExpired
(long time) Implemented by subclasses to resolve which sessions this node should attempt to expire.abstract void
doSave
(String id, SessionData data) 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.long
getGracePeriodMillis
(float weight) int
Returns the names of the attributes that should be excluded from serialization.long
int
boolean
isNonPersistentAttributes
(String attrName) void
save
(String id, SessionData data) Save the session data.void
setGracePeriodSecs
(int gracePeriodSecs) Sets the interval in secs to prevent too eager session scavenging.void
setNonPersistentAttributes
(String... nonPersistentAttributes) Specifies attributes that should be excluded from serialization.void
setSavePeriodSecs
(int savePeriodSecs) The minimum time in seconds between save operations.Methods inherited from class com.aspectran.core.component.AbstractComponent
destroy, doDestroy, doInitialize, getComponentName, initialize, isAvailable, isDestroyed, isDestroying, 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, isDestroying, isInitialized
Methods inherited from interface com.aspectran.core.component.session.SessionStore
delete, exists, getAllSessions, load
-
Field Details
-
DEFAULT_GRACE_PERIOD_SECS
public static final int DEFAULT_GRACE_PERIOD_SECS- See Also:
-
DEFAULT_SAVE_PERIOD_SECS
public static final int DEFAULT_SAVE_PERIOD_SECS- See Also:
-
-
Constructor Details
-
AbstractSessionStore
public AbstractSessionStore()
-
-
Method Details
-
getGracePeriodSecs
public int getGracePeriodSecs() -
getGracePeriodMillis
public long getGracePeriodMillis(float weight) -
setGracePeriodSecs
public void setGracePeriodSecs(int gracePeriodSecs) Sets the interval in secs to prevent too eager session scavenging.- Parameters:
gracePeriodSecs
- interval in secs to prevent too eager session scavenging
-
getSavePeriodSecs
public int getSavePeriodSecs()- Returns:
- the time in seconds between saves
-
getSavePeriodMillis
public long getSavePeriodMillis() -
setSavePeriodSecs
public void setSavePeriodSecs(int savePeriodSecs) 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:
savePeriodSecs
- the savePeriodSecs to set
-
getNonPersistentAttributes
Description copied from interface:SessionStore
Returns the names of the attributes that should be excluded from serialization.- Specified by:
getNonPersistentAttributes
in interfaceSessionStore
- Returns:
- the attribute names to be excluded from serialization
-
setNonPersistentAttributes
Specifies attributes that should be excluded from serialization.- Parameters:
nonPersistentAttributes
- the attribute names to exclude from serialization
-
isNonPersistentAttributes
-
save
Description copied from interface:SessionStore
Save the session data.- Specified by:
save
in interfaceSessionStore
- Parameters:
id
- identity of session to storedata
- info of session to store- Throws:
Exception
- if unable to write session data
-
doSave
Store the session data persistently.- Parameters:
id
- identity of session to storedata
- info of the session- Throws:
Exception
- if unable to store data
-
getExpired
Description copied from interface:SessionStore
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 interfaceSessionStore
- Parameters:
candidates
- if provided, these are keys of sessions that the SessionStore thinks has expired and should be verified by the SessionStore- Returns:
- set of session ids
-
checkExpiry
Checks whether the given session has not expired.- Parameters:
data
- the session datatime
- the time before which the sessions must have expired- Returns:
- true if the session has not yet expired, false otherwise
-
doGetExpired
Implemented by subclasses to resolve which sessions this node should attempt to expire.- Parameters:
time
- the upper limit of expiry times to check- Returns:
- the reconciled set of session ids that this node should attempt to expire
-
doCleanOrphans
public abstract void doCleanOrphans(long time) Implemented by subclasses to delete unmanaged sessions that expired before a specified time. This is to remove 'orphaned' sessions that are no longer actively managed on any node, while sessions that are explicitly managed on each node are handled by other mechanisms such as doGetExpired.This is called only periodically to avoid placing excessive load on the store.
- Parameters:
time
- the upper limit of the expiry time to check in msec
-
cleanOrphans
public void cleanOrphans(long time) Description copied from interface:SessionStore
Remove all unmanaged sessions that expired at or before the given time.- Specified by:
cleanOrphans
in interfaceSessionStore
- Parameters:
time
- the time before which the sessions must have expired
-
checkInitialized
- Throws:
IllegalStateException
-
checkAlreadyInitialized
- Throws:
IllegalStateException
-