Class TomcatReactiveWebServerFactory
java.lang.Object
org.springframework.boot.web.server.AbstractConfigurableWebServerFactory
org.springframework.boot.web.reactive.server.AbstractReactiveWebServerFactory
org.springframework.boot.web.embedded.tomcat.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 Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreate a newTomcatReactiveWebServerFactoryinstance.TomcatReactiveWebServerFactory(int port) Create a newTomcatReactiveWebServerFactorythat listens for requests using the specified port. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAdditionalTomcatConnectors(org.apache.catalina.connector.Connector... connectors) AddConnectors in addition to the default connector, e.g.voidaddConnectorCustomizers(TomcatConnectorCustomizer... tomcatConnectorCustomizers) AddTomcatConnectorCustomizers that should be added to the TomcatConnector.voidaddContextCustomizers(TomcatContextCustomizer... tomcatContextCustomizers) AddTomcatContextCustomizers that should be added to the TomcatContext.voidaddContextLifecycleListeners(org.apache.catalina.LifecycleListener... contextLifecycleListeners) AddLifecycleListeners that should be added to the TomcatContext.voidaddEngineValves(org.apache.catalina.Valve... engineValves) AddValves that should be applied to the TomcatEngine.voidaddProtocolHandlerCustomizers(TomcatProtocolHandlerCustomizer<?>... tomcatProtocolHandlerCustomizers) AddTomcatProtocolHandlerCustomizers that should be added to the TomcatConnector.protected voidconfigureContext(org.apache.catalina.Context context) Configure the TomcatContext.protected voidcustomizeConnector(org.apache.catalina.connector.Connector connector) List<org.apache.catalina.connector.Connector>Returns a mutable collection of theConnectors that will be added to the Tomcat.Collection<org.apache.catalina.LifecycleListener>Returns a mutable collection of theLifecycleListeners that will be applied to the TomcatContext.List<org.apache.catalina.Valve>Returns a mutable collection of theValves that will be applied to the TomcatEngine.Returns a mutable collection of theTomcatConnectorCustomizers that will be applied to the TomcatConnector.Returns a mutable collection of theTomcatContextCustomizers that will be applied to the TomcatContext.Returns a mutable collection of theTomcatProtocolHandlerCustomizers that will be applied to the TomcatConnector.protected TomcatWebServergetTomcatWebServer(org.apache.catalina.startup.Tomcat tomcat) Factory method called to create theTomcatWebServer.Returns the character encoding to use for URL decoding.getWebServer(org.springframework.http.server.reactive.HttpHandler httpHandler) Gets a new fully configured but pausedWebServerinstance.protected voidprepareContext(org.apache.catalina.Host host, org.springframework.http.server.reactive.TomcatHttpHandlerAdapter servlet) voidsetBackgroundProcessorDelay(int delay) Sets the background processor delay in seconds.voidsetBaseDirectory(File baseDirectory) Set the Tomcat base directory.voidsetContextLifecycleListeners(Collection<? extends org.apache.catalina.LifecycleListener> contextLifecycleListeners) SetLifecycleListeners that should be applied to the TomcatContext.voidsetDisableMBeanRegistry(boolean disableMBeanRegistry) Set whether the factory should disable Tomcat's MBean registry prior to creating the server.voidsetProtocol(String protocol) The Tomcat protocol to use when create theConnector.voidsetTomcatConnectorCustomizers(Collection<? extends TomcatConnectorCustomizer> tomcatConnectorCustomizers) SetTomcatConnectorCustomizers that should be applied to the TomcatConnector.voidsetTomcatContextCustomizers(Collection<? extends TomcatContextCustomizer> tomcatContextCustomizers) SetTomcatContextCustomizers that should be applied to the TomcatContext.voidsetTomcatProtocolHandlerCustomizers(Collection<? extends TomcatProtocolHandlerCustomizer<?>> tomcatProtocolHandlerCustomizers) SetTomcatProtocolHandlerCustomizers that should be applied to the TomcatConnector.voidsetUriEncoding(Charset uriEncoding) Set the character encoding to use for URL decoding.voidsetUseApr(boolean useApr) Whether to use APR.Methods 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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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.server.ErrorPageRegistry
addErrorPages
-
Field Details
-
DEFAULT_PROTOCOL
The class name of default protocol used.- See Also:
-
-
Constructor Details
-
TomcatReactiveWebServerFactory
public TomcatReactiveWebServerFactory()Create a newTomcatReactiveWebServerFactoryinstance. -
TomcatReactiveWebServerFactory
public TomcatReactiveWebServerFactory(int port) Create a newTomcatReactiveWebServerFactorythat listens for requests using the specified port.- Parameters:
port- the port to listen on
-
-
Method Details
-
getWebServer
Description copied from interface:ReactiveWebServerFactoryGets a new fully configured but pausedWebServerinstance. Clients should not be able to connect to the returned server untilWebServer.start()is called (which happens when theApplicationContexthas been fully refreshed).- Specified by:
getWebServerin interfaceReactiveWebServerFactory- 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 TomcatContext.- Parameters:
context- the Tomcat context
-
customizeConnector
protected void customizeConnector(org.apache.catalina.connector.Connector connector) -
setBaseDirectory
Description copied from interface:ConfigurableTomcatWebServerFactorySet the Tomcat base directory. If not specified a temporary directory will be used.- Specified by:
setBaseDirectoryin interfaceConfigurableTomcatWebServerFactory- Parameters:
baseDirectory- the tomcat base directory
-
setBackgroundProcessorDelay
public void setBackgroundProcessorDelay(int delay) Description copied from interface:ConfigurableTomcatWebServerFactorySets the background processor delay in seconds.- Specified by:
setBackgroundProcessorDelayin interfaceConfigurableTomcatWebServerFactory- Parameters:
delay- the delay in seconds
-
setTomcatContextCustomizers
public void setTomcatContextCustomizers(Collection<? extends TomcatContextCustomizer> tomcatContextCustomizers) SetTomcatContextCustomizers that should be applied to the TomcatContext. Calling this method will replace any existing customizers.- Parameters:
tomcatContextCustomizers- the customizers to set
-
getTomcatContextCustomizers
Returns a mutable collection of theTomcatContextCustomizers that will be applied to the TomcatContext.- Returns:
- the listeners that will be applied
-
addContextCustomizers
AddTomcatContextCustomizers that should be added to the TomcatContext.- Specified by:
addContextCustomizersin interfaceConfigurableTomcatWebServerFactory- Parameters:
tomcatContextCustomizers- the customizers to add
-
setTomcatConnectorCustomizers
public void setTomcatConnectorCustomizers(Collection<? extends TomcatConnectorCustomizer> tomcatConnectorCustomizers) SetTomcatConnectorCustomizers that should be applied to the TomcatConnector. Calling this method will replace any existing customizers.- Parameters:
tomcatConnectorCustomizers- the customizers to set
-
addConnectorCustomizers
AddTomcatConnectorCustomizers that should be added to the TomcatConnector.- Specified by:
addConnectorCustomizersin interfaceConfigurableTomcatWebServerFactory- Parameters:
tomcatConnectorCustomizers- the customizers to add
-
getTomcatConnectorCustomizers
Returns a mutable collection of theTomcatConnectorCustomizers that will be applied to the TomcatConnector.- Returns:
- the customizers that will be applied
-
setTomcatProtocolHandlerCustomizers
public void setTomcatProtocolHandlerCustomizers(Collection<? extends TomcatProtocolHandlerCustomizer<?>> tomcatProtocolHandlerCustomizers) SetTomcatProtocolHandlerCustomizers that should be applied to the TomcatConnector. Calling this method will replace any existing customizers.- Parameters:
tomcatProtocolHandlerCustomizers- the customizers to set- Since:
- 2.2.0
-
addProtocolHandlerCustomizers
public void addProtocolHandlerCustomizers(TomcatProtocolHandlerCustomizer<?>... tomcatProtocolHandlerCustomizers) AddTomcatProtocolHandlerCustomizers that should be added to the TomcatConnector.- Specified by:
addProtocolHandlerCustomizersin interfaceConfigurableTomcatWebServerFactory- Parameters:
tomcatProtocolHandlerCustomizers- the customizers to add- Since:
- 2.2.0
-
getTomcatProtocolHandlerCustomizers
Returns a mutable collection of theTomcatProtocolHandlerCustomizers that will be applied to the TomcatConnector.- Returns:
- the customizers that will be applied
- Since:
- 2.2.0
-
addAdditionalTomcatConnectors
public void addAdditionalTomcatConnectors(org.apache.catalina.connector.Connector... connectors) AddConnectors in addition to the default connector, e.g. for SSL or AJP.Connector customizersare not applied to connectors added this way.- Parameters:
connectors- the connectors to add- Since:
- 2.2.0
-
getAdditionalTomcatConnectors
Returns a mutable collection of theConnectors 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:ConfigurableTomcatWebServerFactoryAddValves that should be applied to the TomcatEngine.- Specified by:
addEngineValvesin interfaceConfigurableTomcatWebServerFactory- Parameters:
engineValves- the valves to add
-
getEngineValves
Returns a mutable collection of theValves that will be applied to the TomcatEngine.- Returns:
- the engine valves that will be applied
-
setUriEncoding
Set the character encoding to use for URL decoding. If not specified 'UTF-8' will be used.- Specified by:
setUriEncodingin interfaceConfigurableTomcatWebServerFactory- Parameters:
uriEncoding- the uri encoding to set
-
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) SetLifecycleListeners that should be applied to the TomcatContext. Calling this method will replace any existing listeners.- Parameters:
contextLifecycleListeners- the listeners to set
-
getContextLifecycleListeners
Returns a mutable collection of theLifecycleListeners that will be applied to the TomcatContext.- Returns:
- the context lifecycle listeners that will be applied
-
addContextLifecycleListeners
public void addContextLifecycleListeners(org.apache.catalina.LifecycleListener... contextLifecycleListeners) AddLifecycleListeners that should be added to the TomcatContext.- Parameters:
contextLifecycleListeners- the listeners to add
-
getTomcatWebServer
Factory method called to create theTomcatWebServer. Subclasses can override this method to return a differentTomcatWebServeror apply additional processing to the Tomcat server.- Parameters:
tomcat- the Tomcat server.- Returns:
- a new
TomcatWebServerinstance
-
setProtocol
The Tomcat protocol to use when create theConnector.- 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
-
setUseApr
public void setUseApr(boolean useApr) Whether to use APR.- Parameters:
useApr- whether to use APR- Since:
- 3.4.4
-