TomcatServletWebServerFactory

AbstractServletWebServerFactory that can be used to create TomcatWebServers. Can be initialized using Spring's ServletContextInitializers or Tomcat LifecycleListeners.

Unless explicitly configured otherwise this factory will create containers that listen for HTTP requests on port 8080.

Author

Phillip Webb

Dave Syer

Brock Mills

Stephane Nicoll

Andy Wilkinson

Eddú Meléndez

Christoffer Sawicki

Dawid Antecki

Moritz Halbritter

Scott Frederick

Since

2.0.0

See also

Constructors

Link copied to clipboard
constructor()
Create a new TomcatServletWebServerFactory instance.
constructor(port: Int)
Create a new TomcatServletWebServerFactory that listens for requests using the specified port.
constructor(contextPath: String, port: Int)
Create a new TomcatServletWebServerFactory with the specified context path and port.

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val DEFAULT_PROTOCOL: String = "org.apache.coyote.http11.Http11NioProtocol"
The class name of default protocol used.
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open var http2: Http2
Link copied to clipboard
Link copied to clipboard
open var jsp: Jsp
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open var port: Int
Link copied to clipboard
Link copied to clipboard
open var session: Session
Link copied to clipboard
open var shutdown: Shutdown
Link copied to clipboard
open var ssl: Ssl
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
open fun addAdditionalTomcatConnectors(connectors: Array<Connector>)
Add Connectors in addition to the default connector, e.g.
Link copied to clipboard
open fun addConnectorCustomizers(tomcatConnectorCustomizers: Array<TomcatConnectorCustomizer>)
Add TomcatConnectorCustomizers that should be added to the Tomcat Connector.
Link copied to clipboard
open fun addContextCustomizers(tomcatContextCustomizers: Array<TomcatContextCustomizer>)
Add TomcatContextCustomizers that should be added to the Tomcat Context.
Link copied to clipboard
open fun addContextLifecycleListeners(contextLifecycleListeners: Array<LifecycleListener>)
Add LifecycleListeners that should be added to the Tomcat Context.
Link copied to clipboard
open fun addContextValves(contextValves: Array<Valve>)
Add Valves that should be applied to the Tomcat Context.
Link copied to clipboard
open fun addCookieSameSiteSuppliers(cookieSameSiteSuppliers: Array<CookieSameSiteSupplier>)
Add CookieSameSiteSuppliers to those that should be used to obtain the SameSite attribute of any added cookie.
Link copied to clipboard
open fun addEngineValves(engineValves: Array<Valve>)
Add Valves that should be applied to the Tomcat Engine.
Link copied to clipboard
open fun addErrorPages(errorPages: Array<ErrorPage>)
Adds error pages that will be used when handling exceptions.
Link copied to clipboard
Add ServletContextInitializers to those that should be applied in addition to getWebServer parameters.
Link copied to clipboard
open fun addMimeMappings(mimeMappings: MimeMappings)
Adds mime-type mappings.
Link copied to clipboard
open fun addProtocolHandlerCustomizers(tomcatProtocolHandlerCustomizers: Array<TomcatProtocolHandlerCustomizer<out Any>>)
Add TomcatProtocolHandlerCustomizers that should be added to the Tomcat Connector.
Link copied to clipboard
open fun addTldSkipPatterns(patterns: Array<String>)
Add patterns that match jars to ignore for TLD scanning.
Link copied to clipboard
open fun addWebListeners(webListenerClassNames: Array<String>)
Adds web listeners that will be registered with the servlet container.
Link copied to clipboard
open fun getContextLifecycleListeners(): Collection<LifecycleListener>
Returns a mutable collection of the LifecycleListeners that will be applied to the Tomcat Context.
Link copied to clipboard
open fun getContextValves(): Collection<Valve>
Returns a mutable collection of the Valves that will be applied to the Tomcat Context.
Link copied to clipboard
open fun getDocumentRoot(): File
Returns the document root which will be used by the web context to serve static files.
Link copied to clipboard
open fun getEngineValves(): Collection<Valve>
Returns a mutable collection of the Valves that will be applied to the Tomcat Engine.
Link copied to clipboard
Returns a mutable collection of the TomcatConnectorCustomizers that will be applied to the Tomcat Connector.
Link copied to clipboard
Returns a mutable collection of the TomcatContextCustomizers that will be applied to the Tomcat Context.
Link copied to clipboard
Returns a mutable collection of the TomcatProtocolHandlerCustomizers that will be applied to the Tomcat Connector.
Link copied to clipboard
Gets a new fully configured but paused WebServer instance.
Link copied to clipboard
Flag to indicate that the default servlet should be registered.
Link copied to clipboard
Sets the background processor delay in seconds.
Link copied to clipboard
open fun setBaseDirectory(baseDirectory: File)
Set the Tomcat base directory.
Link copied to clipboard
open fun setContextLifecycleListeners(contextLifecycleListeners: Collection<out LifecycleListener>)
Set LifecycleListeners that should be applied to the Tomcat Context.
Link copied to clipboard
open fun setContextValves(contextValves: Collection<out Valve>)
Set Valves that should be applied to the Tomcat Context.
Link copied to clipboard
open fun setCookieSameSiteSuppliers(cookieSameSiteSuppliers: List<out CookieSameSiteSupplier>)
Sets CookieSameSiteSuppliers that should be used to obtain the SameSite attribute of any added cookie.
Link copied to clipboard
open fun setDisableMBeanRegistry(disableMBeanRegistry: Boolean)
Set whether the factory should disable Tomcat's MBean registry prior to creating the server.
Link copied to clipboard
open fun setDocumentRoot(documentRoot: File)
Sets the document root directory which will be used by the web context to serve static files.
Link copied to clipboard
open fun setEngineValves(engineValves: Collection<out Valve>)
Set Valves that should be applied to the Tomcat Engine.
Link copied to clipboard
open fun setErrorPages(errorPages: Set<out ErrorPage>)
Sets the error pages that will be used when handling exceptions.
Link copied to clipboard
open fun setInitializers(initializers: List<out ServletContextInitializer>)
Sets ServletContextInitializer that should be applied in addition to getWebServer parameters.
Link copied to clipboard
open fun setProtocol(protocol: String)
The Tomcat protocol to use when create the Connector.
Link copied to clipboard
open fun setRegisterDefaultServlet(registerDefaultServlet: Boolean)
Set if the DefaultServlet should be registered.
Link copied to clipboard
open fun setResourceLoader(resourceLoader: ResourceLoader)
Link copied to clipboard
open fun setTldSkipPatterns(patterns: Collection<String>)
Set the patterns that match jars to ignore for TLD scanning.
Link copied to clipboard
open fun setTomcatConnectorCustomizers(tomcatConnectorCustomizers: Collection<out TomcatConnectorCustomizer>)
Set TomcatConnectorCustomizers that should be applied to the Tomcat Connector.
Link copied to clipboard
open fun setTomcatContextCustomizers(tomcatContextCustomizers: Collection<out TomcatContextCustomizer>)
Set TomcatContextCustomizers that should be applied to the Tomcat Context.
Link copied to clipboard
open fun setTomcatProtocolHandlerCustomizers(tomcatProtocolHandlerCustomizer: Collection<out TomcatProtocolHandlerCustomizer<out Any>>)
Set TomcatProtocolHandlerCustomizers that should be applied to the Tomcat Connector.
Link copied to clipboard
open fun setUseApr(useApr: Boolean)
Whether to use APR.