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:
org.springframework.beans.factory.Aware, ConfigurableJettyWebServerFactory, org.springframework.boot.web.error.ErrorPageRegistry, org.springframework.boot.web.server.ConfigurableWebServerFactory, org.springframework.boot.web.server.servlet.ConfigurableServletWebServerFactory, org.springframework.boot.web.server.servlet.ServletWebServerFactory, org.springframework.boot.web.server.servlet.WebListenerRegistry, org.springframework.boot.web.server.WebServerFactory, org.springframework.context.ResourceLoaderAware
public class JettyServletWebServerFactory
extends JettyWebServerFactory
implements ConfigurableJettyWebServerFactory, org.springframework.boot.web.server.servlet.ConfigurableServletWebServerFactory, org.springframework.context.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:
- 4.0.0
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreate 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 Summary
Modifier and TypeMethodDescriptionprotected final voidaddDefaultServlet(org.eclipse.jetty.ee11.webapp.WebAppContext context) Add Jetty'sDefaultServletto the givenWebAppContext.protected org.eclipse.jetty.server.HandleraddHandlerWrappers(org.eclipse.jetty.server.Handler handler) protected final voidaddJspServlet(org.eclipse.jetty.ee11.webapp.WebAppContext context) Add Jetty'sJspServletto the givenWebAppContext.protected final voidconfigureWebAppContext(org.eclipse.jetty.ee11.webapp.WebAppContext context, org.springframework.boot.web.servlet.ServletContextInitializer... initializers) Configure the given JettyWebAppContextfor use.protected JettyWebServergetJettyWebServer(org.eclipse.jetty.server.Server server) Factory method called to create theJettyWebServer.protected org.eclipse.jetty.ee11.webapp.ConfigurationgetServletContextInitializerConfiguration(org.eclipse.jetty.ee11.webapp.WebAppContext webAppContext, org.springframework.boot.web.server.servlet.ServletContextInitializers initializers) Return a JettyConfigurationthat will invoke the specifiedServletContextInitializers.org.springframework.boot.web.server.servlet.ServletWebServerSettingsprotected org.eclipse.jetty.ee11.webapp.Configuration[]getWebAppContextConfigurations(org.eclipse.jetty.ee11.webapp.WebAppContext webAppContext, org.springframework.boot.web.server.servlet.ServletContextInitializers initializers) Return the JettyConfigurations that should be applied to the server.org.springframework.boot.web.server.WebServergetWebServer(org.springframework.boot.web.servlet.ServletContextInitializer... initializers) protected voidpostProcessWebAppContext(org.eclipse.jetty.ee11.webapp.WebAppContext webAppContext) Post process the JettyWebAppContextbefore it's used with the Jetty Server.voidsetResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader) Methods inherited from class JettyWebServerFactory
addConfigurations, addServerCustomizers, applyWrapper, createConnector, createConnector, customizeSsl, getAcceptors, getConfigurations, getMaxConnections, getSelectors, getServerCustomizers, getThreadPool, isUseForwardHeaders, setAcceptors, setConfigurations, setMaxConnections, setSelectors, setServerCustomizers, setThreadPool, setUseForwardHeadersMethods 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, setSslBundlesMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ConfigurableJettyWebServerFactory
addServerCustomizers, setAcceptors, setMaxConnections, setSelectors, setThreadPool, setUseForwardHeadersMethods 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, setSessionMethods inherited from interface org.springframework.boot.web.server.ConfigurableWebServerFactory
setAddress, setCompression, setErrorPages, setHttp2, setPort, setServerHeader, setShutdown, setSsl, setSslBundlesMethods inherited from interface org.springframework.boot.web.error.ErrorPageRegistry
addErrorPages
-
Constructor Details
-
JettyServletWebServerFactory
public JettyServletWebServerFactory()Create a newJettyServletWebServerFactoryinstance. -
JettyServletWebServerFactory
public JettyServletWebServerFactory(int port) Create a newJettyServletWebServerFactorythat listens for requests using the specified port.- Parameters:
port- the port to listen on
-
JettyServletWebServerFactory
Create a newJettyServletWebServerFactorywith the specified context path and port.- Parameters:
contextPath- the root context pathport- the port to listen on
-
-
Method Details
-
getWebServer
public org.springframework.boot.web.server.WebServer getWebServer(org.springframework.boot.web.servlet.ServletContextInitializer... initializers) - Specified by:
getWebServerin interfaceorg.springframework.boot.web.server.servlet.ServletWebServerFactory
-
addHandlerWrappers
protected org.eclipse.jetty.server.Handler addHandlerWrappers(org.eclipse.jetty.server.Handler handler) - Overrides:
addHandlerWrappersin classJettyWebServerFactory
-
configureWebAppContext
protected final void configureWebAppContext(org.eclipse.jetty.ee11.webapp.WebAppContext context, org.springframework.boot.web.servlet.ServletContextInitializer... initializers) Configure the given JettyWebAppContextfor use.- Parameters:
context- the context to configureinitializers- the set of initializers to apply
-
addDefaultServlet
protected final void addDefaultServlet(org.eclipse.jetty.ee11.webapp.WebAppContext context) Add Jetty'sDefaultServletto the givenWebAppContext.- Parameters:
context- the jettyWebAppContext
-
addJspServlet
protected final void addJspServlet(org.eclipse.jetty.ee11.webapp.WebAppContext context) Add Jetty'sJspServletto the givenWebAppContext.- Parameters:
context- the jettyWebAppContext
-
getWebAppContextConfigurations
protected org.eclipse.jetty.ee11.webapp.Configuration[] getWebAppContextConfigurations(org.eclipse.jetty.ee11.webapp.WebAppContext webAppContext, org.springframework.boot.web.server.servlet.ServletContextInitializers initializers) Return the JettyConfigurations that should be applied to the server.- Parameters:
webAppContext- the JettyWebAppContextinitializers- theServletContextInitializers to apply- Returns:
- configurations to apply
-
getServletContextInitializerConfiguration
protected org.eclipse.jetty.ee11.webapp.Configuration getServletContextInitializerConfiguration(org.eclipse.jetty.ee11.webapp.WebAppContext webAppContext, org.springframework.boot.web.server.servlet.ServletContextInitializers initializers) Return a JettyConfigurationthat will invoke the specifiedServletContextInitializers. By default this method will return aServletContextInitializerConfiguration.- Parameters:
webAppContext- the JettyWebAppContextinitializers- theServletContextInitializers to apply- Returns:
- the
Configurationinstance
-
postProcessWebAppContext
protected void postProcessWebAppContext(org.eclipse.jetty.ee11.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 JettyWebAppContext
-
getJettyWebServer
Factory 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
public void setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader) - Specified by:
setResourceLoaderin interfaceorg.springframework.context.ResourceLoaderAware
-
getSettings
public org.springframework.boot.web.server.servlet.ServletWebServerSettings getSettings()- Specified by:
getSettingsin interfaceorg.springframework.boot.web.server.servlet.ConfigurableServletWebServerFactory
-