Class TomcatServletManager

    • Constructor Detail

      • TomcatServletManager

        public TomcatServletManager​(java.lang.String contextPath,
                                    InjectionRegistry injectionRegistry,
                                    OfficeExtensionContext sourceContext,
                                    java.lang.String webAppPath)
                             throws java.io.IOException
        Instantiate.
        Parameters:
        contextPath - Context path.
        injectionRegistry - InjectionRegistry.
        sourceContext - OfficeExtensionContext.
        webAppPath - Path to web application (WAR). May be null.
        Throws:
        java.io.IOException - If fails to setup container.
    • Method Detail

      • runInMavenWarProject

        public static <R,​T extends java.lang.Throwable> R runInMavenWarProject​(TomcatServletManager.Operation<R,​T> operation)
                                                                              throws T extends java.lang.Throwable
        Runs the TomcatServletManager.Operation assuming within Maven war project.
        Type Parameters:
        R - Return type.
        T - Possible exception type.
        Parameters:
        operation - TomcatServletManager.Operation.
        Returns:
        Result.
        Throws:
        T - Possible failure.
        T extends java.lang.Throwable
      • isChainServletManager

        public boolean isChainServletManager()
        Indicates if chain in the ServletManager.
        Returns:
        true to chain in the ServletManager.
      • start

        public void start​(AvailableType[] availableTypes)
                   throws java.lang.Exception
        Starts the Servlet container.
        Parameters:
        availableTypes - AvailableType instances.
        Throws:
        java.lang.Exception - If fails to start.
      • stop

        public void stop()
                  throws java.lang.Exception
        Stops the Servlet container.
        Throws:
        java.lang.Exception - If fails to stop.
      • getContext

        public org.apache.catalina.Context getContext()
        Description copied from interface: ServletManager
        Obtains the Context.
        Specified by:
        getContext in interface ServletManager
        Returns:
        Context.
      • addServlet

        public ServletServicer addServlet​(java.lang.String name,
                                          java.lang.Class<? extends javax.servlet.Servlet> servletClass,
                                          java.util.function.Consumer<org.apache.catalina.Wrapper> decorator)
        Description copied from interface: ServletManager
        Adds a Servlet.
        Specified by:
        addServlet in interface ServletManager
        Parameters:
        name - Name of Servlet.
        servletClass - Servlet Class.
        decorator - Decorates the Servlet. May be null.
        Returns:
        ServletServicer.
      • addServlet

        public ServletServicer addServlet​(java.lang.String name,
                                          javax.servlet.Servlet servlet,
                                          boolean isInjectDependencies,
                                          java.util.function.Consumer<org.apache.catalina.Wrapper> decorator)
        Description copied from interface: ServletManager
        Adds a Servlet instance.
        Specified by:
        addServlet in interface ServletManager
        Parameters:
        name - Name of Servlet.
        servlet - Servlet.
        isInjectDependencies - Flags to inject dependencies into the Servlet instance.
        decorator - Decorates the Servlet. May be null.
        Returns:
        ServletServicer.
      • addFilter

        public FilterServicer addFilter​(java.lang.String name,
                                        java.lang.Class<? extends javax.servlet.Filter> filterClass,
                                        java.util.function.Consumer<org.apache.tomcat.util.descriptor.web.FilterDef> decorator)
        Description copied from interface: ServletManager
        Adds a Filter.
        Specified by:
        addFilter in interface ServletManager
        Parameters:
        name - Name of Filter.
        filterClass - Filter Class.
        decorator - Decorates the Filter. May be null.
        Returns:
        FilterServicer.
      • getDependency

        public <T> T getDependency​(java.lang.String qualifier,
                                   java.lang.Class<? extends T> type)
        Description copied from interface: ServletManager

        Obtains a dependency.

        The dependency is via a SupplierThreadLocal that is always available in servicing a Servlet / Filter.

        Specified by:
        getDependency in interface ServletManager
        Type Parameters:
        T - Type of dependency.
        Parameters:
        qualifier - Qualifier. May be null.
        type - Type.
        Returns:
        Dependency.
      • chainInServletManager

        public void chainInServletManager()
        Description copied from interface: ServletManager
        Chains in this ServletManager to service HTTP requests. This allows the backing Servlet container to route requests to the appropriate Filter / Servlet to service the HTTP request.
        Specified by:
        chainInServletManager in interface ServletManager