Interface SessionHandler
-
- All Superinterfaces:
Component
- All Known Implementing Classes:
AbstractSessionHandler,DefaultSessionManager
public interface SessionHandler extends Component
The session handler is responsible for session start, session exists, session write, time to live and session destroy.Created: 2017. 6. 12.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddSessionListener(SessionListener listener)Adds an event listener for session-related events.voidclearSessionListeners()Removes all event listeners for session-related events.DefaultSessioncreateSession(java.lang.String id)Create an entirely new Session.java.lang.StringcreateSessionId(long seedTerm)Create a new Session ID.voidfireSessionAttributeListeners(Session session, java.lang.String name, java.lang.Object oldValue, java.lang.Object newValue)Call binding and attribute listeners based on the new and old values of the attribute.voidfireSessionDestroyedListeners(Session session)Call the session lifecycle listeners.intgetDefaultMaxIdleSecs()SchedulergetScheduler()DefaultSessiongetSession(java.lang.String id)Get a known existing session.SessionCachegetSessionCache()SessionIdGeneratorgetSessionIdGenerator()longgetSessionTimeMax()longgetSessionTimeMean()doublegetSessionTimeStdDev()longgetSessionTimeTotal()java.lang.StringgetWorkerName()voidinvalidate(java.lang.String id)Called when a session has expired.voidinvalidate(java.lang.String id, Session.DestroyedReason reason)voidrecordSessionTime(DefaultSession session)Record length of time session has been active.voidreleaseSession(DefaultSession session)DefaultSessionremoveSession(java.lang.String id, boolean invalidate)Remove session from manager.DefaultSessionremoveSession(java.lang.String id, boolean invalidate, Session.DestroyedReason reason)voidremoveSessionListener(SessionListener listener)Removes an event listener for for session-related events.java.lang.StringrenewSessionId(java.lang.String oldId, java.lang.String newId)Change the id of a Session.voidscavenge()Called periodically by the HouseKeeper to handle the list of sessions that have expired since the last call to scavenge.voidsessionInactivityTimerExpired(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.voidsetDefaultMaxIdleSecs(int defaultMaxIdleSecs)voidstatsReset()Resets the session usage statistics.-
Methods inherited from interface com.aspectran.core.component.Component
destroy, getComponentName, initialize, isAvailable, isDestroyed, isDestroying, isInitialized
-
-
-
-
Method Detail
-
getScheduler
Scheduler getScheduler()
-
getWorkerName
java.lang.String getWorkerName()
-
getSessionIdGenerator
SessionIdGenerator getSessionIdGenerator()
-
getSessionCache
SessionCache getSessionCache()
-
getDefaultMaxIdleSecs
int getDefaultMaxIdleSecs()
-
setDefaultMaxIdleSecs
void setDefaultMaxIdleSecs(int defaultMaxIdleSecs)
-
getSession
DefaultSession getSession(java.lang.String id)
Get a known existing session.- Parameters:
id- the session id- Returns:
- a Session or null if none exists
-
createSession
DefaultSession createSession(java.lang.String id)
Create an entirely new Session.- Parameters:
id- identity of session to create- Returns:
- the new session object
-
releaseSession
void releaseSession(DefaultSession session)
-
createSessionId
java.lang.String createSessionId(long seedTerm)
Create a new Session ID.- Parameters:
seedTerm- the seed for RNG- Returns:
- the new session id
-
renewSessionId
java.lang.String renewSessionId(java.lang.String oldId, java.lang.String newId)Change the id of a Session.- Parameters:
oldId- the current session idnewId- the new session id- Returns:
- the Session after changing its id
-
removeSession
DefaultSession removeSession(java.lang.String id, boolean invalidate)
Remove session from manager.- Parameters:
id- the session to removeinvalidate- if false, only remove from cache- Returns:
- if the session was removed
-
removeSession
DefaultSession removeSession(java.lang.String id, boolean invalidate, Session.DestroyedReason reason)
-
invalidate
void invalidate(java.lang.String id)
Called when a session has expired.- Parameters:
id- the id to invalidate
-
invalidate
void invalidate(java.lang.String id, Session.DestroyedReason reason)
-
sessionInactivityTimerExpired
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. 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
-
scavenge
void scavenge()
Called periodically by the HouseKeeper to handle the list of sessions that have expired since the last call to scavenge.
-
addSessionListener
void addSessionListener(SessionListener listener)
Adds an event listener for session-related events.- Parameters:
listener- the session listener- See Also:
removeSessionListener(SessionListener)
-
removeSessionListener
void removeSessionListener(SessionListener listener)
Removes an event listener for for session-related events.- Parameters:
listener- the session listener to remove- See Also:
addSessionListener(SessionListener)
-
clearSessionListeners
void clearSessionListeners()
Removes all event listeners for session-related events.- See Also:
removeSessionListener(SessionListener)
-
fireSessionAttributeListeners
void fireSessionAttributeListeners(Session session, java.lang.String name, java.lang.Object oldValue, java.lang.Object newValue)
Call binding and attribute listeners based on the new and old values of the attribute.- Parameters:
name- name of the attributenewValue- new value of the attributeoldValue- previous value of the attribute- Throws:
java.lang.IllegalStateException- if no session manager can be find
-
fireSessionDestroyedListeners
void fireSessionDestroyedListeners(Session session)
Call the session lifecycle listeners.- Parameters:
session- the session on which to call the lifecycle listeners
-
recordSessionTime
void recordSessionTime(DefaultSession session)
Record length of time session has been active. Called when the session is about to be invalidated.- Parameters:
session- the session whose time to record
-
getSessionTimeMax
long getSessionTimeMax()
- Returns:
- the maximum amount of time session remained valid
-
getSessionTimeTotal
long getSessionTimeTotal()
- Returns:
- the total amount of time all sessions remained valid
-
getSessionTimeMean
long getSessionTimeMean()
- Returns:
- the mean amount of time session remained valid
-
getSessionTimeStdDev
double getSessionTimeStdDev()
- Returns:
- the standard deviation of amount of time session remained valid
-
statsReset
void statsReset()
Resets the session usage statistics.
-
-