Class TomcatServletWebServerFactory

java.lang.Object
org.springframework.boot.web.server.AbstractConfigurableWebServerFactory
org.springframework.boot.tomcat.TomcatWebServerFactory
org.springframework.boot.tomcat.servlet.TomcatServletWebServerFactory
All Implemented Interfaces:
org.springframework.beans.factory.Aware, ConfigurableTomcatWebServerFactory, 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 TomcatServletWebServerFactory extends TomcatWebServerFactory implements ConfigurableTomcatWebServerFactory, org.springframework.boot.web.server.servlet.ConfigurableServletWebServerFactory, org.springframework.context.ResourceLoaderAware
ConfigurableServletWebServerFactory that can be used to create TomcatWebServers. Can be initialized using Spring's ServletContextInitializers or Tomcat LifecycleListeners.

Unless explicitly configured otherwise this factory will create containers that listen for HTTP requests on port 8080.

Since:
4.0.0
See Also:
  • Constructor Details

    • TomcatServletWebServerFactory

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

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

      public TomcatServletWebServerFactory(String contextPath, int port)
      Create a new TomcatServletWebServerFactory 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
    • prepareContext

      protected void prepareContext(org.apache.catalina.Host host, org.springframework.boot.web.servlet.ServletContextInitializer[] initializers)
    • configureContext

      protected void configureContext(org.apache.catalina.Context context, Iterable<org.springframework.boot.web.servlet.ServletContextInitializer> initializers)
      Configure the Tomcat Context.
      Parameters:
      context - the Tomcat context
      initializers - initializers to apply
    • postProcessContext

      protected void postProcessContext(org.apache.catalina.Context context)
      Post process the Tomcat Context before it's used with the Tomcat Server. Subclasses can override this method to apply additional processing to the Context.
      Parameters:
      context - the Tomcat Context
    • getTomcatWebServer

      protected TomcatWebServer getTomcatWebServer(org.apache.catalina.startup.Tomcat tomcat)
      Factory method called to create the TomcatWebServer. Subclasses can override this method to return a different TomcatWebServer or apply additional processing to the Tomcat server.
      Parameters:
      tomcat - the Tomcat server.
      Returns:
      a new TomcatWebServer instance
    • setResourceLoader

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

      public Set<String> getTldSkipPatterns()
      Returns a mutable set of the patterns that match jars to ignore for TLD scanning.
      Returns:
      the set of jars to ignore for TLD scanning
    • setTldSkipPatterns

      public void setTldSkipPatterns(Collection<String> patterns)
      Set the patterns that match jars to ignore for TLD scanning. See Tomcat's catalina.properties for typical values. Defaults to a list drawn from that source.
      Parameters:
      patterns - the jar patterns to skip when scanning for TLDs etc
    • addTldSkipPatterns

      public void addTldSkipPatterns(String... patterns)
      Add patterns that match jars to ignore for TLD scanning. See Tomcat's catalina.properties for typical values.
      Parameters:
      patterns - the additional jar patterns to skip when scanning for TLDs etc
    • getSettings

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