Class ServletContainerFactory


  • public class ServletContainerFactory
    extends java.lang.Object
    Created by tommackenzie on 4/3/16. A factory that creates a ServletContainer. System.setProperty("org.eclipse.jetty.LEVEL","INFO");
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static org.slf4j.Logger logger  
    • Method Summary

      Modifier and Type Method Description
      protected org.eclipse.jetty.webapp.Configuration[] makeConfigurations()  
      protected org.eclipse.jetty.util.resource.PathResource makeFileResource​(java.net.URI classPath)  
      protected org.eclipse.jetty.server.CustomRequestLog makeRequestLog​(java.lang.String logFile)  
      protected java.lang.String makeResourceBase​(java.net.URI webApp)  
      protected org.eclipse.jetty.server.ServerConnector makeServerConnector​(org.eclipse.jetty.server.Server server, int port)  
      ServletContainer makeServletContainer​(java.lang.String documentRoot, java.lang.Class clazz, int port, java.lang.String requestLog, java.util.List<org.apache.tomcat.util.descriptor.web.ErrorPage> errorPages)  
      ServletContainer makeServletContainer​(java.lang.String documentRoot, java.net.URI webApp, java.net.URI compliedClassPath, int port, java.lang.String requestLog, java.util.List<org.apache.tomcat.util.descriptor.web.ErrorPage> errorPages)  
      protected org.eclipse.jetty.webapp.WebAppContext makeWebAppContext​(java.lang.String documentRoot, java.lang.String resourceBase, org.eclipse.jetty.webapp.Configuration[] configurations, org.eclipse.jetty.util.resource.PathResource containerResources, java.util.List<org.apache.tomcat.util.descriptor.web.ErrorPage> errorPages)  
      protected org.eclipse.jetty.webapp.WebAppContext makeWebAppContextForWAR​(java.lang.String documentRoot, org.eclipse.jetty.webapp.Configuration[] configurations, org.eclipse.jetty.util.resource.Resource war, java.util.List<org.apache.tomcat.util.descriptor.web.ErrorPage> errorPages)  
      • Methods inherited from class java.lang.Object

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

      • logger

        protected static org.slf4j.Logger logger
    • Method Detail

      • makeServletContainer

        public ServletContainer makeServletContainer​(java.lang.String documentRoot,
                                                     java.lang.Class clazz,
                                                     int port,
                                                     java.lang.String requestLog,
                                                     java.util.List<org.apache.tomcat.util.descriptor.web.ErrorPage> errorPages)
                                              throws java.net.URISyntaxException,
                                                     java.io.IOException
        Parameters:
        documentRoot - root path for the servlet container to run. example, "/"
        clazz - a class in your project.
        port - the port the container should use. 0 will randomly assign a port.
        requestLog - path to the request log
        errorPages - a list of ErrorPages
        Returns:
        a configured instance of ServletContainer
        Throws:
        java.net.URISyntaxException - if an issue occurred constructing a URI
        java.io.IOException - if issues come up regarding webapp or containerResources
      • makeServletContainer

        public ServletContainer makeServletContainer​(java.lang.String documentRoot,
                                                     java.net.URI webApp,
                                                     java.net.URI compliedClassPath,
                                                     int port,
                                                     java.lang.String requestLog,
                                                     java.util.List<org.apache.tomcat.util.descriptor.web.ErrorPage> errorPages)
                                              throws java.io.IOException
        Parameters:
        documentRoot - root path for the servlet container to run. example, "/"
        webApp - absolute file path to the webapp directory in your project.
        compliedClassPath - absolute file path to, target/classes/ in your project.
        port - the port the container should use. 0 will randomly assign a port.
        requestLog - path to the request log
        errorPages - a list of ErrorPages
        Returns:
        a configured instance of ServletContainer
        Throws:
        java.io.IOException - if issues come up regarding webapp or containerResources
      • makeWebAppContext

        protected org.eclipse.jetty.webapp.WebAppContext makeWebAppContext​(java.lang.String documentRoot,
                                                                           java.lang.String resourceBase,
                                                                           org.eclipse.jetty.webapp.Configuration[] configurations,
                                                                           org.eclipse.jetty.util.resource.PathResource containerResources,
                                                                           java.util.List<org.apache.tomcat.util.descriptor.web.ErrorPage> errorPages)
      • makeWebAppContextForWAR

        protected org.eclipse.jetty.webapp.WebAppContext makeWebAppContextForWAR​(java.lang.String documentRoot,
                                                                                 org.eclipse.jetty.webapp.Configuration[] configurations,
                                                                                 org.eclipse.jetty.util.resource.Resource war,
                                                                                 java.util.List<org.apache.tomcat.util.descriptor.web.ErrorPage> errorPages)
      • makeResourceBase

        protected java.lang.String makeResourceBase​(java.net.URI webApp)
                                             throws java.net.MalformedURLException
        Throws:
        java.net.MalformedURLException
      • makeFileResource

        protected org.eclipse.jetty.util.resource.PathResource makeFileResource​(java.net.URI classPath)
                                                                         throws java.io.IOException
        Throws:
        java.io.IOException
      • makeConfigurations

        protected org.eclipse.jetty.webapp.Configuration[] makeConfigurations()
      • makeServerConnector

        protected org.eclipse.jetty.server.ServerConnector makeServerConnector​(org.eclipse.jetty.server.Server server,
                                                                               int port)
      • makeRequestLog

        protected org.eclipse.jetty.server.CustomRequestLog makeRequestLog​(java.lang.String logFile)