Interface SessionContext<A,B extends Session<A>>
- Type Parameters:
A- the session data typeB- the session type
- All Superinterfaces:
ExchangeContext
- All Known Subinterfaces:
BasicSessionContext<A>,BasicSessionContext.Intercepted<A>,BasicSessionSecurityContext<A,,B, C, D> BasicSessionSecurityContext.Intercepted<A,,B, C, D> JWTSessionContext<A,,B> JWTSessionContext.Intercepted<A,,B> JWTSessionSecurityContext<A,,B, C, D> JWTSessionSecurityContext.Intercepted<A,,B, C, D> SessionContext.Intercepted<A,B>
The general session context which exposes the session in the exchange context.
A session may or may not exist when a request is received, isSessionPresent() can be used to determine whether a session is present in the context, in any case getSession()
returns either the existing session or creates a new one.
getSessionData() and getSessionData(Supplier) are shortcuts for accessing session data which can be created on the fly when missing using the provided supplier.
- Since:
- 1.13
- Author:
- Jeremy Kuhn
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceSessionContext.Intercepted<A,B extends Session<A>> An intercepted session context used by the session interceptor to populate the session context. -
Method Summary
Modifier and TypeMethodDescriptionResolves or creates the session.Resolves the session data.getSessionData(Supplier<A> supplier) Resolves the session data or creates them using the specified supplier if none exist in the session.booleanDetermines whether a session is present in the context.Methods inherited from interface io.inverno.mod.http.base.ExchangeContext
init
-
Method Details
-
isSessionPresent
boolean isSessionPresent()Determines whether a session is present in the context.
- Returns:
- true if a session is present, false otherwise
-
getSession
Resolves or creates the session.
- Returns:
- a mono emitting the existing session if one has been resolved from the request or a mono emitting a new session
-
getSessionData
Resolves the session data.
This is a shortcut for
context.getSession().flatMap(Session::getData)and as a result a new session is created when if none is present- Returns:
- a mono resolving session data or an empty mono if none exist in the session
-
getSessionData
Resolves the session data or creates them using the specified supplier if none exist in the session.
This is a shortcut for
context.getSession().flatMap(session -> session.getData(supplier))and as a result a new session is created when if none is present.- Parameters:
supplier- a session data supplier- Returns:
- a mono resolving or creating session data
-