Class TomcatWebServerFactory
java.lang.Object
org.springframework.boot.web.server.AbstractConfigurableWebServerFactory
org.springframework.boot.tomcat.TomcatWebServerFactory
- All Implemented Interfaces:
ConfigurableTomcatWebServerFactory, ErrorPageRegistry, ConfigurableWebServerFactory, 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 TypeMethodDescriptionvoidaddAdditionalConnectors(Connector... connectors) AddConnectors in addition to the default connector, e.g.voidaddConnectorCustomizers(TomcatConnectorCustomizer... connectorCustomizers) AddTomcatConnectorCustomizers that should be added to the TomcatConnector.voidaddContextCustomizers(TomcatContextCustomizer... contextCustomizers) AddTomcatContextCustomizers that should be added to the TomcatContext.voidaddContextLifecycleListeners(LifecycleListener... contextLifecycleListeners) AddLifecycleListeners that should be added to the TomcatContext.voidaddContextValves(Valve... contextValves) voidaddEngineValves(Valve... engineValves) voidaddProtocolHandlerCustomizers(TomcatProtocolHandlerCustomizer<?>... protocolHandlerCustomizers) AddTomcatProtocolHandlerCustomizers that should be added to the TomcatConnector.protected Tomcatprotected voidcustomizeConnector(Connector connector) Returns a mutable collection of theConnectors that will be added to the Tomcat server.int@Nullable FileReturns 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 theLifecycleListeners that will be applied to the TomcatContext.Returns a mutable collection of theTomcatProtocolHandlerCustomizers that will be applied to the TomcatConnector.booleanReturns whether the factory should disable Tomcat's MBean registry prior to creating the server.voidsetAdditionalConnectors(Collection<? extends Connector> additionalConnectors) Set additionalConnectors that should be added to the Tomcat server .voidsetBackgroundProcessorDelay(int delay) Sets the background processor delay in seconds.voidsetBaseDirectory(@Nullable File baseDirectory) Set the Tomcat base directory.voidsetConnectorCustomizers(Collection<? extends TomcatConnectorCustomizer> connectorCustomizers) SetTomcatConnectorCustomizers that should be applied to the TomcatConnector.voidsetContextCustomizers(Collection<? extends TomcatContextCustomizer> contextCustomizers) SetTomcatContextCustomizers that should be applied to the TomcatContext.voidsetContextLifecycleListeners(Collection<? extends LifecycleListener> contextLifecycleListeners) SetLifecycleListeners that should be applied to the TomcatContext.voidsetContextValves(Collection<? extends Valve> contextValves) voidsetDisableMBeanRegistry(boolean disableMBeanRegistry) Set whether the factory should disable Tomcat's MBean registry prior to creating the server.voidsetEngineValves(Collection<? extends Valve> engineValves) voidsetProtocol(String protocol) The Tomcat protocol to use when create theConnector.voidsetProtocolHandlerCustomizers(Collection<? extends TomcatProtocolHandlerCustomizer<?>> protocolHandlerCustomizers) 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 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 Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ConfigurableWebServerFactory
setAddress, setCompression, setErrorPages, setHttp2, setPort, setServerHeader, setShutdown, setSsl, setSslBundlesMethods inherited from interface ErrorPageRegistry
addErrorPages
-
Field Details
-
DEFAULT_PROTOCOL
-
-
Constructor Details
-
TomcatWebServerFactory
protected TomcatWebServerFactory() -
TomcatWebServerFactory
protected TomcatWebServerFactory(int port)
-
-
Method Details
-
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
-
getBaseDirectory
-
getEngineValves
- Returns:
- the engine valves that will be applied
-
setEngineValves
-
addEngineValves
Description copied from interface:ConfigurableTomcatWebServerFactory- Specified by:
addEngineValvesin interfaceConfigurableTomcatWebServerFactory- Parameters:
engineValves- the valves to add
-
getUriEncoding
-
setUriEncoding
Description copied from interface:ConfigurableTomcatWebServerFactorySet 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
-
getBackgroundProcessorDelay
public int getBackgroundProcessorDelay() -
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
-
getProtocol
-
setProtocol
-
getContextValves
- Returns:
- the context valves that will be applied
- See Also:
-
setContextValves
-
addContextValves
-
getContextLifecycleListeners
Returns a mutable collection of theLifecycleListeners that will be applied to the TomcatContext.- Returns:
- the context lifecycle listeners that will be applied
-
setContextLifecycleListeners
public void setContextLifecycleListeners(Collection<? extends LifecycleListener> contextLifecycleListeners) SetLifecycleListeners that should be applied to the TomcatContext. Calling this method will replace any existing listeners.- Parameters:
contextLifecycleListeners- the listeners to set
-
addContextLifecycleListeners
AddLifecycleListeners that should be added to the TomcatContext.- Parameters:
contextLifecycleListeners- the listeners to add
-
getContextCustomizers
Returns a mutable collection of theTomcatContextCustomizers that will be applied to the TomcatContext.- Returns:
- the listeners that will be applied
-
setContextCustomizers
SetTomcatContextCustomizers 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:ConfigurableTomcatWebServerFactoryAddTomcatContextCustomizers that should be added to the TomcatContext.- Specified by:
addContextCustomizersin interfaceConfigurableTomcatWebServerFactory- Parameters:
contextCustomizers- the customizers to add
-
getConnectorCustomizers
Returns a mutable collection of theTomcatConnectorCustomizers that will be applied to the TomcatConnector.- Returns:
- the customizers that will be applied
-
setConnectorCustomizers
public void setConnectorCustomizers(Collection<? extends TomcatConnectorCustomizer> connectorCustomizers) SetTomcatConnectorCustomizers 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:ConfigurableTomcatWebServerFactoryAddTomcatConnectorCustomizers that should be added to the TomcatConnector.- Specified by:
addConnectorCustomizersin interfaceConfigurableTomcatWebServerFactory- Parameters:
connectorCustomizers- the customizers to add
-
getProtocolHandlerCustomizers
Returns a mutable collection of theTomcatProtocolHandlerCustomizers that will be applied to the TomcatConnector.- Returns:
- the customizers that will be applied
-
setProtocolHandlerCustomizers
public void setProtocolHandlerCustomizers(Collection<? extends TomcatProtocolHandlerCustomizer<?>> protocolHandlerCustomizers) SetTomcatProtocolHandlerCustomizers 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:ConfigurableTomcatWebServerFactoryAddTomcatProtocolHandlerCustomizers that should be added to the TomcatConnector.- Specified by:
addProtocolHandlerCustomizersin interfaceConfigurableTomcatWebServerFactory- Parameters:
protocolHandlerCustomizers- the customizers to add
-
getAdditionalConnectors
-
setAdditionalConnectors
Set additionalConnectors that should be added to the Tomcat server . Calling this method will replace any existing additional connectors.- Parameters:
additionalConnectors- the additionalConnectors to set
-
addAdditionalConnectors
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
-
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:
setDisableMBeanRegistryin interfaceConfigurableTomcatWebServerFactory- Parameters:
disableMBeanRegistry- whether to disable the MBean registry
-
setUseApr
public void setUseApr(boolean useApr) Whether to use APR.- Specified by:
setUseAprin interfaceConfigurableTomcatWebServerFactory- Parameters:
useApr- whether to use APR
-
createTomcat
-
customizeConnector
-