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
Modifier and Type Method Description void
addSessionListener(SessionListener listener)
Adds an event listener for session-related events.void
clearSessionListeners()
Removes all event listeners for session-related events.BasicSession
createSession(java.lang.String id)
Create an entirely new Session.java.lang.String
createSessionId(long seedTerm)
Create a new Session ID.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.void
fireSessionDestroyedListeners(Session session)
Call the session lifecycle listeners.int
getDefaultMaxIdleSecs()
Scheduler
getScheduler()
BasicSession
getSession(java.lang.String id)
Get a known existing session.SessionCache
getSessionCache()
SessionIdGenerator
getSessionIdGenerator()
long
getSessionTimeMax()
long
getSessionTimeMean()
double
getSessionTimeStdDev()
long
getSessionTimeTotal()
java.lang.String
getWorkerName()
void
invalidate(java.lang.String id)
Called when a session has expired.void
invalidate(java.lang.String id, Session.DestroyedReason reason)
void
recordSessionTime(BasicSession session)
Record length of time session has been active.void
releaseSession(BasicSession session)
BasicSession
removeSession(java.lang.String id, boolean invalidate)
Remove session from manager.BasicSession
removeSession(java.lang.String id, boolean invalidate, Session.DestroyedReason reason)
void
removeSessionListener(SessionListener listener)
Removes an event listener for for session-related events.java.lang.String
renewSessionId(java.lang.String oldId, java.lang.String newId)
Change the id of a Session.void
scavenge()
Called periodically by the HouseKeeper to handle the list of sessions that have expired since the last call to scavenge.void
sessionInactivityTimerExpired(BasicSession 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)
void
statsReset()
Resets the session usage statistics.-
Methods inherited from interface com.aspectran.core.component.Component
destroy, getComponentName, initialize, isAvailable, isDestroyed, isDestroying, isInitialized
-
-
-
-
Method Detail
-
getWorkerName
java.lang.String getWorkerName()
-
getScheduler
Scheduler getScheduler()
-
getSessionIdGenerator
SessionIdGenerator getSessionIdGenerator()
-
getSessionCache
SessionCache getSessionCache()
-
getDefaultMaxIdleSecs
int getDefaultMaxIdleSecs()
-
setDefaultMaxIdleSecs
void setDefaultMaxIdleSecs(int defaultMaxIdleSecs)
-
getSession
BasicSession getSession(java.lang.String id)
Get a known existing session.- Parameters:
id
- the session id- Returns:
- a Session or null if none exists
-
createSession
BasicSession 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(BasicSession 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
BasicSession 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
BasicSession 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(BasicSession 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 basic 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(BasicSession 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.
-
-