类 TomcatServletWebServerFactory
- java.lang.Object
- org.springframework.boot.web.server.AbstractConfigurableWebServerFactory
- org.springframework.boot.web.servlet.server.AbstractServletWebServerFactory
- org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory
- 所有已实现的接口:
org.springframework.beans.factory.Aware
,ConfigurableTomcatWebServerFactory
,ConfigurableWebServerFactory
,ErrorPageRegistry
,WebServerFactory
,ConfigurableServletWebServerFactory
,ServletWebServerFactory
,org.springframework.context.ResourceLoaderAware
public class TomcatServletWebServerFactory extends AbstractServletWebServerFactory implements ConfigurableTomcatWebServerFactory, org.springframework.context.ResourceLoaderAware
AbstractServletWebServerFactory
that can be used to createTomcatWebServer
s. Can be initialized using Spring'sServletContextInitializer
s or TomcatLifecycleListener
s.Unless explicitly configured otherwise this factory will create containers that listen for HTTP requests on port 8080.
字段概要
字段 修饰符和类型 字段 说明 static String
DEFAULT_PROTOCOL
The class name of default protocol used.从类继承的字段 org.springframework.boot.web.servlet.server.AbstractServletWebServerFactory
logger
构造器概要
构造器 构造器 说明 TomcatServletWebServerFactory()
Create a newTomcatServletWebServerFactory
instance.TomcatServletWebServerFactory(int port)
Create a newTomcatServletWebServerFactory
that listens for requests using the specified port.TomcatServletWebServerFactory(String contextPath, int port)
Create a newTomcatServletWebServerFactory
with the specified context path and port.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
addAdditionalTomcatConnectors(org.apache.catalina.connector.Connector... connectors)
AddConnector
s in addition to the default connector, e.g. for SSL or AJPvoid
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
addContextValves(org.apache.catalina.Valve... contextValves)
AddValve
s that should be applied to the TomcatContext
.void
addEngineValves(org.apache.catalina.Valve... engineValves)
AddValve
s that should be applied to the TomcatEngine
.void
addTldSkipPatterns(String... patterns)
Add patterns that match jars to ignore for TLD scanning.protected void
configureContext(org.apache.catalina.Context context, ServletContextInitializer[] initializers)
Configure the TomcatContext
.protected void
customizeConnector(org.apache.catalina.connector.Connector connector)
List<org.apache.catalina.connector.Connector>
getAdditionalTomcatConnectors()
Returns a mutable collection of theConnector
s that will be added to the Tomcat.Collection<org.apache.catalina.LifecycleListener>
getContextLifecycleListeners()
Returns a mutable collection of theLifecycleListener
s that will be applied to the TomcatContext
.Collection<org.apache.catalina.Valve>
getContextValves()
Returns a mutable collection of theValve
s that will be applied to the TomcatContext
.Collection<org.apache.catalina.Valve>
getEngineValves()
Returns a mutable collection of theValve
s that will be applied to the TomcatEngine
.Set<String>
getTldSkipPatterns()
Returns a mutable set of the patterns that match jars to ignore for TLD scanning.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(ServletContextInitializer... initializers)
Gets a new fully configured but pausedWebServer
instance.protected void
postProcessContext(org.apache.catalina.Context context)
Post process the TomcatContext
before it's used with the Tomcat Server.protected void
prepareContext(org.apache.catalina.Host host, ServletContextInitializer[] initializers)
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
setContextValves(Collection<? extends org.apache.catalina.Valve> contextValves)
SetValve
s that should be applied to the TomcatContext
.void
setEngineValves(Collection<? extends org.apache.catalina.Valve> engineValves)
SetValve
s that should be applied to the TomcatEngine
.void
setProtocol(String protocol)
The Tomcat protocol to use when create theConnector
.void
setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader)
void
setTldSkipPatterns(Collection<String> patterns)
Set the patterns that match jars to ignore for TLD scanning.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.从类继承的方法 org.springframework.boot.web.servlet.server.AbstractServletWebServerFactory
addInitializers, getContextPath, getDisplayName, getDocumentRoot, getInitParameters, getJsp, getLocaleCharsetMappings, getMimeMappings, getSession, getUrlsOfJarsWithMetaInfResources, getValidDocumentRoot, getValidSessionStoreDir, getValidSessionStoreDir, isRegisterDefaultServlet, mergeInitializers, setContextPath, setDisplayName, setDocumentRoot, setInitializers, setInitParameters, setJsp, setLocaleCharsetMappings, setMimeMappings, setRegisterDefaultServlet, setSession, shouldRegisterJspServlet
从类继承的方法 org.springframework.boot.web.server.AbstractConfigurableWebServerFactory
addErrorPages, createTempDir, getAddress, getCompression, getErrorPages, getHttp2, getPort, getServerHeader, getSsl, getSslStoreProvider, setAddress, setCompression, setErrorPages, setHttp2, setPort, setServerHeader, setSsl, setSslStoreProvider
从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
从接口继承的方法 org.springframework.boot.web.server.ConfigurableWebServerFactory
setAddress, setCompression, setErrorPages, setHttp2, setPort, setServerHeader, setSsl, setSslStoreProvider
从接口继承的方法 org.springframework.boot.web.server.ErrorPageRegistry
addErrorPages
字段详细资料
DEFAULT_PROTOCOL
public static final String DEFAULT_PROTOCOL
The class name of default protocol used.- 另请参阅:
- 常量字段值
构造器详细资料
TomcatServletWebServerFactory
public TomcatServletWebServerFactory()
Create a newTomcatServletWebServerFactory
instance.
TomcatServletWebServerFactory
public TomcatServletWebServerFactory(int port)
Create a newTomcatServletWebServerFactory
that listens for requests using the specified port.- 参数:
port
- the port to listen on
TomcatServletWebServerFactory
public TomcatServletWebServerFactory(String contextPath, int port)
Create a newTomcatServletWebServerFactory
with the specified context path and port.- 参数:
contextPath
- the root context pathport
- the port to listen on
方法详细资料
getWebServer
public WebServer getWebServer(ServletContextInitializer... initializers)
从接口复制的说明:ServletWebServerFactory
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).- 指定者:
getWebServer
在接口中ServletWebServerFactory
- 参数:
initializers
-ServletContextInitializer
s that should be applied as the server starts- 返回:
- a fully configured and started
WebServer
- 另请参阅:
WebServer.stop()
prepareContext
protected void prepareContext(org.apache.catalina.Host host, ServletContextInitializer[] initializers)
customizeConnector
protected void customizeConnector(org.apache.catalina.connector.Connector connector)
configureContext
protected void configureContext(org.apache.catalina.Context context, ServletContextInitializer[] initializers)
Configure the TomcatContext
.- 参数:
context
- the Tomcat contextinitializers
- initializers to apply
postProcessContext
protected void postProcessContext(org.apache.catalina.Context context)
Post process the TomcatContext
before it's used with the Tomcat Server. Subclasses can override this method to apply additional processing to theContext
.- 参数:
context
- the TomcatContext
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.- 参数:
tomcat
- the Tomcat server.- 返回:
- a new
TomcatWebServer
instance
setResourceLoader
public void setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader)
- 指定者:
setResourceLoader
在接口中org.springframework.context.ResourceLoaderAware
setBaseDirectory
public void setBaseDirectory(File baseDirectory)
从接口复制的说明:ConfigurableTomcatWebServerFactory
Set the Tomcat base directory. If not specified a temporary directory will be used.- 指定者:
setBaseDirectory
在接口中ConfigurableTomcatWebServerFactory
- 参数:
baseDirectory
- the tomcat base directory
getTldSkipPatterns
public Set<String> getTldSkipPatterns()
Returns a mutable set of the patterns that match jars to ignore for TLD scanning.- 返回:
- the list of jars to ignore for TLD scanning
setTldSkipPatterns
public void setTldSkipPatterns(Collection<String> patterns)
Set the patterns that match jars to ignore for TLD scanning. See Tomcat's catalina.properties for typical values. Defaults to a list drawn from that source.- 参数:
patterns
- the jar patterns to skip when scanning for TLDs etc
addTldSkipPatterns
public void addTldSkipPatterns(String... patterns)
Add patterns that match jars to ignore for TLD scanning. See Tomcat's catalina.properties for typical values.- 参数:
patterns
- the additional jar patterns to skip when scanning for TLDs etc
setProtocol
public void setProtocol(String protocol)
The Tomcat protocol to use when create theConnector
.- 参数:
protocol
- the protocol- 另请参阅:
Connector(String)
setEngineValves
public void setEngineValves(Collection<? extends org.apache.catalina.Valve> engineValves)
SetValve
s that should be applied to the TomcatEngine
. Calling this method will replace any existing valves.- 参数:
engineValves
- the valves to set
getEngineValves
public Collection<org.apache.catalina.Valve> getEngineValves()
Returns a mutable collection of theValve
s that will be applied to the TomcatEngine
.- 返回:
- the engine valves that will be applied
addEngineValves
public void addEngineValves(org.apache.catalina.Valve... engineValves)
从接口复制的说明:ConfigurableTomcatWebServerFactory
AddValve
s that should be applied to the TomcatEngine
.- 指定者:
addEngineValves
在接口中ConfigurableTomcatWebServerFactory
- 参数:
engineValves
- the valves to add
setContextValves
public void setContextValves(Collection<? extends org.apache.catalina.Valve> contextValves)
SetValve
s that should be applied to the TomcatContext
. Calling this method will replace any existing valves.- 参数:
contextValves
- the valves to set
getContextValves
public Collection<org.apache.catalina.Valve> getContextValves()
Returns a mutable collection of theValve
s that will be applied to the TomcatContext
.- 返回:
- the context valves that will be applied
- 另请参阅:
getEngineValves()
addContextValves
public void addContextValves(org.apache.catalina.Valve... contextValves)
AddValve
s that should be applied to the TomcatContext
.- 参数:
contextValves
- the valves to add
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.- 参数:
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
.- 返回:
- 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
.- 参数:
contextLifecycleListeners
- the listeners to add
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.- 参数:
tomcatContextCustomizers
- the customizers to set
getTomcatContextCustomizers
public Collection<TomcatContextCustomizer> getTomcatContextCustomizers()
Returns a mutable collection of theTomcatContextCustomizer
s that will be applied to the TomcatContext
.- 返回:
- the listeners that will be applied
addContextCustomizers
public void addContextCustomizers(TomcatContextCustomizer... tomcatContextCustomizers)
从接口复制的说明:ConfigurableTomcatWebServerFactory
AddTomcatContextCustomizer
s that should be added to the TomcatContext
.- 指定者:
addContextCustomizers
在接口中ConfigurableTomcatWebServerFactory
- 参数:
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.- 参数:
tomcatConnectorCustomizers
- the customizers to set
addConnectorCustomizers
public void addConnectorCustomizers(TomcatConnectorCustomizer... tomcatConnectorCustomizers)
从接口复制的说明:ConfigurableTomcatWebServerFactory
AddTomcatConnectorCustomizer
s that should be added to the TomcatConnector
.- 指定者:
addConnectorCustomizers
在接口中ConfigurableTomcatWebServerFactory
- 参数:
tomcatConnectorCustomizers
- the customizers to add
getTomcatConnectorCustomizers
public Collection<TomcatConnectorCustomizer> getTomcatConnectorCustomizers()
Returns a mutable collection of theTomcatConnectorCustomizer
s that will be applied to the TomcatConnector
.- 返回:
- the customizers that will be applied
addAdditionalTomcatConnectors
public void addAdditionalTomcatConnectors(org.apache.catalina.connector.Connector... connectors)
AddConnector
s in addition to the default connector, e.g. for SSL or AJP- 参数:
connectors
- the connectors to add
getAdditionalTomcatConnectors
public List<org.apache.catalina.connector.Connector> getAdditionalTomcatConnectors()
Returns a mutable collection of theConnector
s that will be added to the Tomcat.- 返回:
- the additionalTomcatConnectors
setUriEncoding
public void setUriEncoding(Charset uriEncoding)
从接口复制的说明:ConfigurableTomcatWebServerFactory
Set the character encoding to use for URL decoding. If not specified 'UTF-8' will be used.- 指定者:
setUriEncoding
在接口中ConfigurableTomcatWebServerFactory
- 参数:
uriEncoding
- the uri encoding to set
getUriEncoding
public Charset getUriEncoding()
Returns the character encoding to use for URL decoding.- 返回:
- the URI encoding
setBackgroundProcessorDelay
public void setBackgroundProcessorDelay(int delay)
从接口复制的说明:ConfigurableTomcatWebServerFactory
Sets the background processor delay in seconds.- 指定者:
setBackgroundProcessorDelay
在接口中ConfigurableTomcatWebServerFactory
- 参数:
delay
- the delay in seconds