Class AbstractServerFactory

java.lang.Object
io.dropwizard.core.server.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.
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:
  • Constructor Details

    • AbstractServerFactory

      public AbstractServerFactory()
  • Method Details

    • isThreadPoolSizedCorrectly

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

      public RequestLogFactory<?> getRequestLogFactory()
    • setRequestLogFactory

      public void setRequestLogFactory(RequestLogFactory<?> requestLog)
    • getGzipFilterFactory

      public GzipHandlerFactory getGzipFilterFactory()
    • setGzipFilterFactory

      public void setGzipFilterFactory(GzipHandlerFactory gzip)
    • 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)
    • getJerseyRootPath

      public Optional<String> getJerseyRootPath()
    • 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, jakarta.validation.Validator validator, MutableServletContextHandler handler, @Nullable jakarta.servlet.Servlet jerseyContainer, com.codahale.metrics.MetricRegistry metricRegistry)
    • createThreadPool

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

      protected ExecutorService getVirtualThreadsExecutorService()
    • 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 void addRequestLog(org.eclipse.jetty.server.Server server, String name, MutableServletContextHandler servletContextHandler)
    • addGracefulHandler

      protected org.eclipse.jetty.server.Handler addGracefulHandler(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)