Class AbstractSessionHandler
java.lang.Object
com.aspectran.core.component.AbstractComponent
com.aspectran.core.component.session.AbstractSessionHandler
- All Implemented Interfaces:
Component
,SessionHandler
- Direct Known Subclasses:
DefaultSessionManager
Abstract Implementation of SessionHandler.
Created: 2017. 6. 12.
-
Constructor Summary
Constructors -
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
void
fireSessionAttributeListeners
(Session session, String name, Object oldValue, Object newValue) Call binding and attribute listeners based on the new and old values of the attribute.void
fireSessionDestroyedListeners
(Session session) Call the session lifecycle listeners.Returns the component name.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) void
recordSessionTime
(DefaultSession session) Record length of time session has been active.void
releaseSession
(DefaultSession 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.void
sessionInactivityTimerExpired
(DefaultSession 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) 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
destroy, 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, initialize, isAvailable, isDestroyed, isDestroying, isInitialized
-
Constructor Details
-
AbstractSessionHandler
public AbstractSessionHandler()
-
-
Method Details
-
getWorkerName
- Specified by:
getWorkerName
in interfaceSessionHandler
-
setWorkerName
-
getScheduler
- Specified by:
getScheduler
in interfaceSessionHandler
-
setScheduler
-
getSessionIdGenerator
- Specified by:
getSessionIdGenerator
in interfaceSessionHandler
-
setSessionIdGenerator
-
getSessionCache
- Specified by:
getSessionCache
in interfaceSessionHandler
-
setSessionCache
-
getHouseKeeper
-
setHouseKeeper
-
getDefaultMaxIdleSecs
public int getDefaultMaxIdleSecs()- Specified by:
getDefaultMaxIdleSecs
in interfaceSessionHandler
-
setDefaultMaxIdleSecs
public void setDefaultMaxIdleSecs(int defaultMaxIdleSecs) - Specified by:
setDefaultMaxIdleSecs
in interfaceSessionHandler
-
getSession
Description copied from interface:SessionHandler
Get a known existing session.- Specified by:
getSession
in interfaceSessionHandler
- Parameters:
id
- the session id- Returns:
- a Session or null if none exists
-
createSession
Description copied from interface:SessionHandler
Create an entirely new Session.- Specified by:
createSession
in interfaceSessionHandler
- Parameters:
id
- identity of session to create- Returns:
- the new session object
-
releaseSession
- Specified by:
releaseSession
in interfaceSessionHandler
-
createSessionId
Description copied from interface:SessionHandler
Create a new Session ID.- Specified by:
createSessionId
in interfaceSessionHandler
- Parameters:
seedTerm
- the seed for RNG- Returns:
- the new session id
-
renewSessionId
Description copied from interface:SessionHandler
Change the id of a Session.- Specified by:
renewSessionId
in interfaceSessionHandler
- Parameters:
oldId
- the current session idnewId
- the new session id- Returns:
- the Session after changing its id
-
removeSession
Description copied from interface:SessionHandler
Remove session from manager.- Specified by:
removeSession
in interfaceSessionHandler
- Parameters:
id
- the session to removeinvalidate
- if false, only remove from cache- Returns:
- if the session was removed
-
removeSession
- Specified by:
removeSession
in interfaceSessionHandler
-
invalidate
Description copied from interface:SessionHandler
Called when a session has expired.- Specified by:
invalidate
in interfaceSessionHandler
- Parameters:
id
- the id to invalidate
-
invalidate
- Specified by:
invalidate
in interfaceSessionHandler
-
sessionInactivityTimerExpired
Description copied from interface:SessionHandler
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.
- Specified by:
sessionInactivityTimerExpired
in interfaceSessionHandler
- Parameters:
session
- the default sessionnow
- the time at which to check for expiry
-
scavenge
public void scavenge(long scavengingInterval) Description copied from interface:SessionHandler
Called periodically by the HouseKeeper to handle the list of sessions that have expired since the last call to scavenge.- Specified by:
scavenge
in interfaceSessionHandler
- Parameters:
scavengingInterval
- the period between scavenge cycles
-
addSessionListener
Description copied from interface:SessionHandler
Adds an event listener for session-related events.- Specified by:
addSessionListener
in interfaceSessionHandler
- Parameters:
listener
- the session listener- See Also:
-
removeSessionListener
Description copied from interface:SessionHandler
Removes an event listener for session-related events.- Specified by:
removeSessionListener
in interfaceSessionHandler
- Parameters:
listener
- the session listener to remove- See Also:
-
clearSessionListeners
public void clearSessionListeners()Description copied from interface:SessionHandler
Removes all event listeners for session-related events.- Specified by:
clearSessionListeners
in interfaceSessionHandler
- See Also:
-
fireSessionAttributeListeners
public void fireSessionAttributeListeners(Session session, String name, Object oldValue, Object newValue) Description copied from interface:SessionHandler
Call binding and attribute listeners based on the new and old values of the attribute.- Specified by:
fireSessionAttributeListeners
in interfaceSessionHandler
name
- name of the attributeoldValue
- previous value of the attributenewValue
- new value of the attribute
-
fireSessionDestroyedListeners
Description copied from interface:SessionHandler
Call the session lifecycle listeners.- Specified by:
fireSessionDestroyedListeners
in interfaceSessionHandler
- Parameters:
session
- the session on which to call the lifecycle listeners
-
getActiveSessions
- Specified by:
getActiveSessions
in interfaceSessionHandler
- Returns:
- the identifiers of those sessions that are active on this node, excluding passivated sessions
-
getAllSessions
- Specified by:
getAllSessions
in interfaceSessionHandler
- Returns:
- the identifiers of all sessions, including both active and passive
-
recordSessionTime
Description copied from interface:SessionHandler
Record length of time session has been active. Called when the session is about to be invalidated.- Specified by:
recordSessionTime
in interfaceSessionHandler
- Parameters:
session
- the session whose time to record
-
getStatistics
- Specified by:
getStatistics
in interfaceSessionHandler
-
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
-