public class JettyServletWebServerFactory extends AbstractServletWebServerFactory implements ConfigurableJettyWebServerFactory, ResourceLoaderAware
ServletWebServerFactory that can be used to create a JettyWebServer.
Can be initialized using Spring's ServletContextInitializers or Jetty
Configurations.
Unless explicitly configured otherwise this factory will create servers that listen for HTTP requests on port 8080.
AbstractConfigurableWebServerFactory.setPort(int),
setConfigurations(Collection),
JettyWebServerlogger| Constructor and Description |
|---|
JettyServletWebServerFactory()
Create a new
JettyServletWebServerFactory instance. |
JettyServletWebServerFactory(int port)
Create a new
JettyServletWebServerFactory that listens for requests using
the specified port. |
JettyServletWebServerFactory(String contextPath,
int port)
Create a new
JettyServletWebServerFactory with the specified context path
and port. |
| Modifier and Type | Method and Description |
|---|---|
void |
addConfigurations(org.eclipse.jetty.webapp.Configuration... configurations)
Add
Configurations that will be applied to the WebAppContext before
the server is started. |
protected void |
addDefaultServlet(org.eclipse.jetty.webapp.WebAppContext context)
Add Jetty's
DefaultServlet to the given WebAppContext. |
protected void |
addJspServlet(org.eclipse.jetty.webapp.WebAppContext context)
Add Jetty's
JspServlet to the given WebAppContext. |
void |
addServerCustomizers(JettyServerCustomizer... customizers)
Add
JettyServerCustomizers that will be applied to the Server
before it is started. |
protected void |
configureWebAppContext(org.eclipse.jetty.webapp.WebAppContext context,
ServletContextInitializer... initializers)
Configure the given Jetty
WebAppContext for use. |
Collection<org.eclipse.jetty.webapp.Configuration> |
getConfigurations()
Returns a mutable collection of Jetty
Configurations that will be applied
to the WebAppContext before the server is created. |
protected JettyWebServer |
getJettyWebServer(org.eclipse.jetty.server.Server server)
Factory method called to create the
JettyWebServer. |
Collection<JettyServerCustomizer> |
getServerCustomizers()
Returns a mutable collection of Jetty
JettyServerCustomizers that will be
applied to the Server before the it is created. |
protected org.eclipse.jetty.webapp.Configuration |
getServletContextInitializerConfiguration(org.eclipse.jetty.webapp.WebAppContext webAppContext,
ServletContextInitializer... initializers)
Return a Jetty
Configuration that will invoke the specified
ServletContextInitializers. |
org.eclipse.jetty.util.thread.ThreadPool |
getThreadPool()
Returns a Jetty
ThreadPool that should be used by the Server. |
protected org.eclipse.jetty.webapp.Configuration[] |
getWebAppContextConfigurations(org.eclipse.jetty.webapp.WebAppContext webAppContext,
ServletContextInitializer... initializers)
Return the Jetty
Configurations that should be applied to the server. |
WebServer |
getWebServer(ServletContextInitializer... initializers)
Gets a new fully configured but paused
WebServer instance. |
protected void |
postProcessWebAppContext(org.eclipse.jetty.webapp.WebAppContext webAppContext)
Post process the Jetty
WebAppContext before it's used with the Jetty
Server. |
void |
setAcceptors(int acceptors)
Set the number of acceptor threads to use.
|
void |
setConfigurations(Collection<? extends org.eclipse.jetty.webapp.Configuration> configurations)
Sets Jetty
Configurations that will be applied to the WebAppContext
before the server is created. |
void |
setResourceLoader(ResourceLoader resourceLoader) |
void |
setSelectors(int selectors)
Set the number of selector threads to use.
|
void |
setServerCustomizers(Collection<? extends JettyServerCustomizer> customizers)
Sets
JettyServerCustomizers that will be applied to the Server
before it is started. |
void |
setThreadPool(org.eclipse.jetty.util.thread.ThreadPool threadPool)
Set the
ThreadPool that should be used by the Server. |
void |
setUseForwardHeaders(boolean useForwardHeaders)
Set if x-forward-* headers should be processed.
|
addCookieSameSiteSuppliers, addInitializers, addWebListeners, getContextPath, getCookieSameSiteSuppliers, getDisplayName, getDocumentRoot, getInitParameters, getJsp, getLocaleCharsetMappings, getMimeMappings, getSession, getUrlsOfJarsWithMetaInfResources, getValidDocumentRoot, getValidSessionStoreDir, getValidSessionStoreDir, getWebListenerClassNames, isRegisterDefaultServlet, mergeInitializers, setContextPath, setCookieSameSiteSuppliers, setDisplayName, setDocumentRoot, setInitializers, setInitParameters, setJsp, setLocaleCharsetMappings, setMimeMappings, setRegisterDefaultServlet, setSession, shouldRegisterJspServletaddErrorPages, createTempDir, getAddress, getCompression, getErrorPages, getHttp2, getPort, getServerHeader, getShutdown, getSsl, getSslStoreProvider, setAddress, setCompression, setErrorPages, setHttp2, setPort, setServerHeader, setShutdown, setSsl, setSslStoreProviderclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitsetAddress, setCompression, setErrorPages, setHttp2, setPort, setServerHeader, setShutdown, setSsl, setSslStoreProvideraddErrorPagespublic JettyServletWebServerFactory()
JettyServletWebServerFactory instance.public JettyServletWebServerFactory(int port)
JettyServletWebServerFactory that listens for requests using
the specified port.port - the port to listen onpublic JettyServletWebServerFactory(String contextPath, int port)
JettyServletWebServerFactory with the specified context path
and port.contextPath - the root context pathport - the port to listen onpublic WebServer getWebServer(ServletContextInitializer... initializers)
ServletWebServerFactoryWebServer instance. Clients should
not be able to connect to the returned server until WebServer.start() is
called (which happens when the ApplicationContext has been fully
refreshed).getWebServer in interface ServletWebServerFactoryinitializers - ServletContextInitializers that should be applied as
the server startsWebServerWebServer.stop()protected final void configureWebAppContext(org.eclipse.jetty.webapp.WebAppContext context,
ServletContextInitializer... initializers)
WebAppContext for use.context - the context to configureinitializers - the set of initializers to applyprotected final void addDefaultServlet(org.eclipse.jetty.webapp.WebAppContext context)
DefaultServlet to the given WebAppContext.context - the jetty WebAppContextprotected final void addJspServlet(org.eclipse.jetty.webapp.WebAppContext context)
JspServlet to the given WebAppContext.context - the jetty WebAppContextprotected org.eclipse.jetty.webapp.Configuration[] getWebAppContextConfigurations(org.eclipse.jetty.webapp.WebAppContext webAppContext,
ServletContextInitializer... initializers)
Configurations that should be applied to the server.webAppContext - the Jetty WebAppContextinitializers - the ServletContextInitializers to applyprotected org.eclipse.jetty.webapp.Configuration getServletContextInitializerConfiguration(org.eclipse.jetty.webapp.WebAppContext webAppContext,
ServletContextInitializer... initializers)
Configuration that will invoke the specified
ServletContextInitializers. By default this method will return a
ServletContextInitializerConfiguration.webAppContext - the Jetty WebAppContextinitializers - the ServletContextInitializers to applyConfiguration instanceprotected void postProcessWebAppContext(org.eclipse.jetty.webapp.WebAppContext webAppContext)
WebAppContext before it's used with the Jetty
Server. Subclasses can override this method to apply additional processing to the
WebAppContext.webAppContext - the Jetty WebAppContextprotected JettyWebServer getJettyWebServer(org.eclipse.jetty.server.Server server)
JettyWebServer. Subclasses can override
this method to return a different JettyWebServer or apply additional
processing to the Jetty server.server - the Jetty server.JettyWebServer instancepublic void setResourceLoader(ResourceLoader resourceLoader)
setResourceLoader in interface ResourceLoaderAwarepublic void setUseForwardHeaders(boolean useForwardHeaders)
ConfigurableJettyWebServerFactorysetUseForwardHeaders in interface ConfigurableJettyWebServerFactoryuseForwardHeaders - if x-forward headers should be usedpublic void setAcceptors(int acceptors)
ConfigurableJettyWebServerFactorysetAcceptors in interface ConfigurableJettyWebServerFactoryacceptors - the number of acceptor threads to usepublic void setSelectors(int selectors)
ConfigurableJettyWebServerFactorysetSelectors in interface ConfigurableJettyWebServerFactoryselectors - the number of selector threads to usepublic void setServerCustomizers(Collection<? extends JettyServerCustomizer> customizers)
JettyServerCustomizers that will be applied to the Server
before it is started. Calling this method will replace any existing customizers.customizers - the Jetty customizers to applypublic Collection<JettyServerCustomizer> getServerCustomizers()
JettyServerCustomizers that will be
applied to the Server before the it is created.JettyServerCustomizerspublic void addServerCustomizers(JettyServerCustomizer... customizers)
ConfigurableJettyWebServerFactoryJettyServerCustomizers that will be applied to the Server
before it is started.addServerCustomizers in interface ConfigurableJettyWebServerFactorycustomizers - the customizers to addpublic void setConfigurations(Collection<? extends org.eclipse.jetty.webapp.Configuration> configurations)
Configurations that will be applied to the WebAppContext
before the server is created. Calling this method will replace any existing
configurations.configurations - the Jetty configurations to applypublic Collection<org.eclipse.jetty.webapp.Configuration> getConfigurations()
Configurations that will be applied
to the WebAppContext before the server is created.Configurationspublic void addConfigurations(org.eclipse.jetty.webapp.Configuration... configurations)
Configurations that will be applied to the WebAppContext before
the server is started.configurations - the configurations to addpublic org.eclipse.jetty.util.thread.ThreadPool getThreadPool()
ThreadPool that should be used by the Server.ThreadPool or nullpublic void setThreadPool(org.eclipse.jetty.util.thread.ThreadPool threadPool)
ConfigurableJettyWebServerFactoryThreadPool that should be used by the Server. If set to
null (default), the Server creates a ThreadPool implicitly.setThreadPool in interface ConfigurableJettyWebServerFactorythreadPool - the ThreadPool to be used