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 Details

    • JettyServletWebServerFactory

      public JettyServletWebServerFactory()
      Create a new JettyServletWebServerFactory instance.
    • JettyServletWebServerFactory

      public JettyServletWebServerFactory(int port)
      Create a new JettyServletWebServerFactory that listens for requests using the specified port.
      Parameters:
      port - the port to listen on
    • JettyServletWebServerFactory

      public JettyServletWebServerFactory(String contextPath, int port)
      Create a new JettyServletWebServerFactory with the specified context path and port.
      Parameters:
      contextPath - the root context path
      port - 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:
      getWebServer in interface org.springframework.boot.web.server.servlet.ServletWebServerFactory
    • addHandlerWrappers

      protected org.eclipse.jetty.server.Handler addHandlerWrappers(org.eclipse.jetty.server.Handler handler)
      Overrides:
      addHandlerWrappers in class JettyWebServerFactory
    • configureWebAppContext

      protected final void configureWebAppContext(org.eclipse.jetty.ee11.webapp.WebAppContext context, org.springframework.boot.web.servlet.ServletContextInitializer... initializers)
      Configure the given Jetty WebAppContext for use.
      Parameters:
      context - the context to configure
      initializers - the set of initializers to apply
    • addDefaultServlet

      protected final void addDefaultServlet(org.eclipse.jetty.ee11.webapp.WebAppContext context)
      Add Jetty's DefaultServlet to the given WebAppContext.
      Parameters:
      context - the jetty WebAppContext
    • addJspServlet

      protected final void addJspServlet(org.eclipse.jetty.ee11.webapp.WebAppContext context)
      Add Jetty's JspServlet to the given WebAppContext.
      Parameters:
      context - the jetty WebAppContext
    • 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 Jetty Configurations that should be applied to the server.
      Parameters:
      webAppContext - the Jetty WebAppContext
      initializers - the ServletContextInitializers 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 Jetty Configuration that will invoke the specified ServletContextInitializers. By default this method will return a ServletContextInitializerConfiguration.
      Parameters:
      webAppContext - the Jetty WebAppContext
      initializers - the ServletContextInitializers to apply
      Returns:
      the Configuration instance
    • postProcessWebAppContext

      protected void postProcessWebAppContext(org.eclipse.jetty.ee11.webapp.WebAppContext webAppContext)
      Post process the Jetty WebAppContext before it's used with the Jetty Server. Subclasses can override this method to apply additional processing to the WebAppContext.
      Parameters:
      webAppContext - the Jetty WebAppContext
    • getJettyWebServer

      protected JettyWebServer getJettyWebServer(org.eclipse.jetty.server.Server server)
      Factory method called to create the JettyWebServer. Subclasses can override this method to return a different JettyWebServer or apply additional processing to the Jetty server.
      Parameters:
      server - the Jetty server.
      Returns:
      a new JettyWebServer instance
    • setResourceLoader

      public void setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader)
      Specified by:
      setResourceLoader in interface org.springframework.context.ResourceLoaderAware
    • getSettings

      public org.springframework.boot.web.server.servlet.ServletWebServerSettings getSettings()
      Specified by:
      getSettings in interface org.springframework.boot.web.server.servlet.ConfigurableServletWebServerFactory