Class AbstractSessionAwareRequestHandler
- Direct Known Subclasses:
AbstractSessionAwareFilter
,AbstractSessionAwareInterceptor
This base class is able to intercept HandlerMethod
handlers which have the session ID as a
RequestParam
or PathVariable
that is also annotated with AquimaSessionId
.
This class gives the following interpretation to FlushMode.AUTO:
- a POST, PUT, PATCH or DELETE request is an intent to modify - FlushMode.ALWAYS is used
- for all other request methods, FlushMode.NEVER is used
However, the actual flush mode may be influenced by prior interceptors/filters that also inherit from this base
class, as well as by the annotations on the target controller. See
getSession(HttpServletRequest, Object, FlushMode)
for more details.
- Since:
- 12.1
- Author:
- Petru Galanton
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractSessionAwareRequestHandler
(com.blueriq.component.api.IAquimaSessionsMap sessionManager) -
Method Summary
Modifier and TypeMethodDescriptionfinal com.blueriq.component.api.FlushMode
extractEffectiveFlushMode
(jakarta.servlet.http.HttpServletRequest request, com.blueriq.component.api.annotation.AquimaSessionId aquimaSessionId, com.blueriq.component.api.FlushMode interceptorFlushMode) final String
extractSessionId
(jakarta.servlet.http.HttpServletRequest request, org.springframework.core.MethodParameter parameter, com.blueriq.component.api.annotation.AquimaSessionId annotation) Extracts the session ID from the request.final com.blueriq.component.api.IAquimaSession
getSession
(jakarta.servlet.http.HttpServletRequest request, Object handler) Same asgetSession(HttpServletRequest, Object, FlushMode)
withFlushMode.AUTO
.final com.blueriq.component.api.IAquimaSession
getSession
(jakarta.servlet.http.HttpServletRequest request, Object handler, com.blueriq.component.api.FlushMode flushMode) Returns the AquimaSession for this request.final com.blueriq.component.api.IAquimaSessionsMap
-
Constructor Details
-
Method Details
-
getSessionManager
public final com.blueriq.component.api.IAquimaSessionsMap getSessionManager() -
getSession
public final com.blueriq.component.api.IAquimaSession getSession(jakarta.servlet.http.HttpServletRequest request, Object handler) Same asgetSession(HttpServletRequest, Object, FlushMode)
withFlushMode.AUTO
. The flush mode is automatically determined from the annotations of the target controller and the request method.- Parameters:
request
- the HTTP requesthandler
- the Spring handler- Returns:
- the AquimaSession corresponding to the request or null
-
getSession
public final com.blueriq.component.api.IAquimaSession getSession(jakarta.servlet.http.HttpServletRequest request, Object handler, com.blueriq.component.api.FlushMode flushMode) Returns the AquimaSession for this request.The session is obtained from the session manager using a flush mode with a priority equal or higher than the provided flush mode. For example:
- if the controller declares FlushMode.ALWAYS and this method is called with FlushMode.NEVER, the session is obtained using FlushMode.ALWAYS
- if the controller declares FlushMode.NEVER and this method is called with FlushMode.ALWAYS, the session is obtained using FlushMode.ALWAYS
- if neither the controller or the interceptor provide a flush mode (i.e. they use the implicit FlushMode.AUTO), the effective flush mode is determined based on the HTTP request method: POST, PUT, PATCH and DELETE imply intent to modify the session, so FlushMode.ALWAYS is used. Otherwise, FlushMode.NEVER is used.
The identified session is cached as a request attribute. When multiple subclasses intercept the same request, only the first interceptor has to inspect the controller, as long as the FlushMode used by the interceptor has equal or lower precendence than the FlushMode used to obtain the session. When the FlushMode requested by an interceptor has higher precendence than a previously used FlushMode, the session is obtained again from the session manager using the new, higher precendence FlushMode.
- Parameters:
request
- the HTTP requesthandler
- the Spring handlerflushMode
- the intent for the requested session- Returns:
- the AquimaSession corresponding to the request or null
-
extractSessionId
public final String extractSessionId(jakarta.servlet.http.HttpServletRequest request, org.springframework.core.MethodParameter parameter, com.blueriq.component.api.annotation.AquimaSessionId annotation) Extracts the session ID from the request.- Parameters:
request
- the HTTP requestparameter
- the parameter of a controller methodannotation
- the annotation that contains the named parameter value- Returns:
- the session ID or null if the session ID could not be extracted
-
extractEffectiveFlushMode
public final com.blueriq.component.api.FlushMode extractEffectiveFlushMode(jakarta.servlet.http.HttpServletRequest request, com.blueriq.component.api.annotation.AquimaSessionId aquimaSessionId, com.blueriq.component.api.FlushMode interceptorFlushMode)
-