类 MockWebSession
- java.lang.Object
- org.springframework.mock.web.server.MockWebSession
- 所有已实现的接口:
WebSession
public class MockWebSession extends Object implements WebSession
Implementation ofWebSession
that delegates to a session instance obtained viaInMemoryWebSessionStore
.This is intended for use with the
session(WebSession)
method of theMockServerWebExchange
builder, eliminating the need to useWebSessionManager
orWebSessionStore
altogether.- 从以下版本开始:
- 5.1
- 作者:
- Rossen Stoyanchev
构造器概要
构造器 构造器 说明 MockWebSession()
MockWebSession(Clock clock)
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 reactor.core.publisher.Mono<Void>
changeSessionId()
Generate a new id for the session and update the underlying session storage to reflect the new id.Map<String,Object>
getAttributes()
Return a map that holds session attributes.Instant
getCreationTime()
Return the time when the session was created.String
getId()
Return a unique session identifier.Instant
getLastAccessTime()
Return the last time of session access as a result of user activity such as an HTTP request.Duration
getMaxIdleTime()
Return the maximum time after thelastAccessTime
before a session expires.reactor.core.publisher.Mono<Void>
invalidate()
Invalidate the current session and clear session storage.boolean
isExpired()
Returntrue
if the session expired aftermaxIdleTime
elapsed.boolean
isStarted()
Whether a session with the client has been started explicitly viaWebSession.start()
or implicitly by adding session attributes.reactor.core.publisher.Mono<Void>
save()
Save the session through theWebSessionStore
as 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.void
setMaxIdleTime(Duration maxIdleTime)
Configure the max amount of time that may elapse after thelastAccessTime
before a session is considered expired.void
start()
Force the creation of a session causing the session id to be sent whenWebSession.save()
is called.从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
从接口继承的方法 org.springframework.web.server.WebSession
getAttribute, getAttributeOrDefault, getRequiredAttribute
构造器详细资料
MockWebSession
public MockWebSession()
MockWebSession
public MockWebSession(@Nullable Clock clock)
方法详细资料
getId
public String getId()
从接口复制的说明:WebSession
Return a unique session identifier.- 指定者:
getId
在接口中WebSession
getAttributes
public Map<String,Object> getAttributes()
从接口复制的说明:WebSession
Return a map that holds session attributes.- 指定者:
getAttributes
在接口中WebSession
start
public void start()
从接口复制的说明:WebSession
Force the creation of a session causing the session id to be sent whenWebSession.save()
is called.- 指定者:
start
在接口中WebSession
isStarted
public boolean isStarted()
从接口复制的说明:WebSession
Whether 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 reactor.core.publisher.Mono<Void> changeSessionId()
从接口复制的说明:WebSession
Generate 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
- 返回:
- completion notification (success or error)
invalidate
public reactor.core.publisher.Mono<Void> invalidate()
从接口复制的说明:WebSession
Invalidate the current session and clear session storage.- 指定者:
invalidate
在接口中WebSession
- 返回:
- completion notification (success or error)
save
public reactor.core.publisher.Mono<Void> save()
从接口复制的说明:WebSession
Save the session through theWebSessionStore
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 wasinvalidated
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
- 返回:
Mono
to indicate completion with success or error
- If the session is new (i.e. created but never persisted), it must have been started explicitly via
isExpired
public boolean isExpired()
从接口复制的说明:WebSession
Returntrue
if the session expired aftermaxIdleTime
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
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 withmaxIdleTimeInSeconds
this helps to determine when a session isexpired
.- 指定者:
getLastAccessTime
在接口中WebSession
setMaxIdleTime
public void setMaxIdleTime(Duration maxIdleTime)
从接口复制的说明:WebSession
Configure the max amount of time that may elapse after thelastAccessTime
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 thelastAccessTime
before a session expires. A negative time indicates the session doesn't expire.- 指定者:
getMaxIdleTime
在接口中WebSession