Class TomcatWebServerFactory

java.lang.Object
org.springframework.boot.web.server.AbstractConfigurableWebServerFactory
org.springframework.boot.tomcat.TomcatWebServerFactory
All Implemented Interfaces:
ConfigurableTomcatWebServerFactory, org.springframework.boot.web.error.ErrorPageRegistry, org.springframework.boot.web.server.ConfigurableWebServerFactory, org.springframework.boot.web.server.WebServerFactory
Direct Known Subclasses:
TomcatReactiveWebServerFactory, TomcatServletWebServerFactory

public class TomcatWebServerFactory extends org.springframework.boot.web.server.AbstractConfigurableWebServerFactory implements ConfigurableTomcatWebServerFactory
Base class for factories that produce a TomcatWebServer.
Since:
4.0.0
  • Field Details

    • DEFAULT_PROTOCOL

      public static final String DEFAULT_PROTOCOL
      The class name of default protocol used.
      See Also:
  • Constructor Details

    • TomcatWebServerFactory

      protected TomcatWebServerFactory()
    • TomcatWebServerFactory

      protected TomcatWebServerFactory(int port)
  • Method Details

    • setBaseDirectory

      public void setBaseDirectory(File baseDirectory)
      Description copied from interface: ConfigurableTomcatWebServerFactory
      Set the Tomcat base directory. If not specified a temporary directory will be used.
      Specified by:
      setBaseDirectory in interface ConfigurableTomcatWebServerFactory
      Parameters:
      baseDirectory - the tomcat base directory
    • getBaseDirectory

      public File getBaseDirectory()
    • getEngineValves

      public Collection<org.apache.catalina.Valve> getEngineValves()
      Returns a mutable collection of the Valves that will be applied to the Tomcat Engine.
      Returns:
      the engine valves that will be applied
    • setEngineValves

      public void setEngineValves(Collection<? extends org.apache.catalina.Valve> engineValves)
      Set Valves that should be applied to the Tomcat Engine. Calling this method will replace any existing valves.
      Parameters:
      engineValves - the valves to set
    • addEngineValves

      public void addEngineValves(org.apache.catalina.Valve... engineValves)
      Description copied from interface: ConfigurableTomcatWebServerFactory
      Add Valves that should be applied to the Tomcat Engine.
      Specified by:
      addEngineValves in interface ConfigurableTomcatWebServerFactory
      Parameters:
      engineValves - the valves to add
    • getUriEncoding

      public Charset getUriEncoding()
    • setUriEncoding

      public void setUriEncoding(Charset uriEncoding)
      Description copied from interface: ConfigurableTomcatWebServerFactory
      Set the character encoding to use for URL decoding. If not specified 'UTF-8' will be used.
      Specified by:
      setUriEncoding in interface ConfigurableTomcatWebServerFactory
      Parameters:
      uriEncoding - the uri encoding to set
    • getBackgroundProcessorDelay

      public int getBackgroundProcessorDelay()
    • setBackgroundProcessorDelay

      public void setBackgroundProcessorDelay(int delay)
      Description copied from interface: ConfigurableTomcatWebServerFactory
      Sets the background processor delay in seconds.
      Specified by:
      setBackgroundProcessorDelay in interface ConfigurableTomcatWebServerFactory
      Parameters:
      delay - the delay in seconds
    • getProtocol

      public String getProtocol()
    • setProtocol

      public void setProtocol(String protocol)
      The Tomcat protocol to use when create the Connector.
      Parameters:
      protocol - the protocol
      See Also:
      • Connector(String)
    • getContextValves

      public Collection<org.apache.catalina.Valve> getContextValves()
      Returns a mutable collection of the Valves that will be applied to the Tomcat Context.
      Returns:
      the context valves that will be applied
      See Also:
    • setContextValves

      public void setContextValves(Collection<? extends org.apache.catalina.Valve> contextValves)
      Set Valves that should be applied to the Tomcat Context. Calling this method will replace any existing valves.
      Parameters:
      contextValves - the valves to set
    • addContextValves

      public void addContextValves(org.apache.catalina.Valve... contextValves)
      Add Valves that should be applied to the Tomcat Context.
      Parameters:
      contextValves - the valves to add
    • getContextLifecycleListeners

      public Collection<org.apache.catalina.LifecycleListener> getContextLifecycleListeners()
      Returns a mutable collection of the LifecycleListeners that will be applied to the Tomcat Context.
      Returns:
      the context lifecycle listeners that will be applied
    • setContextLifecycleListeners

      public void setContextLifecycleListeners(Collection<? extends org.apache.catalina.LifecycleListener> contextLifecycleListeners)
      Set LifecycleListeners that should be applied to the Tomcat Context. Calling this method will replace any existing listeners.
      Parameters:
      contextLifecycleListeners - the listeners to set
    • addContextLifecycleListeners

      public void addContextLifecycleListeners(org.apache.catalina.LifecycleListener... contextLifecycleListeners)
      Add LifecycleListeners that should be added to the Tomcat Context.
      Parameters:
      contextLifecycleListeners - the listeners to add
    • getContextCustomizers

      public Collection<TomcatContextCustomizer> getContextCustomizers()
      Returns a mutable collection of the TomcatContextCustomizers that will be applied to the Tomcat Context.
      Returns:
      the listeners that will be applied
    • setContextCustomizers

      public void setContextCustomizers(Collection<? extends TomcatContextCustomizer> contextCustomizers)
      Set TomcatContextCustomizers that should be applied to the Tomcat Context. Calling this method will replace any existing customizers.
      Parameters:
      contextCustomizers - the customizers to set
    • addContextCustomizers

      public void addContextCustomizers(TomcatContextCustomizer... contextCustomizers)
      Description copied from interface: ConfigurableTomcatWebServerFactory
      Add TomcatContextCustomizers that should be added to the Tomcat Context.
      Specified by:
      addContextCustomizers in interface ConfigurableTomcatWebServerFactory
      Parameters:
      contextCustomizers - the customizers to add
    • getConnectorCustomizers

      public Set<TomcatConnectorCustomizer> getConnectorCustomizers()
      Returns a mutable collection of the TomcatConnectorCustomizers that will be applied to the Tomcat Connector.
      Returns:
      the customizers that will be applied
    • setConnectorCustomizers

      public void setConnectorCustomizers(Collection<? extends TomcatConnectorCustomizer> connectorCustomizers)
      Set TomcatConnectorCustomizers that should be applied to the Tomcat Connector. Calling this method will replace any existing customizers.
      Parameters:
      connectorCustomizers - the customizers to set
    • addConnectorCustomizers

      public void addConnectorCustomizers(TomcatConnectorCustomizer... connectorCustomizers)
      Description copied from interface: ConfigurableTomcatWebServerFactory
      Add TomcatConnectorCustomizers that should be added to the Tomcat Connector.
      Specified by:
      addConnectorCustomizers in interface ConfigurableTomcatWebServerFactory
      Parameters:
      connectorCustomizers - the customizers to add
    • getProtocolHandlerCustomizers

      public Set<TomcatProtocolHandlerCustomizer<?>> getProtocolHandlerCustomizers()
      Returns a mutable collection of the TomcatProtocolHandlerCustomizers that will be applied to the Tomcat Connector.
      Returns:
      the customizers that will be applied
    • setProtocolHandlerCustomizers

      public void setProtocolHandlerCustomizers(Collection<? extends TomcatProtocolHandlerCustomizer<?>> protocolHandlerCustomizers)
      Set TomcatProtocolHandlerCustomizers that should be applied to the Tomcat Connector. Calling this method will replace any existing customizers.
      Parameters:
      protocolHandlerCustomizers - the customizers to set
    • addProtocolHandlerCustomizers

      public void addProtocolHandlerCustomizers(TomcatProtocolHandlerCustomizer<?>... protocolHandlerCustomizers)
      Description copied from interface: ConfigurableTomcatWebServerFactory
      Add TomcatProtocolHandlerCustomizers that should be added to the Tomcat Connector.
      Specified by:
      addProtocolHandlerCustomizers in interface ConfigurableTomcatWebServerFactory
      Parameters:
      protocolHandlerCustomizers - the customizers to add
    • getAdditionalConnectors

      public List<org.apache.catalina.connector.Connector> getAdditionalConnectors()
      Returns a mutable collection of the Connectors that will be added to the Tomcat server.
      Returns:
      the additional connectors
    • setAdditionalConnectors

      public void setAdditionalConnectors(Collection<? extends org.apache.catalina.connector.Connector> additionalConnectors)
      Set additional Connectors that should be added to the Tomcat server . Calling this method will replace any existing additional connectors.
      Parameters:
      additionalConnectors - the additionalConnectors to set
    • addAdditionalConnectors

      public void addAdditionalConnectors(org.apache.catalina.connector.Connector... connectors)
      Add Connectors in addition to the default connector, e.g. for SSL or AJP.

      Connector customizers are not applied to connectors added this way.

      Parameters:
      connectors - the connectors to add
    • isDisableMBeanRegistry

      public boolean isDisableMBeanRegistry()
      Returns whether the factory should disable Tomcat's MBean registry prior to creating the server.
      Returns:
      whether to disable Tomcat's MBean registry
    • setDisableMBeanRegistry

      public void setDisableMBeanRegistry(boolean disableMBeanRegistry)
      Set whether the factory should disable Tomcat's MBean registry prior to creating the server.
      Specified by:
      setDisableMBeanRegistry in interface ConfigurableTomcatWebServerFactory
      Parameters:
      disableMBeanRegistry - whether to disable the MBean registry
    • setUseApr

      public void setUseApr(boolean useApr)
      Whether to use APR.
      Specified by:
      setUseApr in interface ConfigurableTomcatWebServerFactory
      Parameters:
      useApr - whether to use APR
    • createTomcat

      protected org.apache.catalina.startup.Tomcat createTomcat()
    • customizeConnector

      protected void customizeConnector(org.apache.catalina.connector.Connector connector)