Package io.bootique.jetty.server
Class ServerFactory
- java.lang.Object
-
- io.bootique.jetty.server.ServerFactory
-
public class ServerFactory extends Object
-
-
Field Summary
Fields Modifier and Type Field Description protected List<ConnectorFactory>connectorsprotected Stringcontextprotected Map<String,FilterFactory>filtersprotected intidleThreadTimeoutprotected intmaxQueuedRequestsprotected intmaxThreadsprotected intminThreadsprotected Map<String,ServletFactory>servletsprotected booleansessions
-
Constructor Summary
Constructors Constructor Description ServerFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Collection<ConnectorFactory>connectorFactories(org.eclipse.jetty.server.Server server)protected org.eclipse.jetty.server.handler.gzip.GzipHandlercreateGzipHandler()protected org.eclipse.jetty.servlet.ServletContextHandlercreateHandler(String context, Set<MappedServlet> servlets, Set<MappedFilter> filters, Set<MappedListener> listeners)protected voidcreateRequestLog(org.eclipse.jetty.server.Server server)ServerHoldercreateServerHolder(Set<MappedServlet> servlets, Set<MappedFilter> filters, Set<MappedListener> listeners, Set<ServletContextHandlerExtender> contextHandlerExtenders, RequestMDCManager mdcManager, io.bootique.di.Injector injector)protected org.eclipse.jetty.util.thread.QueuedThreadPoolcreateThreadPool(io.bootique.di.Injector injector)protected org.eclipse.jetty.util.thread.QueuedThreadPoolcreateThreadPool(BlockingQueue<Runnable> queue, io.bootique.di.Injector injector)List<ConnectorFactory>getConnectors()StringgetContext()Map<Integer,String>getErrorPages()protected FilterFactorygetFilterFactory(String name)intgetIdleThreadTimeout()intgetMaxQueuedRequests()intgetMaxThreads()intgetMinThreads()Map<String,String>getParams()protected ServletFactorygetServletFactory(String name)io.bootique.resource.FolderResourceFactorygetStaticResourceBase()protected voidinstallFilters(org.eclipse.jetty.servlet.ServletContextHandler handler, Set<MappedFilter> filters)protected voidinstallListeners(org.eclipse.jetty.servlet.ServletContextHandler handler, Set<MappedListener> listeners)protected voidinstallServlets(org.eclipse.jetty.servlet.ServletContextHandler handler, Set<MappedServlet> servlets)booleanisCompression()booleanisSessions()protected voidpostConfigHandler(org.eclipse.jetty.servlet.ServletContextHandler handler, Set<ServletContextHandlerExtender> contextHandlerExtenders)protected StringresolveContext()voidsetCompactPath(boolean compactPath)Compact URLs with multiple '/'s with a single '/'.voidsetCompression(boolean compression)Sets whether compression whether gzip compression should be supported.voidsetConnectors(List<ConnectorFactory> connectors)Sets a list of connector factories for this server.voidsetContext(String context)voidsetErrorPages(Map<Integer,String> errorPages)Sets mappings between HTTP status codes and corresponding pages which will be returned to the user instead.voidsetFilters(Map<String,FilterFactory> filters)voidsetIdleThreadTimeout(int idleThreadTimeout)voidsetMaxFormContentSize(int maxFormContentSize)Sets the maximum size of submitted forms in bytes.voidsetMaxFormKeys(int maxFormKeys)Sets the maximum number of form fields.voidsetMaxQueuedRequests(int maxQueuedRequests)voidsetMaxThreads(int maxConnectorThreads)voidsetMinThreads(int minThreads)voidsetParams(Map<String,String> params)voidsetServlets(Map<String,ServletFactory> servlets)voidsetSessions(boolean sessions)voidsetStaticResourceBase(io.bootique.resource.FolderResourceFactory staticResourceBase)Sets a base location for resources of the Jetty context.
-
-
-
Field Detail
-
connectors
protected List<ConnectorFactory> connectors
-
context
protected String context
-
idleThreadTimeout
protected int idleThreadTimeout
-
filters
protected Map<String,FilterFactory> filters
-
maxThreads
protected int maxThreads
-
minThreads
protected int minThreads
-
maxQueuedRequests
protected int maxQueuedRequests
-
servlets
protected Map<String,ServletFactory> servlets
-
sessions
protected boolean sessions
-
-
Method Detail
-
createServerHolder
public ServerHolder createServerHolder(Set<MappedServlet> servlets, Set<MappedFilter> filters, Set<MappedListener> listeners, Set<ServletContextHandlerExtender> contextHandlerExtenders, RequestMDCManager mdcManager, io.bootique.di.Injector injector)
- Since:
- 3.0
-
postConfigHandler
protected void postConfigHandler(org.eclipse.jetty.servlet.ServletContextHandler handler, Set<ServletContextHandlerExtender> contextHandlerExtenders)
-
createHandler
protected org.eclipse.jetty.servlet.ServletContextHandler createHandler(String context, Set<MappedServlet> servlets, Set<MappedFilter> filters, Set<MappedListener> listeners)
-
createGzipHandler
protected org.eclipse.jetty.server.handler.gzip.GzipHandler createGzipHandler()
-
installServlets
protected void installServlets(org.eclipse.jetty.servlet.ServletContextHandler handler, Set<MappedServlet> servlets)
-
getServletFactory
protected ServletFactory getServletFactory(String name)
-
installFilters
protected void installFilters(org.eclipse.jetty.servlet.ServletContextHandler handler, Set<MappedFilter> filters)
-
getFilterFactory
protected FilterFactory getFilterFactory(String name)
-
installListeners
protected void installListeners(org.eclipse.jetty.servlet.ServletContextHandler handler, Set<MappedListener> listeners)
-
connectorFactories
protected Collection<ConnectorFactory> connectorFactories(org.eclipse.jetty.server.Server server)
-
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.
-
setServlets
public void setServlets(Map<String,ServletFactory> servlets)
-
setFilters
public void setFilters(Map<String,FilterFactory> filters)
-
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
-
-