Class MongoSession

java.lang.Object
org.springframework.session.data.mongo.MongoSession
All Implemented Interfaces:
Session

public class MongoSession extends Object implements Session
Session object providing additional information about the datetime of expiration.
Since:
1.2
  • Constructor Details

    • MongoSession

      public MongoSession()
    • MongoSession

      public MongoSession(long maxInactiveIntervalInSeconds)
    • MongoSession

      public MongoSession(String id, long maxInactiveIntervalInSeconds)
  • Method Details

    • changeSessionId

      public String changeSessionId()
      Description copied from interface: Session
      Changes the session id. After invoking the Session.getId() will return a new identifier.
      Specified by:
      changeSessionId in interface Session
      Returns:
      the new session id which Session.getId() will now return
    • getAttribute

      @Nullable public <T> T getAttribute(String attributeName)
      Description copied from interface: Session
      Gets the Object associated with the specified name or null if no Object is associated to that name.
      Specified by:
      getAttribute in interface Session
      Type Parameters:
      T - the return type of the attribute
      Parameters:
      attributeName - the name of the attribute to get
      Returns:
      the Object associated with the specified name or null if no Object is associated to that name
    • getAttributeNames

      public Set<String> getAttributeNames()
      Description copied from interface: Session
      Gets the attribute names that have a value associated with it. Each value can be passed into Session.getAttribute(String) to obtain the attribute value.
      Specified by:
      getAttributeNames in interface Session
      Returns:
      the attribute names that have a value associated with it.
      See Also:
    • setAttribute

      public void setAttribute(String attributeName, Object attributeValue)
      Description copied from interface: Session
      Sets the attribute value for the provided attribute name. If the attributeValue is null, it has the same result as removing the attribute with Session.removeAttribute(String) .
      Specified by:
      setAttribute in interface Session
      Parameters:
      attributeName - the attribute name to set
      attributeValue - the value of the attribute to set. If null, the attribute will be removed.
    • removeAttribute

      public void removeAttribute(String attributeName)
      Description copied from interface: Session
      Removes the attribute with the provided attribute name.
      Specified by:
      removeAttribute in interface Session
      Parameters:
      attributeName - the name of the attribute to remove
    • getCreationTime

      public Instant getCreationTime()
      Description copied from interface: Session
      Gets the time when this session was created.
      Specified by:
      getCreationTime in interface Session
      Returns:
      the time when this session was created.
    • setCreationTime

      public void setCreationTime(long created)
    • getLastAccessedTime

      public Instant getLastAccessedTime()
      Description copied from interface: Session
      Gets the last time this Session was accessed.
      Specified by:
      getLastAccessedTime in interface Session
      Returns:
      the last time the client sent a request associated with the session
    • setLastAccessedTime

      public void setLastAccessedTime(Instant lastAccessedTime)
      Description copied from interface: Session
      Sets the last accessed time.
      Specified by:
      setLastAccessedTime in interface Session
      Parameters:
      lastAccessedTime - the last accessed time
    • getMaxInactiveInterval

      public Duration getMaxInactiveInterval()
      Description copied from interface: Session
      Gets the maximum inactive interval between requests before this session will be invalidated. A negative time indicates that the session will never timeout.
      Specified by:
      getMaxInactiveInterval in interface Session
      Returns:
      the maximum inactive interval between requests before this session will be invalidated. A negative time indicates that the session will never timeout.
    • setMaxInactiveInterval

      public void setMaxInactiveInterval(Duration interval)
      Description copied from interface: Session
      Sets the maximum inactive interval between requests before this session will be invalidated. A negative time indicates that the session will never timeout.
      Specified by:
      setMaxInactiveInterval in interface Session
      Parameters:
      interval - the amount of time that the Session should be kept alive between client requests.
    • isExpired

      public boolean isExpired()
      Description copied from interface: Session
      Returns true if the session is expired.
      Specified by:
      isExpired in interface Session
      Returns:
      true if the session is expired, else false.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getId

      public String getId()
      Description copied from interface: Session
      Gets a unique string that identifies the Session.
      Specified by:
      getId in interface Session
      Returns:
      a unique string that identifies the Session
    • getExpireAt

      public Date getExpireAt()
    • setExpireAt

      public void setExpireAt(Date expireAt)