Class TomcatReactiveWebServerFactory

All Implemented Interfaces:
ConfigurableTomcatWebServerFactory, ConfigurableReactiveWebServerFactory, ReactiveWebServerFactory, ConfigurableWebServerFactory, ErrorPageRegistry, WebServerFactory

public class TomcatReactiveWebServerFactory extends AbstractReactiveWebServerFactory implements ConfigurableTomcatWebServerFactory
ReactiveWebServerFactory that can be used to create a TomcatWebServer.
Since:
2.0.0
  • Field Details

    • DEFAULT_PROTOCOL

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

    • TomcatReactiveWebServerFactory

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

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

    • getWebServer

      public WebServer getWebServer(org.springframework.http.server.reactive.HttpHandler httpHandler)
      Description copied from interface: ReactiveWebServerFactory
      Gets a new fully configured but paused WebServer instance. Clients should not be able to connect to the returned server until WebServer.start() is called (which happens when the ApplicationContext has been fully refreshed).
      Specified by:
      getWebServer in interface ReactiveWebServerFactory
      Parameters:
      httpHandler - the HTTP handler in charge of processing requests
      Returns:
      a fully configured and started WebServer
      See Also:
    • prepareContext

      protected void prepareContext(org.apache.catalina.Host host, org.springframework.http.server.reactive.TomcatHttpHandlerAdapter servlet)
    • configureContext

      protected void configureContext(org.apache.catalina.Context context)
      Configure the Tomcat Context.
      Parameters:
      context - the Tomcat context
    • customizeConnector

      protected void customizeConnector(org.apache.catalina.connector.Connector connector)
    • 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
    • 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
    • setTomcatContextCustomizers

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

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

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

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

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

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

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

      public void addProtocolHandlerCustomizers(TomcatProtocolHandlerCustomizer<?>... tomcatProtocolHandlerCustomizers)
      Add TomcatProtocolHandlerCustomizers that should be added to the Tomcat Connector.
      Specified by:
      addProtocolHandlerCustomizers in interface ConfigurableTomcatWebServerFactory
      Parameters:
      tomcatProtocolHandlerCustomizers - the customizers to add
      Since:
      2.2.0
    • getTomcatProtocolHandlerCustomizers

      public Collection<TomcatProtocolHandlerCustomizer<?>> getTomcatProtocolHandlerCustomizers()
      Returns a mutable collection of the TomcatProtocolHandlerCustomizers that will be applied to the Tomcat Connector.
      Returns:
      the customizers that will be applied
      Since:
      2.2.0
    • addAdditionalTomcatConnectors

      public void addAdditionalTomcatConnectors(org.apache.catalina.connector.Connector... connectors)
      Add Connectors in addition to the default connector, e.g. for SSL or AJP
      Parameters:
      connectors - the connectors to add
      Since:
      2.2.0
    • getAdditionalTomcatConnectors

      public List<org.apache.catalina.connector.Connector> getAdditionalTomcatConnectors()
      Returns a mutable collection of the Connectors that will be added to the Tomcat.
      Returns:
      the additionalTomcatConnectors
      Since:
      2.2.0
    • 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
    • getEngineValves

      public List<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
    • setUriEncoding

      public void setUriEncoding(Charset uriEncoding)
      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
    • getUriEncoding

      public Charset getUriEncoding()
      Returns the character encoding to use for URL decoding.
      Returns:
      the URI encoding
    • 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
    • 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
    • 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
    • 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
    • setProtocol

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

      public void setDisableMBeanRegistry(boolean disableMBeanRegistry)
      Set whether the factory should disable Tomcat's MBean registry prior to creating the server.
      Parameters:
      disableMBeanRegistry - whether to disable the MBean registry
      Since:
      2.2.0