Class DynamicServletWrapper

java.lang.Object
de.aristaflow.adept2.base.servletcontainer.DynamicServletWrapper
All Implemented Interfaces:
DynamicServlet, jakarta.servlet.Servlet

public class DynamicServletWrapper extends Object implements DynamicServlet
A simple wrapper to provide DynamicServlet for a HttpServlet. This class forwards all calls, the name can be overridden, notifications for a servlet being (un)deployed are ignored.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final jakarta.servlet.http.HttpServlet
    The wrapped servlet.
    protected String
    The name of the servlet or null in case it should be retrieved from the wrapped servlet.
  • Constructor Summary

    Constructors
    Constructor
    Description
    DynamicServletWrapper(String servletName, jakarta.servlet.http.HttpServlet servlet)
    Creates a new wrapper for the designated servlet.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    jakarta.servlet.ServletConfig
     
     
    Gets the name of the servlet.
    void
    init(jakarta.servlet.ServletConfig config)
     
    void
    service(jakarta.servlet.ServletRequest req, jakarta.servlet.ServletResponse res)
     
    void
    servletDeployed(jakarta.servlet.ServletContext context, Collection<String> urlPatterns)
    Notifies the servlet that it has been deployed with the designated context and the designated patterns.
    void
    servletUndeployed(jakarta.servlet.ServletContext context)
    Notifies the servlet that it has been undeployed.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • servletName

      protected String servletName
      The name of the servlet or null in case it should be retrieved from the wrapped servlet.
    • servlet

      protected final jakarta.servlet.http.HttpServlet servlet
      The wrapped servlet.
  • Constructor Details

    • DynamicServletWrapper

      public DynamicServletWrapper(String servletName, jakarta.servlet.http.HttpServlet servlet)
      Creates a new wrapper for the designated servlet.
      Parameters:
      servletName - The name of the servlet or null in case it should be retrieved from the designated servlet.
      servlet - The wrapped servlet.
  • 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
    • getServletName

      public String getServletName()
      Description copied from interface: DynamicServlet
      Gets the name of the servlet. Note that usually the servlet implementations rely on the servlet configuration to provide a name. However, when using a DynamicServlet, the servlet name has to be provided explicitly.
      Specified by:
      getServletName in interface DynamicServlet
      Returns:
      The name of the servlet.
    • servletDeployed

      public void servletDeployed(jakarta.servlet.ServletContext context, Collection<String> urlPatterns)
      Description copied from interface: DynamicServlet
      Notifies the servlet that it has been deployed with the designated context and the designated patterns. Note that the servlet usually will not have been initialised yet.
      Specified by:
      servletDeployed in interface DynamicServlet
      Parameters:
      context - The servlet context of this servlet.
      urlPatterns - The URL patterns (mapping) this servlet has been deployed with.
    • servletUndeployed

      public void servletUndeployed(jakarta.servlet.ServletContext context)
      Description copied from interface: DynamicServlet
      Notifies the servlet that it has been undeployed.
      Specified by:
      servletUndeployed in interface DynamicServlet
      Parameters:
      context - The servlet context of this servlet.