Class AbstractServerFactory

  • All Implemented Interfaces:
    ServerFactory, Discoverable
    Direct Known Subclasses:
    DefaultServerFactory, SimpleServerFactory

    public abstract class AbstractServerFactory
    extends Object
    implements ServerFactory
    A base class for ServerFactory implementations.

    Configuration Parameters:

    Name Default Description
    requestLog The request log configuration.
    gzip The GZIP configuration.
    serverPush The ServerPushFilterFactory configuration.
    responseMeteredLevel COARSE The response metered level to decide what response code meters are included.
    metricPrefix The metricPrefix to use in the metric name for jetty metrics.
    maxThreads 1024 The maximum number of threads to use for requests.
    minThreads 8 The minimum number of threads to use for requests.
    maxQueuedRequests 1024 The maximum number of requests to queue before blocking the acceptors.
    idleThreadTimeout 1 minute The amount of time a worker thread can be idle before being stopped.
    nofileSoftLimit (none) The number of open file descriptors before a soft error is issued. Requires Jetty's libsetuid.so on java.library.path.
    nofileHardLimit (none) The number of open file descriptors before a hard error is issued. Requires Jetty's libsetuid.so on java.library.path.
    gid (none) The group ID to switch to once the connectors have started. Requires Jetty's libsetuid.so on java.library.path.
    uid (none) The user ID to switch to once the connectors have started. Requires Jetty's libsetuid.so on java.library.path.
    user (none) The username to switch to once the connectors have started. Requires Jetty's libsetuid.so on java.library.path.
    group (none) The group to switch to once the connectors have started. Requires Jetty's libsetuid.so on java.library.path.
    umask (none) The umask to switch to once the connectors have started. Requires Jetty's libsetuid.so on java.library.path.
    startsAsRoot (none) Whether or not the Dropwizard application is started as a root user. Requires Jetty's libsetuid.so on java.library.path.
    registerDefaultExceptionMappers true Whether or not the default Jersey ExceptionMappers should be registered. Set this to false if you want to register your own.
    shutdownGracePeriod 30 seconds The maximum time to wait for Jetty, and all Managed instances, to cleanly shutdown before forcibly terminating them.
    allowedMethods GET, POST, PUT, DELETE, HEAD, OPTIONS, PATCH The set of allowed HTTP methods. Others will be rejected with a 405 Method Not Allowed response.
    rootPath /* The URL pattern relative to applicationContextPath from which the JAX-RS resources will be served.
    enableThreadNameFilter true Whether or not to apply the ThreadNameFilter that adjusts thread names to include the request method and request URI.
    dumpAfterStart true Whether or not to dump jetty diagnostics after start.
    dumpBeforeStop true Whether or not to dump jetty diagnostics before stop.
    enableVirtualThreads false Whether to use virtual threads for Jetty's thread pool.
    See Also:
    DefaultServerFactory, SimpleServerFactory
    • Constructor Detail

      • AbstractServerFactory

        public AbstractServerFactory()
    • Method Detail

      • isThreadPoolSizedCorrectly

        @ValidationMethod(message="must have a smaller minThreads than maxThreads")
        public boolean isThreadPoolSizedCorrectly()
      • setRequestLogFactory

        public void setRequestLogFactory​(RequestLogFactory<?> requestLog)
      • getResponseMeteredLevel

        public com.codahale.metrics.annotation.ResponseMeteredLevel getResponseMeteredLevel()
      • getMetricPrefix

        public @Nullable String getMetricPrefix()
      • getMaxThreads

        public int getMaxThreads()
      • setMaxThreads

        public void setMaxThreads​(int count)
      • getMinThreads

        public int getMinThreads()
      • setMinThreads

        public void setMinThreads​(int count)
      • getMaxQueuedRequests

        public int getMaxQueuedRequests()
      • setMaxQueuedRequests

        public void setMaxQueuedRequests​(int maxQueuedRequests)
      • getIdleThreadTimeout

        public Duration getIdleThreadTimeout()
      • setIdleThreadTimeout

        public void setIdleThreadTimeout​(Duration idleThreadTimeout)
      • getNofileSoftLimit

        public @Nullable Integer getNofileSoftLimit()
      • setNofileSoftLimit

        public void setNofileSoftLimit​(Integer nofileSoftLimit)
      • getNofileHardLimit

        public @Nullable Integer getNofileHardLimit()
      • setNofileHardLimit

        public void setNofileHardLimit​(Integer nofileHardLimit)
      • getGid

        public @Nullable Integer getGid()
      • setGid

        public void setGid​(Integer gid)
      • getUid

        public @Nullable Integer getUid()
      • setUid

        public void setUid​(Integer uid)
      • getUser

        public @Nullable String getUser()
      • setUser

        public void setUser​(String user)
      • getGroup

        public @Nullable String getGroup()
      • setGroup

        public void setGroup​(String group)
      • getUmask

        public @Nullable String getUmask()
      • setUmask

        public void setUmask​(String umask)
      • getStartsAsRoot

        public @Nullable Boolean getStartsAsRoot()
      • setStartsAsRoot

        public void setStartsAsRoot​(Boolean startsAsRoot)
      • getRegisterDefaultExceptionMappers

        public Boolean getRegisterDefaultExceptionMappers()
      • setRegisterDefaultExceptionMappers

        public void setRegisterDefaultExceptionMappers​(Boolean registerDefaultExceptionMappers)
      • getDetailedJsonProcessingExceptionMapper

        public Boolean getDetailedJsonProcessingExceptionMapper()
      • setDetailedJsonProcessingExceptionMapper

        public void setDetailedJsonProcessingExceptionMapper​(Boolean detailedJsonProcessingExceptionMapper)
      • getShutdownGracePeriod

        public Duration getShutdownGracePeriod()
      • setShutdownGracePeriod

        public void setShutdownGracePeriod​(Duration shutdownGracePeriod)
      • getAllowedMethods

        public Set<String> getAllowedMethods()
      • setAllowedMethods

        public void setAllowedMethods​(Set<String> allowedMethods)
      • setJerseyRootPath

        public void setJerseyRootPath​(String jerseyRootPath)
      • getEnableThreadNameFilter

        public boolean getEnableThreadNameFilter()
      • setEnableThreadNameFilter

        public void setEnableThreadNameFilter​(boolean enableThreadNameFilter)
      • getDumpAfterStart

        public boolean getDumpAfterStart()
        Since:
        2.0
      • setDumpAfterStart

        public void setDumpAfterStart​(boolean dumpAfterStart)
        Since:
        2.0
      • getDumpBeforeStop

        public boolean getDumpBeforeStop()
        Since:
        2.0
      • setDumpBeforeStop

        public void setDumpBeforeStop​(boolean dumpBeforeStop)
        Since:
        2.0
      • isEnableVirtualThreads

        public boolean isEnableVirtualThreads()
      • setEnableVirtualThreads

        public void setEnableVirtualThreads​(boolean enableVirtualThreads)
      • createAdminServlet

        protected org.eclipse.jetty.server.Handler createAdminServlet​(org.eclipse.jetty.server.Server server,
                                                                      MutableServletContextHandler handler,
                                                                      com.codahale.metrics.MetricRegistry metrics,
                                                                      com.codahale.metrics.health.HealthCheckRegistry healthChecks,
                                                                      AdminEnvironment admin)
      • createAppServlet

        protected org.eclipse.jetty.server.Handler createAppServlet​(org.eclipse.jetty.server.Server server,
                                                                    JerseyEnvironment jersey,
                                                                    com.fasterxml.jackson.databind.ObjectMapper objectMapper,
                                                                    javax.validation.Validator validator,
                                                                    MutableServletContextHandler handler,
                                                                    @Nullable javax.servlet.Servlet jerseyContainer,
                                                                    com.codahale.metrics.MetricRegistry metricRegistry)
      • createThreadPool

        protected org.eclipse.jetty.util.thread.ThreadPool createThreadPool​(com.codahale.metrics.MetricRegistry metricRegistry)
      • getThreadFactory

        protected ThreadFactory getThreadFactory​(boolean virtualThreadsRequested)
      • buildServer

        protected org.eclipse.jetty.server.Server buildServer​(LifecycleEnvironment lifecycle,
                                                              org.eclipse.jetty.util.thread.ThreadPool threadPool)
      • buildSetUIDListener

        protected org.eclipse.jetty.setuid.SetUIDListener buildSetUIDListener()
      • addRequestLog

        protected org.eclipse.jetty.server.Handler addRequestLog​(org.eclipse.jetty.server.Server server,
                                                                 org.eclipse.jetty.server.Handler handler,
                                                                 String name)
      • addStatsHandler

        protected org.eclipse.jetty.server.Handler addStatsHandler​(org.eclipse.jetty.server.Handler handler)
      • buildGzipHandler

        protected org.eclipse.jetty.server.Handler buildGzipHandler​(org.eclipse.jetty.server.Handler handler)
      • printBanner

        protected void printBanner​(String name)