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 aTomcatWebServer
.- Since:
- 2.0.0
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_PROTOCOL
The class name of default protocol used.
Constructor Summary
Constructors Constructor Description TomcatReactiveWebServerFactory()
Create a newTomcatServletWebServerFactory
instance.TomcatReactiveWebServerFactory(int port)
Create a newTomcatServletWebServerFactory
that listens for requests using the specified port.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addConnectorCustomizers(TomcatConnectorCustomizer... tomcatConnectorCustomizers)
AddTomcatConnectorCustomizer
s that should be added to the TomcatConnector
.void
addContextCustomizers(TomcatContextCustomizer... tomcatContextCustomizers)
AddTomcatContextCustomizer
s that should be added to the TomcatContext
.void
addContextLifecycleListeners(org.apache.catalina.LifecycleListener... contextLifecycleListeners)
AddLifecycleListener
s that should be added to the TomcatContext
.void
addEngineValves(org.apache.catalina.Valve... engineValves)
AddValve
s that should be applied to the TomcatEngine
.protected void
configureContext(org.apache.catalina.Context context)
Configure the TomcatContext
.protected void
customizeConnector(org.apache.catalina.connector.Connector connector)
Collection<org.apache.catalina.LifecycleListener>
getContextLifecycleListeners()
Returns a mutable collection of theLifecycleListener
s that will be applied to the TomcatContext
.List<org.apache.catalina.Valve>
getEngineValves()
Returns a mutable collection of theValve
s that will be applied to the TomcatEngine
.Collection<TomcatConnectorCustomizer>
getTomcatConnectorCustomizers()
Returns a mutable collection of theTomcatConnectorCustomizer
s that will be applied to the TomcatConnector
.Collection<TomcatContextCustomizer>
getTomcatContextCustomizers()
Returns a mutable collection of theTomcatContextCustomizer
s that will be applied to the TomcatContext
.protected TomcatWebServer
getTomcatWebServer(org.apache.catalina.startup.Tomcat tomcat)
Factory method called to create theTomcatWebServer
.Charset
getUriEncoding()
Returns the character encoding to use for URL decoding.WebServer
getWebServer(org.springframework.http.server.reactive.HttpHandler httpHandler)
Gets a new fully configured but pausedWebServer
instance.protected void
prepareContext(org.apache.catalina.Host host, org.springframework.http.server.reactive.TomcatHttpHandlerAdapter servlet)
void
setBackgroundProcessorDelay(int delay)
Sets the background processor delay in seconds.void
setBaseDirectory(File baseDirectory)
Set the Tomcat base directory.void
setContextLifecycleListeners(Collection<? extends org.apache.catalina.LifecycleListener> contextLifecycleListeners)
SetLifecycleListener
s that should be applied to the TomcatContext
.void
setProtocol(String protocol)
The Tomcat protocol to use when create theConnector
.void
setTomcatConnectorCustomizers(Collection<? extends TomcatConnectorCustomizer> tomcatConnectorCustomizers)
SetTomcatConnectorCustomizer
s that should be applied to the TomcatConnector
.void
setTomcatContextCustomizers(Collection<? extends TomcatContextCustomizer> tomcatContextCustomizers)
SetTomcatContextCustomizer
s that should be applied to the TomcatContext
.void
setUriEncoding(Charset uriEncoding)
Set the character encoding to use for URL decoding.Methods inherited from class org.springframework.boot.web.server.AbstractConfigurableWebServerFactory
addErrorPages, createTempDir, getAddress, getCompression, getErrorPages, getHttp2, getPort, getServerHeader, getSsl, getSslStoreProvider, setAddress, setCompression, setErrorPages, setHttp2, setPort, setServerHeader, setSsl, setSslStoreProvider
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.boot.web.server.ConfigurableWebServerFactory
setAddress, setCompression, setErrorPages, setHttp2, setPort, setServerHeader, setSsl, setSslStoreProvider
Methods inherited from interface org.springframework.boot.web.server.ErrorPageRegistry
addErrorPages
Field Detail
DEFAULT_PROTOCOL
public static final String DEFAULT_PROTOCOL
The class name of default protocol used.- See Also:
- Constant Field Values
Constructor Detail
TomcatReactiveWebServerFactory
public TomcatReactiveWebServerFactory()
Create a newTomcatServletWebServerFactory
instance.
TomcatReactiveWebServerFactory
public TomcatReactiveWebServerFactory(int port)
Create a newTomcatServletWebServerFactory
that listens for requests using the specified port.- Parameters:
port
- the port to listen on
Method Detail
getWebServer
public WebServer getWebServer(org.springframework.http.server.reactive.HttpHandler httpHandler)
Description copied from interface:ReactiveWebServerFactory
Gets a new fully configured but pausedWebServer
instance. Clients should not be able to connect to the returned server untilWebServer.start()
is called (which happens when theApplicationContext
has been fully refreshed).- Specified by:
getWebServer
in interfaceReactiveWebServerFactory
- Parameters:
httpHandler
- the HTTP handler in charge of processing requests- Returns:
- a fully configured and started
WebServer
- See Also:
WebServer.stop()
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
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 interfaceConfigurableTomcatWebServerFactory
- 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 interfaceConfigurableTomcatWebServerFactory
- Parameters:
delay
- the delay in seconds
setTomcatContextCustomizers
public void setTomcatContextCustomizers(Collection<? extends TomcatContextCustomizer> tomcatContextCustomizers)
SetTomcatContextCustomizer
s that should be applied to the TomcatContext
. Calling this method will replace any existing customizers.- Parameters:
tomcatContextCustomizers
- the customizers to set
getTomcatContextCustomizers
public Collection<TomcatContextCustomizer> getTomcatContextCustomizers()
Returns a mutable collection of theTomcatContextCustomizer
s that will be applied to the TomcatContext
.- Returns:
- the listeners that will be applied
addContextCustomizers
public void addContextCustomizers(TomcatContextCustomizer... tomcatContextCustomizers)
AddTomcatContextCustomizer
s that should be added to the TomcatContext
.- Specified by:
addContextCustomizers
in interfaceConfigurableTomcatWebServerFactory
- Parameters:
tomcatContextCustomizers
- the customizers to add
setTomcatConnectorCustomizers
public void setTomcatConnectorCustomizers(Collection<? extends TomcatConnectorCustomizer> tomcatConnectorCustomizers)
SetTomcatConnectorCustomizer
s that should be applied to the TomcatConnector
. Calling this method will replace any existing customizers.- Parameters:
tomcatConnectorCustomizers
- the customizers to set
addConnectorCustomizers
public void addConnectorCustomizers(TomcatConnectorCustomizer... tomcatConnectorCustomizers)
AddTomcatConnectorCustomizer
s that should be added to the TomcatConnector
.- Specified by:
addConnectorCustomizers
in interfaceConfigurableTomcatWebServerFactory
- Parameters:
tomcatConnectorCustomizers
- the customizers to add
getTomcatConnectorCustomizers
public Collection<TomcatConnectorCustomizer> getTomcatConnectorCustomizers()
Returns a mutable collection of theTomcatConnectorCustomizer
s that will be applied to the TomcatConnector
.- Returns:
- the customizers that will be applied
addEngineValves
public void addEngineValves(org.apache.catalina.Valve... engineValves)
Description copied from interface:ConfigurableTomcatWebServerFactory
AddValve
s that should be applied to the TomcatEngine
.- Specified by:
addEngineValves
in interfaceConfigurableTomcatWebServerFactory
- Parameters:
engineValves
- the valves to add
getEngineValves
public List<org.apache.catalina.Valve> getEngineValves()
Returns a mutable collection of theValve
s that will be applied to the TomcatEngine
.- 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 interfaceConfigurableTomcatWebServerFactory
- 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)
SetLifecycleListener
s that should be applied to the TomcatContext
. 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 theLifecycleListener
s 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)
AddLifecycleListener
s that should be added to the TomcatContext
.- Parameters:
contextLifecycleListeners
- the listeners to add
getTomcatWebServer
protected TomcatWebServer getTomcatWebServer(org.apache.catalina.startup.Tomcat tomcat)
Factory method called to create theTomcatWebServer
. Subclasses can override this method to return a differentTomcatWebServer
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 theConnector
.- Parameters:
protocol
- the protocol- See Also:
Connector(String)