Class JettyServletWebServerFactory
java.lang.Object
org.springframework.boot.web.server.AbstractConfigurableWebServerFactory
org.springframework.boot.web.servlet.server.AbstractServletWebServerFactory
org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory
- All Implemented Interfaces:
- Aware,- ConfigurableJettyWebServerFactory,- ConfigurableWebServerFactory,- ErrorPageRegistry,- WebServerFactory,- ConfigurableServletWebServerFactory,- ServletWebServerFactory,- WebListenerRegistry,- ResourceLoaderAware
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.
- Since:
- 2.0.0
- Author:
- Phillip Webb, Dave Syer, Andrey Hihlovskiy, Andy Wilkinson, EddĂș MelĂ©ndez, Venil Noronha, Henri Kerola
- See Also:
- 
Field SummaryFields inherited from class org.springframework.boot.web.servlet.server.AbstractServletWebServerFactorylogger
- 
Constructor SummaryConstructorsConstructorDescriptionCreate a newJettyServletWebServerFactoryinstance.JettyServletWebServerFactory(int port) Create a newJettyServletWebServerFactorythat listens for requests using the specified port.JettyServletWebServerFactory(String contextPath, int port) Create a newJettyServletWebServerFactorywith the specified context path and port.
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddConfigurations(org.eclipse.jetty.webapp.Configuration... configurations) AddConfigurations that will be applied to theWebAppContextbefore the server is started.protected final voidaddDefaultServlet(org.eclipse.jetty.webapp.WebAppContext context) Add Jetty'sDefaultServletto the givenWebAppContext.protected final voidaddJspServlet(org.eclipse.jetty.webapp.WebAppContext context) Add Jetty'sJspServletto the givenWebAppContext.voidaddServerCustomizers(JettyServerCustomizer... customizers) AddJettyServerCustomizers that will be applied to theServerbefore it is started.protected final voidconfigureWebAppContext(org.eclipse.jetty.webapp.WebAppContext context, ServletContextInitializer... initializers) Configure the given JettyWebAppContextfor use.Collection<org.eclipse.jetty.webapp.Configuration>Returns a mutable collection of JettyConfigurations that will be applied to theWebAppContextbefore the server is created.protected JettyWebServergetJettyWebServer(org.eclipse.jetty.server.Server server) Factory method called to create theJettyWebServer.Returns a mutable collection of JettyJettyServerCustomizers that will be applied to theServerbefore it is created.protected org.eclipse.jetty.webapp.ConfigurationgetServletContextInitializerConfiguration(org.eclipse.jetty.webapp.WebAppContext webAppContext, ServletContextInitializer... initializers) Return a JettyConfigurationthat will invoke the specifiedServletContextInitializers.org.eclipse.jetty.util.thread.ThreadPoolReturns a JettyThreadPoolthat should be used by theServer.protected org.eclipse.jetty.webapp.Configuration[]getWebAppContextConfigurations(org.eclipse.jetty.webapp.WebAppContext webAppContext, ServletContextInitializer... initializers) Return the JettyConfigurations that should be applied to the server.getWebServer(ServletContextInitializer... initializers) Gets a new fully configured but pausedWebServerinstance.protected voidpostProcessWebAppContext(org.eclipse.jetty.webapp.WebAppContext webAppContext) Post process the JettyWebAppContextbefore it's used with the Jetty Server.voidsetAcceptors(int acceptors) Set the number of acceptor threads to use.voidsetConfigurations(Collection<? extends org.eclipse.jetty.webapp.Configuration> configurations) Sets JettyConfigurations that will be applied to theWebAppContextbefore the server is created.voidsetResourceLoader(ResourceLoader resourceLoader) voidsetSelectors(int selectors) Set the number of selector threads to use.voidsetServerCustomizers(Collection<? extends JettyServerCustomizer> customizers) SetsJettyServerCustomizers that will be applied to theServerbefore it is started.voidsetThreadPool(org.eclipse.jetty.util.thread.ThreadPool threadPool) Set theThreadPoolthat should be used by theServer.voidsetUseForwardHeaders(boolean useForwardHeaders) Set if x-forward-* headers should be processed.Methods inherited from class org.springframework.boot.web.servlet.server.AbstractServletWebServerFactoryaddCookieSameSiteSuppliers, 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, shouldRegisterJspServletMethods inherited from class org.springframework.boot.web.server.AbstractConfigurableWebServerFactoryaddErrorPages, createTempDir, getAddress, getCompression, getErrorPages, getHttp2, getOrCreateSslStoreProvider, getPort, getServerHeader, getShutdown, getSsl, getSslStoreProvider, setAddress, setCompression, setErrorPages, setHttp2, setPort, setServerHeader, setShutdown, setSsl, setSslStoreProviderMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.boot.web.server.ConfigurableWebServerFactorysetAddress, setCompression, setErrorPages, setHttp2, setPort, setServerHeader, setShutdown, setSsl, setSslStoreProviderMethods inherited from interface org.springframework.boot.web.server.ErrorPageRegistryaddErrorPages
- 
Constructor Details- 
JettyServletWebServerFactorypublic JettyServletWebServerFactory()Create a newJettyServletWebServerFactoryinstance.
- 
JettyServletWebServerFactorypublic JettyServletWebServerFactory(int port) Create a newJettyServletWebServerFactorythat listens for requests using the specified port.- Parameters:
- port- the port to listen on
 
- 
JettyServletWebServerFactoryCreate a newJettyServletWebServerFactorywith the specified context path and port.- Parameters:
- contextPath- the root context path
- port- the port to listen on
 
 
- 
- 
Method Details- 
getWebServerDescription copied from interface:ServletWebServerFactoryGets a new fully configured but pausedWebServerinstance. Clients should not be able to connect to the returned server untilWebServer.start()is called (which happens when theApplicationContexthas been fully refreshed).- Specified by:
- getWebServerin interface- ServletWebServerFactory
- Parameters:
- initializers-- ServletContextInitializers that should be applied as the server starts
- Returns:
- a fully configured and started WebServer
- See Also:
 
- 
configureWebAppContextprotected final void configureWebAppContext(org.eclipse.jetty.webapp.WebAppContext context, ServletContextInitializer... initializers) Configure the given JettyWebAppContextfor use.- Parameters:
- context- the context to configure
- initializers- the set of initializers to apply
 
- 
addDefaultServletprotected final void addDefaultServlet(org.eclipse.jetty.webapp.WebAppContext context) Add Jetty'sDefaultServletto the givenWebAppContext.- Parameters:
- context- the jetty- WebAppContext
 
- 
addJspServletprotected final void addJspServlet(org.eclipse.jetty.webapp.WebAppContext context) Add Jetty'sJspServletto the givenWebAppContext.- Parameters:
- context- the jetty- WebAppContext
 
- 
getWebAppContextConfigurationsprotected org.eclipse.jetty.webapp.Configuration[] getWebAppContextConfigurations(org.eclipse.jetty.webapp.WebAppContext webAppContext, ServletContextInitializer... initializers) Return the JettyConfigurations that should be applied to the server.- Parameters:
- webAppContext- the Jetty- WebAppContext
- initializers- the- ServletContextInitializers to apply
- Returns:
- configurations to apply
 
- 
getServletContextInitializerConfigurationprotected org.eclipse.jetty.webapp.Configuration getServletContextInitializerConfiguration(org.eclipse.jetty.webapp.WebAppContext webAppContext, ServletContextInitializer... initializers) Return a JettyConfigurationthat will invoke the specifiedServletContextInitializers. By default this method will return aServletContextInitializerConfiguration.- Parameters:
- webAppContext- the Jetty- WebAppContext
- initializers- the- ServletContextInitializers to apply
- Returns:
- the Configurationinstance
 
- 
postProcessWebAppContextprotected void postProcessWebAppContext(org.eclipse.jetty.webapp.WebAppContext webAppContext) Post process the JettyWebAppContextbefore it's used with the Jetty Server. Subclasses can override this method to apply additional processing to theWebAppContext.- Parameters:
- webAppContext- the Jetty- WebAppContext
 
- 
getJettyWebServerFactory method called to create theJettyWebServer. Subclasses can override this method to return a differentJettyWebServeror apply additional processing to the Jetty server.- Parameters:
- server- the Jetty server.
- Returns:
- a new JettyWebServerinstance
 
- 
setResourceLoader- Specified by:
- setResourceLoaderin interface- ResourceLoaderAware
 
- 
setUseForwardHeaderspublic void setUseForwardHeaders(boolean useForwardHeaders) Description copied from interface:ConfigurableJettyWebServerFactorySet if x-forward-* headers should be processed.- Specified by:
- setUseForwardHeadersin interface- ConfigurableJettyWebServerFactory
- Parameters:
- useForwardHeaders- if x-forward headers should be used
 
- 
setAcceptorspublic void setAcceptors(int acceptors) Description copied from interface:ConfigurableJettyWebServerFactorySet the number of acceptor threads to use.- Specified by:
- setAcceptorsin interface- ConfigurableJettyWebServerFactory
- Parameters:
- acceptors- the number of acceptor threads to use
 
- 
setSelectorspublic void setSelectors(int selectors) Description copied from interface:ConfigurableJettyWebServerFactorySet the number of selector threads to use.- Specified by:
- setSelectorsin interface- ConfigurableJettyWebServerFactory
- Parameters:
- selectors- the number of selector threads to use
 
- 
setServerCustomizersSetsJettyServerCustomizers that will be applied to theServerbefore it is started. Calling this method will replace any existing customizers.- Parameters:
- customizers- the Jetty customizers to apply
 
- 
getServerCustomizersReturns a mutable collection of JettyJettyServerCustomizers that will be applied to theServerbefore it is created.- Returns:
- the JettyServerCustomizers
 
- 
addServerCustomizersDescription copied from interface:ConfigurableJettyWebServerFactoryAddJettyServerCustomizers that will be applied to theServerbefore it is started.- Specified by:
- addServerCustomizersin interface- ConfigurableJettyWebServerFactory
- Parameters:
- customizers- the customizers to add
 
- 
setConfigurationspublic void setConfigurations(Collection<? extends org.eclipse.jetty.webapp.Configuration> configurations) Sets JettyConfigurations that will be applied to theWebAppContextbefore the server is created. Calling this method will replace any existing configurations.- Parameters:
- configurations- the Jetty configurations to apply
 
- 
getConfigurationsReturns a mutable collection of JettyConfigurations that will be applied to theWebAppContextbefore the server is created.- Returns:
- the Jetty Configurations
 
- 
addConfigurationspublic void addConfigurations(org.eclipse.jetty.webapp.Configuration... configurations) AddConfigurations that will be applied to theWebAppContextbefore the server is started.- Parameters:
- configurations- the configurations to add
 
- 
getThreadPoolpublic org.eclipse.jetty.util.thread.ThreadPool getThreadPool()Returns a JettyThreadPoolthat should be used by theServer.- Returns:
- a Jetty ThreadPoolornull
 
- 
setThreadPoolpublic void setThreadPool(org.eclipse.jetty.util.thread.ThreadPool threadPool) Description copied from interface:ConfigurableJettyWebServerFactorySet theThreadPoolthat should be used by theServer. If set tonull(default), theServercreates aThreadPoolimplicitly.- Specified by:
- setThreadPoolin interface- ConfigurableJettyWebServerFactory
- Parameters:
- threadPool- the ThreadPool to be used
 
 
-