Class ManagedSession

java.lang.Object
com.aspectran.core.component.session.ManagedSession
All Implemented Interfaces:
Session

public class ManagedSession extends Object implements Session
A default Session implementation.

Created: 2017. 6. 13.

  • Constructor Details

  • Method Details

    • getSessionManager

      public SessionManager getSessionManager()
    • getSessionData

      protected SessionData getSessionData()
    • setSessionData

      protected void setSessionData(SessionData sessionData)
    • getId

      public String getId()
      Specified by:
      getId in interface Session
    • getAttribute

      public <T> T getAttribute(String name)
      Specified by:
      getAttribute in interface Session
    • getAttributeNames

      public Set<String> getAttributeNames()
      Specified by:
      getAttributeNames in interface Session
    • setAttribute

      public Object setAttribute(String name, Object value)
      Specified by:
      setAttribute in interface Session
    • removeAttribute

      public Object removeAttribute(String name)
      Specified by:
      removeAttribute in interface Session
    • getCreationTime

      public long getCreationTime()
      Specified by:
      getCreationTime in interface Session
    • getLastAccessedTime

      public long getLastAccessedTime()
      Specified by:
      getLastAccessedTime in interface Session
    • getMaxInactiveInterval

      public int getMaxInactiveInterval()
      Specified by:
      getMaxInactiveInterval in interface Session
    • setMaxInactiveInterval

      public void setMaxInactiveInterval(int inactiveIntervalSecs)
      Specified by:
      setMaxInactiveInterval in interface Session
    • getEvictionIdleSecs

      protected int getEvictionIdleSecs()
    • isNew

      public boolean isNew()
      Description copied from interface: Session
      Returns true if a new session was created for the request.
      Specified by:
      isNew in interface Session
      Returns:
      true if the server has created a session, but the client has not yet joined
    • isResident

      protected boolean isResident()
    • setResident

      protected void setResident(boolean resident)
    • isTempResident

      public boolean isTempResident()
      Specified by:
      isTempResident in interface Session
    • getRequests

      protected long getRequests()
      Returns the current number of requests that are active in the Session.
      Returns:
      the number of active requests for this session
    • isValid

      public boolean isValid()
      Description copied from interface: Session
      Returns whether it is a valid session or not.
      Specified by:
      isValid in interface Session
      Returns:
      true if valid session, false otherwise
    • access

      public boolean access()
      Description copied from interface: Session
      Called when a session is first accessed by a request.
      Specified by:
      access in interface Session
    • complete

      public void complete()
      Description copied from interface: Session
      Called when a session is last accessed by a request.
      Specified by:
      complete in interface Session
    • calculateInactivityTimeout

      protected long calculateInactivityTimeout(long now)
      Calculate what the session timer setting should be based on: the time remaining before the session expires and any idle eviction time configured. The timer value will be the lesser of the above.
      Parameters:
      now - the time at which to calculate remaining expiry
      Returns:
      the time remaining before expiry or inactivity timeout
    • invalidate

      public void invalidate()
      Called by users to invalidate a session, or called by the access method as a request enters the session if the session has expired, or called by manager as a result of scavenger expiring session.
      Specified by:
      invalidate in interface Session
    • beginInvalidate

      protected boolean beginInvalidate()
    • finishInvalidate

      protected void finishInvalidate()
    • getDestroyedReason

      public Session.DestroyedReason getDestroyedReason()
      Description copied from interface: Session
      Returns the reason why the session was destroyed.
      Specified by:
      getDestroyedReason in interface Session
      Returns:
      the destroyed reason
    • setDestroyedReason

      protected void setDestroyedReason(Session.DestroyedReason destroyedReason)
    • isExpiredAt

      protected boolean isExpiredAt(long time)
      Check to see if session has expired as at the time given.
      Parameters:
      time - the time since the epoch in ms
      Returns:
      true if expired
    • isIdleLongerThan

      protected boolean isIdleLongerThan(int sec)
      Check if the Session has been idle longer than a number of seconds.
      Parameters:
      sec - the number of seconds
      Returns:
      true if the session has been idle longer than the interval
    • onSessionAttributeUpdate

      protected void onSessionAttributeUpdate(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
    • unbindValue

      protected void unbindValue(String name, Object value)
      Parameters:
      name - the name with which the object is bound or unbound
      value - the bound value
    • bindValue

      protected void bindValue(String name, Object value)
      Parameters:
      name - the name with which the object is bound or unbound
      value - the bound value
    • checkValidForWrite

      protected void checkValidForWrite()
      Check that the session can be modified.
      Throws:
      IllegalStateException - if the session is invalid
    • checkValidForRead

      protected void checkValidForRead()
      Check that the session data can be read.
      Throws:
      IllegalStateException - if the session is invalid
    • lock

      protected AutoLock lock()
      Grab the lock on the session.
      Returns:
      the lock
    • toString

      public String toString()
      Overrides:
      toString in class Object