Class AbstractSessionStore

java.lang.Object
com.aspectran.core.component.AbstractComponent
com.aspectran.core.component.session.AbstractSessionStore
All Implemented Interfaces:
Component, SessionStore
Direct Known Subclasses:
AbstractLettuceSessionStore, FileSessionStore

public abstract class AbstractSessionStore extends AbstractComponent implements SessionStore
Abstract Implementation for SessionStore.

Created: 2017. 9. 10.

  • Field Details

    • DEFAULT_GRACE_PERIOD_SECS

      public static final int DEFAULT_GRACE_PERIOD_SECS
      See Also:
    • DEFAULT_SAVE_PERIOD_SECS

      public static final int DEFAULT_SAVE_PERIOD_SECS
      See Also:
  • Constructor Details

    • AbstractSessionStore

      public AbstractSessionStore()
  • Method Details

    • getGracePeriodSecs

      public int getGracePeriodSecs()
    • getGracePeriodMillis

      public long getGracePeriodMillis(float weight)
    • setGracePeriodSecs

      public void setGracePeriodSecs(int gracePeriodSecs)
      Sets the interval in secs to prevent too eager session scavenging.
      Parameters:
      gracePeriodSecs - interval in secs to prevent too eager session scavenging
    • getSavePeriodSecs

      public int getSavePeriodSecs()
      Returns:
      the time in seconds between saves
    • getSavePeriodMillis

      public long getSavePeriodMillis()
    • setSavePeriodSecs

      public void setSavePeriodSecs(int savePeriodSecs)
      The minimum time in seconds between save operations. Saves normally occur every time the last request exits as session. If nothing changes on the session except for the access time and the persistence technology is slow, this can cause delays.

      By default the value is 0, which means we save after the last request exists. A non zero value means that we will skip doing the save if the session isn't dirty if the elapsed time since the session was last saved does not exceed this value.

      Parameters:
      savePeriodSecs - the savePeriodSecs to set
    • getNonPersistentAttributes

      public Set<String> getNonPersistentAttributes()
      Description copied from interface: SessionStore
      Returns the names of the attributes that should be excluded from serialization.
      Specified by:
      getNonPersistentAttributes in interface SessionStore
      Returns:
      the attribute names to be excluded from serialization
    • setNonPersistentAttributes

      public void setNonPersistentAttributes(String... nonPersistentAttributes)
      Specifies attributes that should be excluded from serialization.
      Parameters:
      nonPersistentAttributes - the attribute names to exclude from serialization
    • isNonPersistentAttributes

      public boolean isNonPersistentAttributes(String attrName)
    • save

      public void save(String id, SessionData data) throws Exception
      Description copied from interface: SessionStore
      Save the session data.
      Specified by:
      save in interface SessionStore
      Parameters:
      id - identity of session to store
      data - info of session to store
      Throws:
      Exception - if unable to write session data
    • doSave

      public abstract void doSave(String id, SessionData data) throws Exception
      Store the session data persistently.
      Parameters:
      id - identity of session to store
      data - info of the session
      Throws:
      Exception - if unable to store data
    • getExpired

      public Set<String> getExpired(Set<String> candidates)
      Description copied from interface: SessionStore
      Called periodically, this method should search the data store for sessions that have been expired for a 'reasonable' amount of time.
      Specified by:
      getExpired in interface SessionStore
      Parameters:
      candidates - if provided, these are keys of sessions that the SessionStore thinks has expired and should be verified by the SessionStore
      Returns:
      set of session ids
    • checkExpiry

      protected boolean checkExpiry(SessionData data, long time)
      Checks whether the given session has not expired.
      Parameters:
      data - the session data
      time - the time before which the sessions must have expired
      Returns:
      true if the session has not yet expired, false otherwise
    • doGetExpired

      public abstract Set<String> doGetExpired(long time)
      Implemented by subclasses to resolve which sessions this node should attempt to expire.
      Parameters:
      time - the upper limit of expiry times to check
      Returns:
      the reconciled set of session ids that this node should attempt to expire
    • doCleanOrphans

      public abstract void doCleanOrphans(long time)
      Implemented by subclasses to delete unmanaged sessions that expired before a specified time. This is to remove 'orphaned' sessions that are no longer actively managed on any node, while sessions that are explicitly managed on each node are handled by other mechanisms such as doGetExpired.

      This is called only periodically to avoid placing excessive load on the store.

      Parameters:
      time - the upper limit of the expiry time to check in msec
    • cleanOrphans

      public void cleanOrphans(long time)
      Description copied from interface: SessionStore
      Remove all unmanaged sessions that expired at or before the given time.
      Specified by:
      cleanOrphans in interface SessionStore
      Parameters:
      time - the time before which the sessions must have expired
    • checkInitialized

      protected void checkInitialized() throws IllegalStateException
      Throws:
      IllegalStateException
    • checkAlreadyInitialized

      protected void checkAlreadyInitialized() throws IllegalStateException
      Throws:
      IllegalStateException