Class AbstractSessionManager
java.lang.Object
com.aspectran.core.component.AbstractComponent
com.aspectran.core.component.session.AbstractSessionManager
- All Implemented Interfaces:
Component
,SessionManager
- Direct Known Subclasses:
DefaultSessionManager
Abstract Implementation of SessionManager.
Created: 2017. 6. 12.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addSessionListener
(SessionListener listener) Adds an event listener for session-related events.void
Removes all event listeners for session-related events.createSession
(String id) Create an entirely new Session.createSessionId
(long seedTerm) Create a new Session ID.protected void
protected void
abstract ClassLoader
Returns the component name.int
int
getSession
(String id) Get a known existing session.void
invalidate
(String id) Called when a session has expired.void
invalidate
(String id, Session.DestroyedReason reason) protected void
onSessionAttributeUpdate
(Session session, String name, Object oldValue, Object newValue) Call binding and attribute listeners based on the new and old values of the attribute.protected void
onSessionCreated
(Session session) Call the session listeners when a new session is created.protected void
onSessionDestroyed
(Session session) Calls session listeners in the reverse order they were added when a session is destroyed.protected void
onSessionEvicted
(Session session) Call the session listeners when a session is evicted from the cache.protected void
onSessionResided
(Session session) Receives notification that a stored session is about to be resided in the cache.void
recordSessionTime
(ManagedSession session) Record length of time session has been active.protected void
refreshSession
(ManagedSession session) protected void
releaseSession
(ManagedSession session) removeSession
(String id, boolean invalidate) Remove session from manager.removeSession
(String id, boolean invalidate, Session.DestroyedReason reason) void
removeSessionListener
(SessionListener listener) Removes an event listener for session-related events.renewSessionId
(String oldId, String newId) Change the id of a Session.void
scavenge
(long scavengingInterval) Called periodically by the HouseKeeper to handle the list of sessions that have expired since the last call to scavenge.boolean
sessionInactivityTimerExpired
(ManagedSession session, long now) Each session has a timer that is configured to go off when either the session has not been accessed for a configurable amount of time, or the session itself has passed its expiry.void
setDefaultMaxIdleSecs
(int defaultMaxIdleSecs) protected void
setHouseKeeper
(HouseKeeper houseKeeper) void
setMaxIdleSecsForNew
(int maxIdleSecsForNew) protected void
setScheduler
(Scheduler scheduler) protected void
setSessionCache
(SessionCache sessionCache) protected void
setSessionIdGenerator
(SessionIdGenerator sessionIdGenerator) protected void
setWorkerName
(String workerName) Methods inherited from class com.aspectran.core.component.AbstractComponent
checkAvailable, checkInitializable, checkNotDestroyed, destroy, initialize, isAvailable, isDestroyed, isDestroying, isInitializable, isInitialized, isInitializing
-
Method Details
-
getClassLoader
-
getWorkerName
- Specified by:
getWorkerName
in interfaceSessionManager
-
setWorkerName
-
getScheduler
- Specified by:
getScheduler
in interfaceSessionManager
-
setScheduler
-
getSessionIdGenerator
- Specified by:
getSessionIdGenerator
in interfaceSessionManager
-
setSessionIdGenerator
-
getSessionCache
- Specified by:
getSessionCache
in interfaceSessionManager
-
setSessionCache
-
getHouseKeeper
-
setHouseKeeper
-
getDefaultMaxIdleSecs
public int getDefaultMaxIdleSecs()- Specified by:
getDefaultMaxIdleSecs
in interfaceSessionManager
-
setDefaultMaxIdleSecs
public void setDefaultMaxIdleSecs(int defaultMaxIdleSecs) - Specified by:
setDefaultMaxIdleSecs
in interfaceSessionManager
-
getMaxIdleSecsForNew
public int getMaxIdleSecsForNew()- Specified by:
getMaxIdleSecsForNew
in interfaceSessionManager
-
setMaxIdleSecsForNew
public void setMaxIdleSecsForNew(int maxIdleSecsForNew) -
getSession
Description copied from interface:SessionManager
Get a known existing session.- Specified by:
getSession
in interfaceSessionManager
- Parameters:
id
- the session id- Returns:
- a Session or null if none exists
-
createSession
Description copied from interface:SessionManager
Create an entirely new Session.- Specified by:
createSession
in interfaceSessionManager
- Parameters:
id
- identity of session to create- Returns:
- the new session object
-
refreshSession
-
releaseSession
-
createSessionId
Description copied from interface:SessionManager
Create a new Session ID.- Specified by:
createSessionId
in interfaceSessionManager
- Parameters:
seedTerm
- the seed for RNG- Returns:
- the new session id
-
renewSessionId
Description copied from interface:SessionManager
Change the id of a Session.- Specified by:
renewSessionId
in interfaceSessionManager
- Parameters:
oldId
- the current session idnewId
- the new session id- Returns:
- the Session after changing its id
-
removeSession
Description copied from interface:SessionManager
Remove session from manager.- Specified by:
removeSession
in interfaceSessionManager
- Parameters:
id
- the session to removeinvalidate
- if false, only remove from cache- Returns:
- if the session was removed
-
removeSession
- Specified by:
removeSession
in interfaceSessionManager
-
invalidate
Description copied from interface:SessionManager
Called when a session has expired.- Specified by:
invalidate
in interfaceSessionManager
- Parameters:
id
- the id to invalidate
-
invalidate
- Specified by:
invalidate
in interfaceSessionManager
-
sessionInactivityTimerExpired
Each session has a timer that is configured to go off when either the session has not been accessed for a configurable amount of time, or the session itself has passed its expiry.If it has passed its expiry, then we will mark it for scavenging by next run of the HouseKeeper; if it has been idle longer than the configured eviction period, we evict from the cache.
If none of the above are true, then the System timer is inconsistent and the caller of this method will need to reset the timer.
- Parameters:
session
- the default sessionnow
- the time at which to check for expiry- Returns:
- true if the session has already expired
-
scavenge
public void scavenge(long scavengingInterval) Called periodically by the HouseKeeper to handle the list of sessions that have expired since the last call to scavenge.- Parameters:
scavengingInterval
- the period between scavenge cycles
-
addSessionListener
Description copied from interface:SessionManager
Adds an event listener for session-related events.- Specified by:
addSessionListener
in interfaceSessionManager
- Parameters:
listener
- the session listener- See Also:
-
removeSessionListener
Description copied from interface:SessionManager
Removes an event listener for session-related events.- Specified by:
removeSessionListener
in interfaceSessionManager
- Parameters:
listener
- the session listener to remove- See Also:
-
clearSessionListeners
public void clearSessionListeners()Description copied from interface:SessionManager
Removes all event listeners for session-related events.- Specified by:
clearSessionListeners
in interfaceSessionManager
- See Also:
-
onSessionAttributeUpdate
protected void onSessionAttributeUpdate(Session session, String name, Object oldValue, Object newValue) Call binding and attribute listeners based on the new and old values of the attribute.- Parameters:
name
- name of the attributeoldValue
- previous value of the attributenewValue
- new value of the attribute- Throws:
IllegalStateException
- if no session manager can be found
-
onSessionDestroyed
Calls session listeners in the reverse order they were added when a session is destroyed.- Parameters:
session
- the session on which to call the session listeners
-
onSessionCreated
Call the session listeners when a new session is created.- Parameters:
session
- the session on which to call the session listeners
-
onSessionEvicted
Call the session listeners when a session is evicted from the cache.- Parameters:
session
- the session on which to call the session listeners
-
onSessionResided
Receives notification that a stored session is about to be resided in the cache.- Parameters:
session
- the session on which to call the session listeners
-
getActiveSessions
- Specified by:
getActiveSessions
in interfaceSessionManager
- Returns:
- the identifiers of those sessions that are active on this node, excluding passivated sessions
-
getAllSessions
- Specified by:
getAllSessions
in interfaceSessionManager
- Returns:
- the identifiers of all sessions, including both active and passive
-
recordSessionTime
Description copied from interface:SessionManager
Record length of time session has been active. Called when the session is about to be invalidated.- Specified by:
recordSessionTime
in interfaceSessionManager
- Parameters:
session
- the session whose time to record
-
getStatistics
- Specified by:
getStatistics
in interfaceSessionManager
-
doInitialize
- Specified by:
doInitialize
in classAbstractComponent
- Throws:
Exception
-
doDestroy
- Specified by:
doDestroy
in classAbstractComponent
- Throws:
Exception
-
getComponentName
Description copied from interface:Component
Returns the component name.- Specified by:
getComponentName
in interfaceComponent
- Overrides:
getComponentName
in classAbstractComponent
- Returns:
- the component name
-