Class TomcatWebServerFactory
java.lang.Object
org.springframework.boot.web.server.AbstractConfigurableWebServerFactory
org.springframework.boot.web.server.tomcat.TomcatWebServerFactory
- All Implemented Interfaces:
ConfigurableWebServerFactory
,ErrorPageRegistry
,ConfigurableTomcatWebServerFactory
,WebServerFactory
- Direct Known Subclasses:
TomcatReactiveWebServerFactory
,TomcatServletWebServerFactory
public class TomcatWebServerFactory
extends AbstractConfigurableWebServerFactory
implements ConfigurableTomcatWebServerFactory
Base class for factories that produce a
TomcatWebServer
.- Since:
- 4.0.0
- Author:
- Andy Wilkinson
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addAdditionalConnectors
(Connector... connectors) AddConnector
s in addition to the default connector, e.g.void
addConnectorCustomizers
(TomcatConnectorCustomizer... connectorCustomizers) AddTomcatConnectorCustomizer
s that should be added to the TomcatConnector
.void
addContextCustomizers
(TomcatContextCustomizer... contextCustomizers) AddTomcatContextCustomizer
s that should be added to the TomcatContext
.void
addContextLifecycleListeners
(LifecycleListener... contextLifecycleListeners) AddLifecycleListener
s that should be added to the TomcatContext
.void
addContextValves
(Valve... contextValves) void
addEngineValves
(Valve... engineValves) void
addProtocolHandlerCustomizers
(TomcatProtocolHandlerCustomizer<?>... protocolHandlerCustomizers) AddTomcatProtocolHandlerCustomizer
s that should be added to the TomcatConnector
.protected Tomcat
protected void
customizeConnector
(Connector connector) Returns a mutable collection of theConnector
s that will be added to the Tomcat server.int
Returns a mutable collection of theTomcatConnectorCustomizer
s that will be applied to the TomcatConnector
.Returns a mutable collection of theTomcatContextCustomizer
s that will be applied to the TomcatContext
.Returns a mutable collection of theLifecycleListener
s that will be applied to the TomcatContext
.Returns a mutable collection of theTomcatProtocolHandlerCustomizer
s that will be applied to the TomcatConnector
.boolean
Returns whether the factory should disable Tomcat's MBean registry prior to creating the server.void
setAdditionalConnectors
(Collection<? extends Connector> additionalConnectors) Set additionalConnectors
s that should be added to the Tomcat server .void
setBackgroundProcessorDelay
(int delay) Sets the background processor delay in seconds.void
setBaseDirectory
(File baseDirectory) Set the Tomcat base directory.void
setConnectorCustomizers
(Collection<? extends TomcatConnectorCustomizer> connectorCustomizers) SetTomcatConnectorCustomizer
s that should be applied to the TomcatConnector
.void
setContextCustomizers
(Collection<? extends TomcatContextCustomizer> contextCustomizers) SetTomcatContextCustomizer
s that should be applied to the TomcatContext
.void
setContextLifecycleListeners
(Collection<? extends LifecycleListener> contextLifecycleListeners) SetLifecycleListener
s that should be applied to the TomcatContext
.void
setContextValves
(Collection<? extends Valve> contextValves) void
setDisableMBeanRegistry
(boolean disableMBeanRegistry) Set whether the factory should disable Tomcat's MBean registry prior to creating the server.void
setEngineValves
(Collection<? extends Valve> engineValves) void
setProtocol
(String protocol) The Tomcat protocol to use when create theConnector
.void
setProtocolHandlerCustomizers
(Collection<? extends TomcatProtocolHandlerCustomizer<?>> protocolHandlerCustomizers) SetTomcatProtocolHandlerCustomizer
s that should be applied to the TomcatConnector
.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, getServerNameSslBundles, getShutdown, getSsl, getSslBundle, getSslBundles, setAddress, setCompression, setErrorPages, setHttp2, setPort, setServerHeader, setShutdown, setSsl, setSslBundles
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, setShutdown, setSsl, setSslBundles
Methods inherited from interface org.springframework.boot.web.server.ErrorPageRegistry
addErrorPages
-
Field Details
-
DEFAULT_PROTOCOL
-
-
Constructor Details
-
TomcatWebServerFactory
protected TomcatWebServerFactory() -
TomcatWebServerFactory
protected TomcatWebServerFactory(int port)
-
-
Method Details
-
setBaseDirectory
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
-
getBaseDirectory
-
getEngineValves
- Returns:
- the engine valves that will be applied
-
setEngineValves
-
addEngineValves
Description copied from interface:ConfigurableTomcatWebServerFactory
- Specified by:
addEngineValves
in interfaceConfigurableTomcatWebServerFactory
- Parameters:
engineValves
- the valves to add
-
getUriEncoding
-
setUriEncoding
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 interfaceConfigurableTomcatWebServerFactory
- 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 interfaceConfigurableTomcatWebServerFactory
- Parameters:
delay
- the delay in seconds
-
getProtocol
-
setProtocol
-
getContextValves
- Returns:
- the context valves that will be applied
- See Also:
-
setContextValves
-
addContextValves
-
getContextLifecycleListeners
Returns a mutable collection of theLifecycleListener
s that will be applied to the TomcatContext
.- Returns:
- the context lifecycle listeners that will be applied
-
setContextLifecycleListeners
public void setContextLifecycleListeners(Collection<? extends 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
-
addContextLifecycleListeners
AddLifecycleListener
s that should be added to the TomcatContext
.- Parameters:
contextLifecycleListeners
- the listeners to add
-
getServerLifecycleListeners
-
getContextCustomizers
Returns a mutable collection of theTomcatContextCustomizer
s that will be applied to the TomcatContext
.- Returns:
- the listeners that will be applied
-
setContextCustomizers
SetTomcatContextCustomizer
s that should be applied to the TomcatContext
. Calling this method will replace any existing customizers.- Parameters:
contextCustomizers
- the customizers to set
-
addContextCustomizers
Description copied from interface:ConfigurableTomcatWebServerFactory
AddTomcatContextCustomizer
s that should be added to the TomcatContext
.- Specified by:
addContextCustomizers
in interfaceConfigurableTomcatWebServerFactory
- Parameters:
contextCustomizers
- the customizers to add
-
getConnectorCustomizers
Returns a mutable collection of theTomcatConnectorCustomizer
s that will be applied to the TomcatConnector
.- Returns:
- the customizers that will be applied
-
setConnectorCustomizers
public void setConnectorCustomizers(Collection<? extends TomcatConnectorCustomizer> connectorCustomizers) SetTomcatConnectorCustomizer
s that should be applied to the TomcatConnector
. Calling this method will replace any existing customizers.- Parameters:
connectorCustomizers
- the customizers to set
-
addConnectorCustomizers
Description copied from interface:ConfigurableTomcatWebServerFactory
AddTomcatConnectorCustomizer
s that should be added to the TomcatConnector
.- Specified by:
addConnectorCustomizers
in interfaceConfigurableTomcatWebServerFactory
- Parameters:
connectorCustomizers
- the customizers to add
-
getProtocolHandlerCustomizers
Returns a mutable collection of theTomcatProtocolHandlerCustomizer
s that will be applied to the TomcatConnector
.- Returns:
- the customizers that will be applied
-
setProtocolHandlerCustomizers
public void setProtocolHandlerCustomizers(Collection<? extends TomcatProtocolHandlerCustomizer<?>> protocolHandlerCustomizers) SetTomcatProtocolHandlerCustomizer
s that should be applied to the TomcatConnector
. 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
AddTomcatProtocolHandlerCustomizer
s that should be added to the TomcatConnector
.- Specified by:
addProtocolHandlerCustomizers
in interfaceConfigurableTomcatWebServerFactory
- Parameters:
protocolHandlerCustomizers
- the customizers to add
-
getAdditionalConnectors
-
setAdditionalConnectors
Set additionalConnectors
s that should be added to the Tomcat server . Calling this method will replace any existing additional connectors.- Parameters:
additionalConnectors
- the additionalConnectors to set
-
addAdditionalConnectors
AddConnector
s 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.- Parameters:
disableMBeanRegistry
- whether to disable the MBean registry
-
createTomcat
-
customizeConnector
-