类 MapSession

所有已实现的接口:
WebSession, Serializable

public class MapSession extends AbstractWebSession implements WebSession, Serializable

A WebSession implementation that is backed by a Map. The defaults for the properties are:

  • id - a secure random generated id
  • creationTime - the moment the MapSession was instantiated
  • lastAccessTime - the moment the MapSession was instantiated
  • maxIdleTime - 30 minutes

This implementation has no synchronization, so it is best to use the copy constructor when working on multiple threads.

从以下版本开始:
4.0 2022/5/10 15:52
作者:
Harry Yang
另请参阅:
  • 字段详细资料

    • serialVersionUID

      private static final long serialVersionUID
      另请参阅:
    • DEFAULT_MAX_INACTIVE_INTERVAL_SECONDS

      public static final int DEFAULT_MAX_INACTIVE_INTERVAL_SECONDS
      Default setMaxIdleTime(Duration) (30 minutes).
      另请参阅:
    • id

      private String id
    • originalId

      private final String originalId
    • creationTime

      private Instant creationTime
    • lastAccessTime

      private Instant lastAccessTime
    • maxIdleTime

      private Duration maxIdleTime
      Defaults to 30 minutes.
  • 构造器详细资料

    • MapSession

      public MapSession()
      Creates a new instance with a secure randomly generated identifier.
    • MapSession

      public MapSession(String id)
      Creates a new instance with the specified id. This is preferred to the default constructor when the id is known to prevent unnecessary consumption on entropy which can be slow.
      参数:
      id - the identifier to use
    • MapSession

      public MapSession(String id, SessionEventDispatcher eventDispatcher)
    • MapSession

      public MapSession(WebSession session)
      Creates a new instance from the provided WebSession.
      参数:
      session - the WebSession to initialize this WebSession with. Cannot be null.
  • 方法详细资料

    • getEventDispatcher

      static SessionEventDispatcher getEventDispatcher(WebSession session)
    • getId

      public String getId()
      从接口复制的说明: WebSession
      returns this session's id
      指定者:
      getId 在接口中 WebSession
    • getOriginalId

      public String getOriginalId()
      Get the original session id.
      返回:
      the original session id
      另请参阅:
    • start

      public void start()
      从接口复制的说明: WebSession
      Force the creation of a session causing the session id to be sent when WebSession.save() is called.
      指定者:
      start 在接口中 WebSession
    • isStarted

      public boolean isStarted()
      从接口复制的说明: WebSession
      Whether a session with the client has been started explicitly via WebSession.start() or implicitly by adding session attributes. If "false" then the session id is not sent to the client and the WebSession.save() method is essentially a no-op.
      指定者:
      isStarted 在接口中 WebSession
    • changeSessionId

      public void changeSessionId()
      从接口复制的说明: WebSession
      Generate a new id for the session and update the underlying session storage to reflect the new id. After a successful call WebSession.getId() reflects the new session id.
      指定者:
      changeSessionId 在接口中 WebSession
    • save

      public void save()
      从接口复制的说明: WebSession
      Save the session through the SessionRepository as follows:
      • If the session is new (i.e. created but never persisted), it must have been started explicitly via WebSession.start() or implicitly by adding attributes, or otherwise this method should have no effect.
      • If the session was retrieved through the WebSessionStore, the implementation for this method must check whether the session was invalidated and if so return an error.

      Note that this method is not intended for direct use by applications. Instead it is automatically invoked just before the response is committed.

      指定者:
      save 在接口中 WebSession
    • doInvalidate

      protected void doInvalidate()
      覆盖:
      doInvalidate 在类中 AbstractWebSession
    • isExpired

      public boolean isExpired()
      从接口复制的说明: WebSession
      Return true if the session expired after maxIdleTime elapsed.

      Typically expiration checks should be automatically made when a session is accessed, a new WebSession instance created if necessary, at the start of request processing so that applications don't have to worry about expired session by default.

      指定者:
      isExpired 在接口中 WebSession
    • isExpired

      boolean isExpired(Instant now)
    • getCreationTime

      public Instant getCreationTime()
      从接口复制的说明: WebSession
      Return the time when the session was created.
      指定者:
      getCreationTime 在接口中 WebSession
    • getLastAccessTime

      public Instant getLastAccessTime()
      从接口复制的说明: WebSession
      Return the last time of session access as a result of user activity such as an HTTP request. Together with maxIdleTimeInSeconds this helps to determine when a session is expired.
      指定者:
      getLastAccessTime 在接口中 WebSession
    • setLastAccessTime

      public void setLastAccessTime(Instant lastAccessTime)
      从接口复制的说明: WebSession
      Sets the last accessed time.
      指定者:
      setLastAccessTime 在接口中 WebSession
      参数:
      lastAccessTime - the last accessed time
    • setMaxIdleTime

      public void setMaxIdleTime(Duration maxIdleTime)
      从接口复制的说明: WebSession
      Configure the max amount of time that may elapse after the lastAccessTime before a session is considered expired. A negative value indicates the session should not expire.
      指定者:
      setMaxIdleTime 在接口中 WebSession
    • getMaxIdleTime

      public Duration getMaxIdleTime()
      从接口复制的说明: WebSession
      Return the maximum time after the lastAccessTime before a session expires. A negative time indicates the session doesn't expire.
      指定者:
      getMaxIdleTime 在接口中 WebSession
    • setCreationTime

      public void setCreationTime(Instant creationTime)
      Sets the time that this WebSession was created. The default is when the WebSession was instantiated.
      参数:
      creationTime - the time that this WebSession was created.
    • setId

      public void setId(String id)
      Sets the identifier for this WebSession. The id should be a secure random generated value to prevent malicious users from guessing this value. The default is a secure random generated identifier.
      参数:
      id - the identifier for this session.
    • equals

      public boolean equals(Object obj)
      覆盖:
      equals 在类中 Object
    • hashCode

      public int hashCode()
      覆盖:
      hashCode 在类中 AbstractWebSession
    • generateId

      private static String generateId()