Class ServerFactory


  • public class ServerFactory
    extends Object
    • Field Detail

      • context

        protected String context
      • idleThreadTimeout

        protected int idleThreadTimeout
      • maxThreads

        protected int maxThreads
      • minThreads

        protected int minThreads
      • maxQueuedRequests

        protected int maxQueuedRequests
      • sessions

        protected boolean sessions
    • Constructor Detail

      • ServerFactory

        public ServerFactory()
    • Method Detail

      • postConfigHandler

        protected void postConfigHandler​(org.eclipse.jetty.servlet.ServletContextHandler handler,
                                         Set<ServletContextHandlerExtender> contextHandlerExtenders)
      • createGzipHandler

        protected org.eclipse.jetty.server.handler.gzip.GzipHandler createGzipHandler()
      • installServlets

        protected void installServlets​(org.eclipse.jetty.servlet.ServletContextHandler handler,
                                       Set<MappedServlet> servlets)
      • installFilters

        protected void installFilters​(org.eclipse.jetty.servlet.ServletContextHandler handler,
                                      Set<MappedFilter> filters)
      • installListeners

        protected void installListeners​(org.eclipse.jetty.servlet.ServletContextHandler handler,
                                        Set<MappedListener> listeners)
      • createThreadPool

        protected org.eclipse.jetty.util.thread.QueuedThreadPool createThreadPool​(io.bootique.di.Injector injector)
      • createThreadPool

        protected org.eclipse.jetty.util.thread.QueuedThreadPool createThreadPool​(BlockingQueue<Runnable> queue,
                                                                                  io.bootique.di.Injector injector)
      • createRequestLog

        protected void createRequestLog​(org.eclipse.jetty.server.Server server)
      • getConnectors

        public List<ConnectorFactory> getConnectors()
        Returns:
        a List of server connectors, each listening on its own unique port.
      • setConnectors

        public void setConnectors​(List<ConnectorFactory> connectors)
        Sets a list of connector factories for this server. Each connectors would listen on its own unique port.
        Parameters:
        connectors - a list of preconfigured connector factories.
      • getContext

        public String getContext()
        Returns:
        web application context path.
      • setContext

        public void setContext​(String context)
      • resolveContext

        protected String resolveContext()
      • getIdleThreadTimeout

        public int getIdleThreadTimeout()
        Returns:
        a period in milliseconds specifying how long it takes until an idle thread is terminated.
      • setIdleThreadTimeout

        public void setIdleThreadTimeout​(int idleThreadTimeout)
      • getMaxQueuedRequests

        public int getMaxQueuedRequests()
        Returns:
        a maximum number of requests to queue if the thread pool is busy.
      • setMaxQueuedRequests

        public void setMaxQueuedRequests​(int maxQueuedRequests)
      • getMaxThreads

        public int getMaxThreads()
        Returns:
        a maximum number of request processing threads in the pool.
      • setMaxThreads

        public void setMaxThreads​(int maxConnectorThreads)
      • getMinThreads

        public int getMinThreads()
        Returns:
        an initial number of request processing threads in the pool.
      • setMinThreads

        public void setMinThreads​(int minThreads)
      • getParams

        public Map<String,​String> getParams()
        Returns:
        a map of arbitrary key/value parameters that are used as "init" parameters of the ServletContext.
      • setParams

        public void setParams​(Map<String,​String> params)
        Parameters:
        params - a map of context init parameters.
      • isSessions

        public boolean isSessions()
        Returns:
        a boolean specifying whether servlet sessions should be supported by Jetty.
      • setSessions

        public void setSessions​(boolean sessions)
      • getStaticResourceBase

        public io.bootique.resource.FolderResourceFactory getStaticResourceBase()
        Returns:
        a base location for resources of the Jetty context.
      • setStaticResourceBase

        public void setStaticResourceBase​(io.bootique.resource.FolderResourceFactory staticResourceBase)
        Sets a base location for resources of the Jetty context. Used by static resource servlets, including the "default" servlet. The value can be a file path or a URL, as well as a special URL starting with "classpath:".

        It can be optionally overridden by DefaultServlet configuration.

        For security reasons this has to be set explicitly. There's no default.

        Parameters:
        staticResourceBase - A base location for resources of the Jetty context, that can be a file path or a URL, as well as a special URL starting with "classpath:".
        See Also:
        JettyModuleExtender.useDefaultServlet(), JettyModuleExtender.addStaticServlet(String, String...), DefaultServlet.
      • isCompression

        public boolean isCompression()
        Returns:
        whether content compression is supported.
      • setCompression

        public void setCompression​(boolean compression)
        Sets whether compression whether gzip compression should be supported. When true, responses will be compressed if a client requests it via "Accept-Encoding:" header. Default is true.
        Parameters:
        compression - whether gzip compression should be supported.
      • setCompactPath

        public void setCompactPath​(boolean compactPath)
        Compact URLs with multiple '/'s with a single '/'.
        Parameters:
        compactPath - Compact URLs with multiple '/'s with a single '/'. Default value is 'false'
      • setMaxFormContentSize

        public void setMaxFormContentSize​(int maxFormContentSize)
        Sets the maximum size of submitted forms in bytes. Default is 200000 (~195K).
        Parameters:
        maxFormContentSize - maximum size of submitted forms in bytes. Default is 200000 (~195K)
      • setMaxFormKeys

        public void setMaxFormKeys​(int maxFormKeys)
        Sets the maximum number of form fields. Default is 1000.
        Parameters:
        maxFormKeys - maximum number of form fields. Default is 1000.
      • getErrorPages

        public Map<Integer,​String> getErrorPages()
        Returns:
        a potentially null map of error pages configuration.
      • setErrorPages

        public void setErrorPages​(Map<Integer,​String> errorPages)
        Sets mappings between HTTP status codes and corresponding pages which will be returned to the user instead.
        Parameters:
        errorPages - map where keys are HTTP status codes and values are page URLs which will be used to handle them