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
public abstract class AbstractSessionHandler extends AbstractComponent implements SessionHandler
Abstract Implementation of SessionHandler.Created: 2017. 6. 12.
-
-
Field Summary
Fields Modifier and Type Field Description protected CounterStatistic
sessionsCreatedStats
protected SampleStatistic
sessionTimeStats
-
Constructor Summary
Constructors Constructor Description AbstractSessionHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
access(Session session)
Called by theSessionHandler
when a session is first accessed by a request.void
addEventListener(java.util.EventListener listener)
Adds an event listener for session-related events.void
clearEventListeners()
Removes all event listeners for session-related events.void
complete(Session session)
Called by theSessionHandler
when a session is last accessed by a request.void
didActivate(Session session)
Call the activation listeners.protected void
doDestroy()
protected void
doInitialize()
int
getDefaultMaxIdleSecs()
Scheduler
getScheduler()
Session
getSession(java.lang.String id)
Get a known existing session.SessionCache
getSessionCache()
SessionIdGenerator
getSessionIdGenerator()
int
getSessionsCreated()
Returns the total number of sessions created by this manager.long
getSessionTimeMax()
Returns the maximum time the session is valid.double
getSessionTimeMean()
Returns the mean amount of time session remained valid.double
getSessionTimeStdDev()
Returns the standard deviation of amount of time session remained valid.long
getSessionTimeTotal()
Returns the total amount of time all sessions remained valid.void
invalidate(java.lang.String id)
Called when a session has expired.Session
newSession(java.lang.String id)
Create an entirely new Session.java.lang.String
newSessionId(long seedTerm)
void
removeEventListener(java.util.EventListener listener)
Removes an event listener for for session-related events.void
sessionAttributeChanged(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
setDefaultMaxIdleSecs(int defaultMaxIdleSecs)
protected void
setSessionCache(SessionCache sessionCache)
protected void
setSessionIdGenerator(SessionIdGenerator sessionIdGenerator)
void
statsReset()
Resets the session usage statistics.void
willPassivate(Session session)
Call the passivation listeners.-
Methods inherited from class com.aspectran.core.component.AbstractComponent
destroy, getComponentName, initialize, isAvailable, isDestroyed, 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, isInitialized
-
-
-
-
Field Detail
-
sessionTimeStats
protected final SampleStatistic sessionTimeStats
-
sessionsCreatedStats
protected final CounterStatistic sessionsCreatedStats
-
-
Method Detail
-
getSessionIdGenerator
public SessionIdGenerator getSessionIdGenerator()
- Specified by:
getSessionIdGenerator
in interfaceSessionHandler
-
setSessionIdGenerator
protected void setSessionIdGenerator(SessionIdGenerator sessionIdGenerator)
-
getSessionCache
public SessionCache getSessionCache()
- Specified by:
getSessionCache
in interfaceSessionHandler
-
setSessionCache
protected void setSessionCache(SessionCache sessionCache)
-
getScheduler
public Scheduler getScheduler()
- Specified by:
getScheduler
in interfaceSessionHandler
-
getDefaultMaxIdleSecs
public int getDefaultMaxIdleSecs()
- Specified by:
getDefaultMaxIdleSecs
in interfaceSessionHandler
-
setDefaultMaxIdleSecs
public void setDefaultMaxIdleSecs(int defaultMaxIdleSecs)
- Specified by:
setDefaultMaxIdleSecs
in interfaceSessionHandler
-
access
public void access(Session session)
Called by theSessionHandler
when a session is first accessed by a request.- Specified by:
access
in interfaceSessionHandler
- Parameters:
session
- the session object- See Also:
complete(Session)
-
complete
public void complete(Session session)
Called by theSessionHandler
when a session is last accessed by a request.- Specified by:
complete
in interfaceSessionHandler
- Parameters:
session
- the session object- See Also:
access(Session)
-
newSession
public Session newSession(java.lang.String id)
Create an entirely new Session.- Specified by:
newSession
in interfaceSessionHandler
- Parameters:
id
- identity of session to create- Returns:
- the new session object
-
getSession
public Session getSession(java.lang.String id)
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
-
invalidate
public void invalidate(java.lang.String id)
Description copied from interface:SessionHandler
Called when a session has expired.- Specified by:
invalidate
in interfaceSessionHandler
- Parameters:
id
- the id to invalidate
-
newSessionId
public java.lang.String newSessionId(long seedTerm)
- Specified by:
newSessionId
in interfaceSessionHandler
-
addEventListener
public void addEventListener(java.util.EventListener listener)
Adds an event listener for session-related events.- Specified by:
addEventListener
in interfaceSessionHandler
- Parameters:
listener
- the session event listener- See Also:
removeEventListener(EventListener)
-
removeEventListener
public void removeEventListener(java.util.EventListener listener)
Removes an event listener for for session-related events.- Specified by:
removeEventListener
in interfaceSessionHandler
- Parameters:
listener
- the session event listener to remove- See Also:
addEventListener(EventListener)
-
clearEventListeners
public void clearEventListeners()
Removes all event listeners for session-related events.- Specified by:
clearEventListeners
in interfaceSessionHandler
- See Also:
removeEventListener(EventListener)
-
sessionAttributeChanged
public void sessionAttributeChanged(Session session, java.lang.String name, java.lang.Object oldValue, java.lang.Object newValue)
Description copied from interface:SessionHandler
Call binding and attribute listeners based on the new and old values of the attribute.- Specified by:
sessionAttributeChanged
in interfaceSessionHandler
- Parameters:
session
- the basic sessionname
- name of the attributeoldValue
- previous value of the attributenewValue
- new value of the attribute
-
didActivate
public void didActivate(Session session)
Description copied from interface:SessionHandler
Call the activation listeners. This must be called holding the lock.- Specified by:
didActivate
in interfaceSessionHandler
- Parameters:
session
- the session
-
willPassivate
public void willPassivate(Session session)
Description copied from interface:SessionHandler
Call the passivation listeners. This must be called holding the lock.- Specified by:
willPassivate
in interfaceSessionHandler
- Parameters:
session
- the session
-
getSessionTimeMax
public long getSessionTimeMax()
Description copied from interface:SessionHandler
Returns the maximum time the session is valid.- Specified by:
getSessionTimeMax
in interfaceSessionHandler
- Returns:
- the maximum amount of time session remained valid
-
getSessionTimeTotal
public long getSessionTimeTotal()
Description copied from interface:SessionHandler
Returns the total amount of time all sessions remained valid.- Specified by:
getSessionTimeTotal
in interfaceSessionHandler
- Returns:
- the total amount of time all sessions remained valid
-
getSessionTimeMean
public double getSessionTimeMean()
Description copied from interface:SessionHandler
Returns the mean amount of time session remained valid.- Specified by:
getSessionTimeMean
in interfaceSessionHandler
- Returns:
- the mean amount of time session remained valid
-
getSessionTimeStdDev
public double getSessionTimeStdDev()
Description copied from interface:SessionHandler
Returns the standard deviation of amount of time session remained valid.- Specified by:
getSessionTimeStdDev
in interfaceSessionHandler
- Returns:
- the standard deviation of amount of time session remained valid
-
getSessionsCreated
public int getSessionsCreated()
Description copied from interface:SessionHandler
Returns the total number of sessions created by this manager.- Specified by:
getSessionsCreated
in interfaceSessionHandler
- Returns:
- the total number of sessions created by this manager
-
statsReset
public void statsReset()
Resets the session usage statistics.- Specified by:
statsReset
in interfaceSessionHandler
-
doInitialize
protected void doInitialize() throws java.lang.Exception
- Specified by:
doInitialize
in classAbstractComponent
- Throws:
java.lang.Exception
-
doDestroy
protected void doDestroy() throws java.lang.Exception
- Specified by:
doDestroy
in classAbstractComponent
- Throws:
java.lang.Exception
-
-