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

public abstract class AbstractSessionManager extends AbstractComponent implements SessionManager
Abstract Implementation of SessionManager.

Created: 2017. 6. 12.

  • Method Details

    • getClassLoader

      public abstract ClassLoader getClassLoader()
    • getWorkerName

      public String getWorkerName()
      Specified by:
      getWorkerName in interface SessionManager
    • setWorkerName

      protected void setWorkerName(String workerName)
    • getScheduler

      public Scheduler getScheduler()
      Specified by:
      getScheduler in interface SessionManager
    • setScheduler

      protected void setScheduler(Scheduler scheduler)
    • getSessionIdGenerator

      public SessionIdGenerator getSessionIdGenerator()
      Specified by:
      getSessionIdGenerator in interface SessionManager
    • setSessionIdGenerator

      protected void setSessionIdGenerator(SessionIdGenerator sessionIdGenerator)
    • getSessionCache

      public SessionCache getSessionCache()
      Specified by:
      getSessionCache in interface SessionManager
    • setSessionCache

      protected void setSessionCache(SessionCache sessionCache)
    • getHouseKeeper

      public HouseKeeper getHouseKeeper()
    • setHouseKeeper

      protected void setHouseKeeper(HouseKeeper houseKeeper)
    • getDefaultMaxIdleSecs

      public int getDefaultMaxIdleSecs()
      Specified by:
      getDefaultMaxIdleSecs in interface SessionManager
    • setDefaultMaxIdleSecs

      public void setDefaultMaxIdleSecs(int defaultMaxIdleSecs)
      Specified by:
      setDefaultMaxIdleSecs in interface SessionManager
    • getMaxIdleSecsForNew

      public int getMaxIdleSecsForNew()
      Specified by:
      getMaxIdleSecsForNew in interface SessionManager
    • setMaxIdleSecsForNew

      public void setMaxIdleSecsForNew(int maxIdleSecsForNew)
    • getSession

      public ManagedSession getSession(String id)
      Description copied from interface: SessionManager
      Get a known existing session.
      Specified by:
      getSession in interface SessionManager
      Parameters:
      id - the session id
      Returns:
      a Session or null if none exists
    • createSession

      public ManagedSession createSession(String id)
      Description copied from interface: SessionManager
      Create an entirely new Session.
      Specified by:
      createSession in interface SessionManager
      Parameters:
      id - identity of session to create
      Returns:
      the new session object
    • refreshSession

      protected void refreshSession(ManagedSession session)
    • releaseSession

      protected void releaseSession(ManagedSession session)
    • createSessionId

      public String createSessionId(long seedTerm)
      Description copied from interface: SessionManager
      Create a new Session ID.
      Specified by:
      createSessionId in interface SessionManager
      Parameters:
      seedTerm - the seed for RNG
      Returns:
      the new session id
    • renewSessionId

      public String renewSessionId(String oldId, String newId)
      Description copied from interface: SessionManager
      Change the id of a Session.
      Specified by:
      renewSessionId in interface SessionManager
      Parameters:
      oldId - the current session id
      newId - the new session id
      Returns:
      the Session after changing its id
    • removeSession

      public ManagedSession removeSession(String id, boolean invalidate)
      Description copied from interface: SessionManager
      Remove session from manager.
      Specified by:
      removeSession in interface SessionManager
      Parameters:
      id - the session to remove
      invalidate - if false, only remove from cache
      Returns:
      if the session was removed
    • removeSession

      public ManagedSession removeSession(String id, boolean invalidate, Session.DestroyedReason reason)
      Specified by:
      removeSession in interface SessionManager
    • invalidate

      public void invalidate(String id)
      Description copied from interface: SessionManager
      Called when a session has expired.
      Specified by:
      invalidate in interface SessionManager
      Parameters:
      id - the id to invalidate
    • invalidate

      public void invalidate(String id, Session.DestroyedReason reason)
      Specified by:
      invalidate in interface SessionManager
    • sessionInactivityTimerExpired

      public 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.

      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 session
      now - 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

      public void addSessionListener(SessionListener listener)
      Description copied from interface: SessionManager
      Adds an event listener for session-related events.
      Specified by:
      addSessionListener in interface SessionManager
      Parameters:
      listener - the session listener
      See Also:
    • removeSessionListener

      public void removeSessionListener(SessionListener listener)
      Description copied from interface: SessionManager
      Removes an event listener for session-related events.
      Specified by:
      removeSessionListener in interface SessionManager
      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 interface SessionManager
      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 attribute
      oldValue - previous value of the attribute
      newValue - new value of the attribute
      Throws:
      IllegalStateException - if no session manager can be found
    • onSessionDestroyed

      protected void onSessionDestroyed(Session session)
      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

      protected void onSessionCreated(Session session)
      Call the session listeners when a new session is created.
      Parameters:
      session - the session on which to call the session listeners
    • onSessionEvicted

      protected void onSessionEvicted(Session session)
      Call the session listeners when a session is evicted from the cache.
      Parameters:
      session - the session on which to call the session listeners
    • onSessionResided

      protected void onSessionResided(Session session)
      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

      public Set<String> getActiveSessions()
      Specified by:
      getActiveSessions in interface SessionManager
      Returns:
      the identifiers of those sessions that are active on this node, excluding passivated sessions
    • getAllSessions

      public Set<String> getAllSessions()
      Specified by:
      getAllSessions in interface SessionManager
      Returns:
      the identifiers of all sessions, including both active and passive
    • recordSessionTime

      public void recordSessionTime(@NonNull ManagedSession session)
      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 interface SessionManager
      Parameters:
      session - the session whose time to record
    • getStatistics

      public SessionStatistics getStatistics()
      Specified by:
      getStatistics in interface SessionManager
    • doInitialize

      protected void doInitialize() throws Exception
      Specified by:
      doInitialize in class AbstractComponent
      Throws:
      Exception
    • doDestroy

      protected void doDestroy() throws Exception
      Specified by:
      doDestroy in class AbstractComponent
      Throws:
      Exception
    • getComponentName

      public String getComponentName()
      Description copied from interface: Component
      Returns the component name.
      Specified by:
      getComponentName in interface Component
      Overrides:
      getComponentName in class AbstractComponent
      Returns:
      the component name