Class JettyServletWebServerFactory
java.lang.Object
org.springframework.boot.web.server.AbstractConfigurableWebServerFactory
org.springframework.boot.jetty.JettyWebServerFactory
org.springframework.boot.jetty.servlet.JettyServletWebServerFactory
- All Implemented Interfaces:
Aware
,ConfigurableJettyWebServerFactory
,ConfigurableWebServerFactory
,ErrorPageRegistry
,ConfigurableServletWebServerFactory
,ServletWebServerFactory
,WebListenerRegistry
,WebServerFactory
,ResourceLoaderAware
public class JettyServletWebServerFactory
extends JettyWebServerFactory
implements ConfigurableJettyWebServerFactory, ConfigurableServletWebServerFactory, ResourceLoaderAware
ServletWebServerFactory
that can be used to create a JettyWebServer
.
Can be initialized using Spring's ServletContextInitializer
s or Jetty
Configuration
s.
Unless explicitly configured otherwise this factory will create servers that listen for HTTP requests on port 8080.
- Since:
- 4.0.0
- Author:
- Phillip Webb, Dave Syer, Andrey Hihlovskiy, Andy Wilkinson, EddĂș MelĂ©ndez, Venil Noronha, Henri Kerola, Moritz Halbritter, Onur Kagan Ozcan
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a newJettyServletWebServerFactory
instance.JettyServletWebServerFactory
(int port) Create a newJettyServletWebServerFactory
that listens for requests using the specified port.JettyServletWebServerFactory
(String contextPath, int port) Create a newJettyServletWebServerFactory
with the specified context path and port. -
Method Summary
Modifier and TypeMethodDescriptionprotected final void
addDefaultServlet
(org.eclipse.jetty.ee10.webapp.WebAppContext context) Add Jetty'sDefaultServlet
to the givenWebAppContext
.protected org.eclipse.jetty.server.Handler
addHandlerWrappers
(org.eclipse.jetty.server.Handler handler) protected final void
addJspServlet
(org.eclipse.jetty.ee10.webapp.WebAppContext context) Add Jetty'sJspServlet
to the givenWebAppContext
.protected final void
configureWebAppContext
(org.eclipse.jetty.ee10.webapp.WebAppContext context, ServletContextInitializer... initializers) Configure the given JettyWebAppContext
for use.protected JettyWebServer
getJettyWebServer
(org.eclipse.jetty.server.Server server) Factory method called to create theJettyWebServer
.protected org.eclipse.jetty.ee10.webapp.Configuration
getServletContextInitializerConfiguration
(org.eclipse.jetty.ee10.webapp.WebAppContext webAppContext, ServletContextInitializers initializers) Return a JettyConfiguration
that will invoke the specifiedServletContextInitializer
s.protected org.eclipse.jetty.ee10.webapp.Configuration[]
getWebAppContextConfigurations
(org.eclipse.jetty.ee10.webapp.WebAppContext webAppContext, ServletContextInitializers initializers) Return the JettyConfiguration
s that should be applied to the server.getWebServer
(ServletContextInitializer... initializers) Gets a new fully configured but pausedWebServer
instance.protected void
postProcessWebAppContext
(org.eclipse.jetty.ee10.webapp.WebAppContext webAppContext) Post process the JettyWebAppContext
before it's used with the Jetty Server.void
setResourceLoader
(ResourceLoader resourceLoader) Methods inherited from class org.springframework.boot.jetty.JettyWebServerFactory
addConfigurations, addServerCustomizers, applyWrapper, createConnector, createConnector, customizeSsl, getAcceptors, getConfigurations, getMaxConnections, getSelectors, getServerCustomizers, getThreadPool, isUseForwardHeaders, setAcceptors, setConfigurations, setMaxConnections, setSelectors, setServerCustomizers, setThreadPool, setUseForwardHeaders
Methods inherited from class org.springframework.boot.web.server.AbstractConfigurableWebServerFactory
addErrorPages, createTempDir, getAddress, getCompression, getErrorPages, getHttp2, getPort, getServerHeader, getServerNameSslBundles, getShutdown, getSsl, getSslBundle, getSslBundles, setAddress, setCompression, setErrorPages, setHttp2, setPort, setServerHeader, setShutdown, setSsl, setSslBundles
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.boot.jetty.ConfigurableJettyWebServerFactory
addServerCustomizers, setAcceptors, setMaxConnections, setSelectors, setThreadPool, setUseForwardHeaders
Methods inherited from interface org.springframework.boot.web.server.servlet.ConfigurableServletWebServerFactory
addCookieSameSiteSuppliers, addInitializers, addMimeMappings, addWebListeners, getContextPath, setContextPath, setCookieSameSiteSuppliers, setDisplayName, setDocumentRoot, setInitializers, setInitParameters, setJsp, setLocaleCharsetMappings, setMimeMappings, setRegisterDefaultServlet, setSession
Methods inherited from interface org.springframework.boot.web.server.ConfigurableWebServerFactory
setAddress, setCompression, setErrorPages, setHttp2, setPort, setServerHeader, setShutdown, setSsl, setSslBundles
Methods inherited from interface org.springframework.boot.web.server.ErrorPageRegistry
addErrorPages
-
Constructor Details
-
JettyServletWebServerFactory
public JettyServletWebServerFactory()Create a newJettyServletWebServerFactory
instance. -
JettyServletWebServerFactory
public JettyServletWebServerFactory(int port) Create a newJettyServletWebServerFactory
that listens for requests using the specified port.- Parameters:
port
- the port to listen on
-
JettyServletWebServerFactory
Create a newJettyServletWebServerFactory
with the specified context path and port.- Parameters:
contextPath
- the root context pathport
- the port to listen on
-
-
Method Details
-
getWebServer
Description copied from interface:ServletWebServerFactory
Gets a new fully configured but pausedWebServer
instance. Clients should not be able to connect to the returned server untilWebServer.start()
is called (which happens when theApplicationContext
has been fully refreshed).- Specified by:
getWebServer
in interfaceServletWebServerFactory
- Parameters:
initializers
-ServletContextInitializer
s that should be applied as the server starts- Returns:
- a fully configured and started
WebServer
- See Also:
-
addHandlerWrappers
protected org.eclipse.jetty.server.Handler addHandlerWrappers(org.eclipse.jetty.server.Handler handler) - Overrides:
addHandlerWrappers
in classJettyWebServerFactory
-
configureWebAppContext
protected final void configureWebAppContext(org.eclipse.jetty.ee10.webapp.WebAppContext context, ServletContextInitializer... initializers) Configure the given JettyWebAppContext
for use.- Parameters:
context
- the context to configureinitializers
- the set of initializers to apply
-
addDefaultServlet
protected final void addDefaultServlet(org.eclipse.jetty.ee10.webapp.WebAppContext context) Add Jetty'sDefaultServlet
to the givenWebAppContext
.- Parameters:
context
- the jettyWebAppContext
-
addJspServlet
protected final void addJspServlet(org.eclipse.jetty.ee10.webapp.WebAppContext context) Add Jetty'sJspServlet
to the givenWebAppContext
.- Parameters:
context
- the jettyWebAppContext
-
getWebAppContextConfigurations
protected org.eclipse.jetty.ee10.webapp.Configuration[] getWebAppContextConfigurations(org.eclipse.jetty.ee10.webapp.WebAppContext webAppContext, ServletContextInitializers initializers) Return the JettyConfiguration
s that should be applied to the server.- Parameters:
webAppContext
- the JettyWebAppContext
initializers
- theServletContextInitializer
s to apply- Returns:
- configurations to apply
-
getServletContextInitializerConfiguration
protected org.eclipse.jetty.ee10.webapp.Configuration getServletContextInitializerConfiguration(org.eclipse.jetty.ee10.webapp.WebAppContext webAppContext, ServletContextInitializers initializers) Return a JettyConfiguration
that will invoke the specifiedServletContextInitializer
s. By default this method will return aServletContextInitializerConfiguration
.- Parameters:
webAppContext
- the JettyWebAppContext
initializers
- theServletContextInitializer
s to apply- Returns:
- the
Configuration
instance
-
postProcessWebAppContext
protected void postProcessWebAppContext(org.eclipse.jetty.ee10.webapp.WebAppContext webAppContext) Post process the JettyWebAppContext
before it's used with the Jetty Server. Subclasses can override this method to apply additional processing to theWebAppContext
.- Parameters:
webAppContext
- the JettyWebAppContext
-
getJettyWebServer
Factory method called to create theJettyWebServer
. Subclasses can override this method to return a differentJettyWebServer
or apply additional processing to the Jetty server.- Parameters:
server
- the Jetty server.- Returns:
- a new
JettyWebServer
instance
-
setResourceLoader
- Specified by:
setResourceLoader
in interfaceResourceLoaderAware
-
getSettings
- Specified by:
getSettings
in interfaceConfigurableServletWebServerFactory
-