public class DefaultWebSessionManager extends java.lang.Object implements WebSessionManager
WebSessionManager
with a cookie-based web
session id resolution strategy and simple in-memory session persistence.Modifier and Type | Field and Description |
---|---|
private java.time.Clock |
clock |
private WebSessionIdResolver |
sessionIdResolver |
private WebSessionStore |
sessionStore |
Constructor and Description |
---|
DefaultWebSessionManager() |
Modifier and Type | Method and Description |
---|---|
protected <any> |
createSession(ServerWebExchange exchange) |
protected WebSession |
extendSession(ServerWebExchange exchange,
WebSession session) |
java.time.Clock |
getClock()
Return the configured clock for access to current time.
|
<any> |
getSession(ServerWebExchange exchange)
Return the
WebSession for the given exchange. |
WebSessionIdResolver |
getSessionIdResolver()
Return the configured
WebSessionIdResolver . |
WebSessionStore |
getSessionStore()
Return the configured
WebSessionStore . |
protected <any> |
saveSession(ServerWebExchange exchange,
WebSession session) |
void |
setClock(java.time.Clock clock)
Configure the
Clock for access to current time. |
void |
setSessionIdResolver(WebSessionIdResolver sessionIdResolver)
Configure the session id resolution strategy to use.
|
void |
setSessionStore(WebSessionStore sessionStore)
Configure the session persistence strategy to use.
|
protected <any> |
validateSession(ServerWebExchange exchange,
WebSession session) |
private WebSessionIdResolver sessionIdResolver
private WebSessionStore sessionStore
private java.time.Clock clock
public void setSessionIdResolver(WebSessionIdResolver sessionIdResolver)
By default CookieWebSessionIdResolver
is used.
sessionIdResolver
- the resolverpublic WebSessionIdResolver getSessionIdResolver()
WebSessionIdResolver
.public void setSessionStore(WebSessionStore sessionStore)
By default InMemoryWebSessionStore
is used.
sessionStore
- the persistence strategypublic WebSessionStore getSessionStore()
WebSessionStore
.public void setClock(java.time.Clock clock)
Clock
for access to current time. During tests you
may use {code Clock.offset(clock, Duration.ofMinutes(-31))} to set the
clock back for example to test changes after sessions expire.
By default Clock.systemDefaultZone()
is used.
clock
- the clock to usepublic java.time.Clock getClock()
public <any> getSession(ServerWebExchange exchange)
WebSessionManager
WebSession
for the given exchange. Always guaranteed
to return an instance either matching to the session id requested by the
client, or with a new session id either because the client did not
specify one or because the underlying session had expired.getSession
in interface WebSessionManager
exchange
- the current exchangeMono
for async access to the sessionprotected <any> validateSession(ServerWebExchange exchange, WebSession session)
protected <any> createSession(ServerWebExchange exchange)
protected WebSession extendSession(ServerWebExchange exchange, WebSession session)
protected <any> saveSession(ServerWebExchange exchange, WebSession session)