类 MapSession
java.lang.Object
cn.taketoday.session.AbstractWebSession
cn.taketoday.session.MapSession
- 所有已实现的接口:
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
MapSessionwas instantiated - lastAccessTime - the moment the
MapSessionwas 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
- 另请参阅:
-
字段概要
字段修饰符和类型字段说明private Instantstatic final intDefaultsetMaxIdleTime(Duration)(30 minutes).private Stringprivate Instantprivate DurationDefaults to 30 minutes.private final Stringprivate static final long从类继承的字段 cn.taketoday.session.AbstractWebSession
attributes, eventDispatcher -
构造器概要
构造器构造器说明Creates a new instance with a secure randomly generated identifier.MapSession(WebSession session) Creates a new instance from the providedWebSession.MapSession(String id) Creates a new instance with the specified id.MapSession(String id, SessionEventDispatcher eventDispatcher) -
方法概要
修饰符和类型方法说明voidGenerate a new id for the session and update the underlying session storage to reflect the new id.protected voidbooleanprivate static StringReturn the time when the session was created.(专用程序包) static SessionEventDispatchergetEventDispatcher(WebSession session) getId()returns this session's idReturn the last time of session access as a result of user activity such as an HTTP request.Return the maximum time after thelastAccessTimebefore a session expires.Get the original session id.inthashCode()booleanReturntrueif the session expired aftermaxIdleTimeelapsed.(专用程序包) booleanbooleanWhether a session with the client has been started explicitly viaWebSession.start()or implicitly by adding session attributes.voidsave()Save the session through theSessionRepositoryas follows: If the session is new (i.e. created but never persisted), it must have been started explicitly viaWebSession.start()or implicitly by adding attributes, or otherwise this method should have no effect.voidsetCreationTime(Instant creationTime) Sets the time that thisWebSessionwas created.voidSets the identifier for thisWebSession.voidsetLastAccessTime(Instant lastAccessTime) Sets the last accessed time.voidsetMaxIdleTime(Duration maxIdleTime) Configure the max amount of time that may elapse after thelastAccessTimebefore a session is considered expired.voidstart()Force the creation of a session causing the session id to be sent whenWebSession.save()is called.从类继承的方法 cn.taketoday.session.AbstractWebSession
allowAttributeReplaced, attributeAdded, attributeBinding, attributeNames, attributeRemoved, attributeReplaced, copyAttributesFrom, createAttributes, getAttribute, getAttributeNames, getAttributes, hasAttribute, hasAttributes, invalidate, removeAttribute, setAttribute从接口继承的方法 cn.taketoday.session.WebSession
attributeNames, getAttribute, getAttributeNames, getAttributes, hasAttribute, hasAttributes, invalidate, removeAttribute, setAttribute
-
字段详细资料
-
serialVersionUID
private static final long serialVersionUID- 另请参阅:
-
DEFAULT_MAX_INACTIVE_INTERVAL_SECONDS
public static final int DEFAULT_MAX_INACTIVE_INTERVAL_SECONDSDefaultsetMaxIdleTime(Duration)(30 minutes).- 另请参阅:
-
id
-
originalId
-
creationTime
-
lastAccessTime
-
maxIdleTime
Defaults to 30 minutes.
-
-
构造器详细资料
-
MapSession
public MapSession()Creates a new instance with a secure randomly generated identifier. -
MapSession
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
-
MapSession
Creates a new instance from the providedWebSession.- 参数:
session- theWebSessionto initialize thisWebSessionwith. Cannot be null.
-
-
方法详细资料
-
getEventDispatcher
-
getId
从接口复制的说明:WebSessionreturns this session's id- 指定者:
getId在接口中WebSession
-
getOriginalId
Get the original session id.- 返回:
- the original session id
- 另请参阅:
-
start
public void start()从接口复制的说明:WebSessionForce the creation of a session causing the session id to be sent whenWebSession.save()is called.- 指定者:
start在接口中WebSession
-
isStarted
public boolean isStarted()从接口复制的说明:WebSessionWhether a session with the client has been started explicitly viaWebSession.start()or implicitly by adding session attributes. If "false" then the session id is not sent to the client and theWebSession.save()method is essentially a no-op.- 指定者:
isStarted在接口中WebSession
-
changeSessionId
public void changeSessionId()从接口复制的说明:WebSessionGenerate a new id for the session and update the underlying session storage to reflect the new id. After a successful callWebSession.getId()reflects the new session id.- 指定者:
changeSessionId在接口中WebSession
-
save
public void save()从接口复制的说明:WebSessionSave the session through theSessionRepositoryas 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 wasinvalidatedand 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
- If the session is new (i.e. created but never persisted), it must have
been started explicitly via
-
doInvalidate
protected void doInvalidate()- 覆盖:
doInvalidate在类中AbstractWebSession
-
isExpired
public boolean isExpired()从接口复制的说明:WebSessionReturntrueif the session expired aftermaxIdleTimeelapsed.Typically expiration checks should be automatically made when a session is accessed, a new
WebSessioninstance 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
-
getCreationTime
从接口复制的说明:WebSessionReturn the time when the session was created.- 指定者:
getCreationTime在接口中WebSession
-
getLastAccessTime
从接口复制的说明:WebSessionReturn the last time of session access as a result of user activity such as an HTTP request. Together withmaxIdleTimeInSecondsthis helps to determine when a session isexpired.- 指定者:
getLastAccessTime在接口中WebSession
-
setLastAccessTime
从接口复制的说明:WebSessionSets the last accessed time.- 指定者:
setLastAccessTime在接口中WebSession- 参数:
lastAccessTime- the last accessed time
-
setMaxIdleTime
从接口复制的说明:WebSessionConfigure the max amount of time that may elapse after thelastAccessTimebefore a session is considered expired. A negative value indicates the session should not expire.- 指定者:
setMaxIdleTime在接口中WebSession
-
getMaxIdleTime
从接口复制的说明:WebSessionReturn the maximum time after thelastAccessTimebefore a session expires. A negative time indicates the session doesn't expire.- 指定者:
getMaxIdleTime在接口中WebSession
-
setCreationTime
Sets the time that thisWebSessionwas created. The default is when theWebSessionwas instantiated.- 参数:
creationTime- the time that thisWebSessionwas created.
-
setId
Sets the identifier for thisWebSession. 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
-
hashCode
public int hashCode()- 覆盖:
hashCode在类中AbstractWebSession
-
generateId
-