Class MdcAwareServletWrapper
java.lang.Object
com.wavemaker.runtime.web.servlet.MdcAwareServletWrapper
- All Implemented Interfaces:
jakarta.servlet.Servlet
A load-on-startup servlet's init() is called by the container after all ServletContextListeners
have returned, so it runs outside any listener's or filter's wm.app.name MDC scope and its logs
would otherwise go unattributed (missing from the per-app log file). This wrapper sets wm.app.name
around delegate.init() without needing to modify the delegate servlet's own source (needed since
DispatcherServlet is a third-party class).
The same gap exists in reverse on undeploy: the container calls servlet destroy() before running
any listener's contextDestroyed(), so destroy() is wrapped the same way, using the context path
captured at init() time since destroy() isn't given a ServletConfig.
-
Constructor Details
-
MdcAwareServletWrapper
public MdcAwareServletWrapper(jakarta.servlet.Servlet delegate)
-
-
Method Details
-
init
public void init(jakarta.servlet.ServletConfig config) throws jakarta.servlet.ServletException - Specified by:
initin interfacejakarta.servlet.Servlet- Throws:
jakarta.servlet.ServletException
-
getServletConfig
public jakarta.servlet.ServletConfig getServletConfig()- Specified by:
getServletConfigin interfacejakarta.servlet.Servlet
-
service
public void service(jakarta.servlet.ServletRequest req, jakarta.servlet.ServletResponse res) throws jakarta.servlet.ServletException, IOException - Specified by:
servicein interfacejakarta.servlet.Servlet- Throws:
jakarta.servlet.ServletExceptionIOException
-
getServletInfo
- Specified by:
getServletInfoin interfacejakarta.servlet.Servlet
-
destroy
public void destroy()- Specified by:
destroyin interfacejakarta.servlet.Servlet
-