Package io.dropwizard.core.server
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 forServerFactory
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
onjava.library.path
.nofileHardLimit
(none) The number of open file descriptors before a hard error is issued. Requires Jetty's libsetuid.so
onjava.library.path
.gid
(none) The group ID to switch to once the connectors have started. Requires Jetty's libsetuid.so
onjava.library.path
.uid
(none) The user ID to switch to once the connectors have started. Requires Jetty's libsetuid.so
onjava.library.path
.user
(none) The username to switch to once the connectors have started. Requires Jetty's libsetuid.so
onjava.library.path
.group
(none) The group to switch to once the connectors have started. Requires Jetty's libsetuid.so
onjava.library.path
.umask
(none) The umask to switch to once the connectors have started. Requires Jetty's libsetuid.so
onjava.library.path
.startsAsRoot
(none) Whether or not the Dropwizard application is started as a root user. Requires Jetty's libsetuid.so
onjava.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 Summary
Constructors Constructor Description AbstractServerFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.eclipse.jetty.server.Handler
addRequestLog(org.eclipse.jetty.server.Server server, org.eclipse.jetty.server.Handler handler, String name)
protected org.eclipse.jetty.server.Handler
addStatsHandler(org.eclipse.jetty.server.Handler handler)
protected org.eclipse.jetty.server.Handler
buildGzipHandler(org.eclipse.jetty.server.Handler handler)
protected org.eclipse.jetty.server.Server
buildServer(LifecycleEnvironment lifecycle, org.eclipse.jetty.util.thread.ThreadPool threadPool)
protected org.eclipse.jetty.setuid.SetUIDListener
buildSetUIDListener()
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)
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)
protected org.eclipse.jetty.util.thread.ThreadPool
createThreadPool(com.codahale.metrics.MetricRegistry metricRegistry)
Set<String>
getAllowedMethods()
Boolean
getDetailedJsonProcessingExceptionMapper()
boolean
getDumpAfterStart()
boolean
getDumpBeforeStop()
boolean
getEnableThreadNameFilter()
@Nullable Integer
getGid()
@Nullable String
getGroup()
GzipHandlerFactory
getGzipFilterFactory()
Duration
getIdleThreadTimeout()
Optional<String>
getJerseyRootPath()
int
getMaxQueuedRequests()
int
getMaxThreads()
@Nullable String
getMetricPrefix()
int
getMinThreads()
@Nullable Integer
getNofileHardLimit()
@Nullable Integer
getNofileSoftLimit()
Boolean
getRegisterDefaultExceptionMappers()
RequestLogFactory<?>
getRequestLogFactory()
com.codahale.metrics.annotation.ResponseMeteredLevel
getResponseMeteredLevel()
ServerPushFilterFactory
getServerPush()
Duration
getShutdownGracePeriod()
@Nullable Boolean
getStartsAsRoot()
@Nullable Integer
getUid()
@Nullable String
getUmask()
@Nullable String
getUser()
protected ExecutorService
getVirtualThreadsExecutorService()
boolean
isEnableVirtualThreads()
boolean
isThreadPoolSizedCorrectly()
protected void
printBanner(String name)
void
setAllowedMethods(Set<String> allowedMethods)
void
setDetailedJsonProcessingExceptionMapper(Boolean detailedJsonProcessingExceptionMapper)
void
setDumpAfterStart(boolean dumpAfterStart)
void
setDumpBeforeStop(boolean dumpBeforeStop)
void
setEnableThreadNameFilter(boolean enableThreadNameFilter)
void
setEnableVirtualThreads(boolean enableVirtualThreads)
void
setGid(Integer gid)
void
setGroup(String group)
void
setGzipFilterFactory(GzipHandlerFactory gzip)
void
setIdleThreadTimeout(Duration idleThreadTimeout)
void
setJerseyRootPath(String jerseyRootPath)
void
setMaxQueuedRequests(int maxQueuedRequests)
void
setMaxThreads(int count)
void
setMinThreads(int count)
void
setNofileHardLimit(Integer nofileHardLimit)
void
setNofileSoftLimit(Integer nofileSoftLimit)
void
setRegisterDefaultExceptionMappers(Boolean registerDefaultExceptionMappers)
void
setRequestLogFactory(RequestLogFactory<?> requestLog)
void
setServerPush(ServerPushFilterFactory serverPush)
void
setShutdownGracePeriod(Duration shutdownGracePeriod)
void
setStartsAsRoot(Boolean startsAsRoot)
void
setUid(Integer uid)
void
setUmask(String umask)
void
setUser(String user)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.dropwizard.core.server.ServerFactory
build, configure
-
-
-
-
Method Detail
-
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)
-
getServerPush
public ServerPushFilterFactory getServerPush()
-
setServerPush
public void setServerPush(ServerPushFilterFactory serverPush)
-
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)
-
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)
-
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 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)
-
-