Class MetaServlet

  • All Implemented Interfaces:
    java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
    Direct Known Subclasses:
    GitServlet

    public class MetaServlet
    extends javax.servlet.http.HttpServlet
    Generic container servlet to manage routing to different pipelines.

    Callers can create and configure a new processing pipeline by using one of the serve(String) or serveRegex(String) methods to allocate a binder for a particular URL pattern.

    Registered filters and servlets are initialized lazily, usually during the first request. Once initialized the bindings in this servlet cannot be modified without destroying the servlet and thereby destroying all registered filters and servlets.

    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
        MetaServlet()
      Empty servlet with no bindings.
      protected MetaServlet​(MetaFilter delegateFilter)
      Initialize a servlet wrapping a filter.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void destroy()
      protected MetaFilter getDelegateFilter()
      Get delegate filter
      void init​(javax.servlet.ServletConfig config)
      protected ServletBinder register​(ServletBinder b)
      Configure a newly created binder.
      ServletBinder serve​(java.lang.String path)
      Construct a binding for a specific path.
      ServletBinder serveRegex​(java.lang.String expression)
      Construct a binding for a regular expression.
      protected void service​(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
      • Methods inherited from class javax.servlet.http.HttpServlet

        doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service
      • Methods inherited from class javax.servlet.GenericServlet

        getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MetaServlet

        public MetaServlet()
        Empty servlet with no bindings.
      • MetaServlet

        protected MetaServlet​(MetaFilter delegateFilter)
        Initialize a servlet wrapping a filter.
        Parameters:
        delegateFilter - the filter being wrapped by the servlet.
    • Method Detail

      • getDelegateFilter

        protected MetaFilter getDelegateFilter()
        Get delegate filter
        Returns:
        filter this servlet delegates all routing logic to.
      • serve

        public ServletBinder serve​(java.lang.String path)
        Construct a binding for a specific path.
        Parameters:
        path - pattern to match.
        Returns:
        binder for the passed path.
      • serveRegex

        public ServletBinder serveRegex​(java.lang.String expression)
        Construct a binding for a regular expression.
        Parameters:
        expression - the regular expression to pattern match the URL against.
        Returns:
        binder for the passed expression.
      • init

        public void init​(javax.servlet.ServletConfig config)
                  throws javax.servlet.ServletException
        Specified by:
        init in interface javax.servlet.Servlet
        Overrides:
        init in class javax.servlet.GenericServlet
        Throws:
        javax.servlet.ServletException
      • destroy

        public void destroy()
        Specified by:
        destroy in interface javax.servlet.Servlet
        Overrides:
        destroy in class javax.servlet.GenericServlet
      • service

        protected void service​(javax.servlet.http.HttpServletRequest req,
                               javax.servlet.http.HttpServletResponse res)
                        throws javax.servlet.ServletException,
                               java.io.IOException
        Overrides:
        service in class javax.servlet.http.HttpServlet
        Throws:
        javax.servlet.ServletException
        java.io.IOException
      • register

        protected ServletBinder register​(ServletBinder b)
        Configure a newly created binder.
        Parameters:
        b - the newly created binder.
        Returns:
        binder for the caller, potentially after adding one or more filters into the pipeline.