Class MdcAwareServletWrapper

java.lang.Object
com.wavemaker.runtime.web.servlet.MdcAwareServletWrapper
All Implemented Interfaces:
jakarta.servlet.Servlet

public class MdcAwareServletWrapper extends Object implements 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:
      init in interface jakarta.servlet.Servlet
      Throws:
      jakarta.servlet.ServletException
    • getServletConfig

      public jakarta.servlet.ServletConfig getServletConfig()
      Specified by:
      getServletConfig in interface jakarta.servlet.Servlet
    • service

      public void service(jakarta.servlet.ServletRequest req, jakarta.servlet.ServletResponse res) throws jakarta.servlet.ServletException, IOException
      Specified by:
      service in interface jakarta.servlet.Servlet
      Throws:
      jakarta.servlet.ServletException
      IOException
    • getServletInfo

      public String getServletInfo()
      Specified by:
      getServletInfo in interface jakarta.servlet.Servlet
    • destroy

      public void destroy()
      Specified by:
      destroy in interface jakarta.servlet.Servlet