Class RequestIdMdcFilter
- All Implemented Interfaces:
jakarta.servlet.Filter, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean, org.springframework.context.EnvironmentAware, org.springframework.core.env.EnvironmentCapable, org.springframework.web.context.ServletContextAware
requestId— the inboundX-Request-Idheader if present, otherwise a freshly generated UUID. Echoed back on the response.userId— the authenticated principal name fromSecurityContextHolder, or"anonymous"when no authentication is in scope.
This is the gemma-rest module's counterpart to
ubic.gemma.web.logging.RequestIdMdcFilter (gemma-web). The two classes are deliberately
separate because gemma-rest does not depend on gemma-web. When running inside gemma-web's WAR,
the gemma-web copy is registered in gemma-web/WEB-INF/web.xml and is the one that fires
for Jersey requests (Jersey is mounted under the same web.xml). When gemma-rest is built as a
standalone WAR (the gemma-rest-war profile of GEMMA_REST_STANDALONE_ROADMAP.md),
this copy is the one registered in gemma-rest/WEB-INF/web.xml.
See LOGGING_MODERNIZATION_RECCE.md §3 Phase 2 for context. ThreadContext propagation
across async executors is already handled by the DelegatingThreadContext* layer in
ubic.gemma.core.logging.log4j.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final StringFields inherited from class org.springframework.web.filter.OncePerRequestFilter
ALREADY_FILTERED_SUFFIXFields inherited from class org.springframework.web.filter.GenericFilterBean
logger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoFilterInternal(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, jakarta.servlet.FilterChain filterChain) Methods inherited from class org.springframework.web.filter.OncePerRequestFilter
doFilter, doFilterNestedErrorDispatch, getAlreadyFilteredAttributeName, isAsyncDispatch, isAsyncStarted, shouldNotFilter, shouldNotFilterAsyncDispatch, shouldNotFilterErrorDispatchMethods inherited from class org.springframework.web.filter.GenericFilterBean
addRequiredProperty, afterPropertiesSet, createEnvironment, destroy, getEnvironment, getFilterConfig, getFilterName, getServletContext, init, initBeanWrapper, initFilterBean, setBeanName, setEnvironment, setServletContext
-
Field Details
-
REQUEST_ID_HEADER
- See Also:
-
REQUEST_ID_MDC_KEY
- See Also:
-
USER_ID_MDC_KEY
- See Also:
-
ANONYMOUS_USER
- See Also:
-
-
Constructor Details
-
RequestIdMdcFilter
public RequestIdMdcFilter()
-
-
Method Details
-
doFilterInternal
protected void doFilterInternal(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, jakarta.servlet.FilterChain filterChain) throws jakarta.servlet.ServletException, IOException - Specified by:
doFilterInternalin classorg.springframework.web.filter.OncePerRequestFilter- Throws:
jakarta.servlet.ServletExceptionIOException
-