public class TomcatEmbeddedServletContainerFactory extends AbstractEmbeddedServletContainerFactory implements org.springframework.context.ResourceLoaderAware
EmbeddedServletContainerFactory
that can be used to create
TomcatEmbeddedServletContainer
s. Can be initialized using Spring's
ServletContextInitializer
s or Tomcat LifecycleListener
s.
Unless explicitly configured otherwise this factory will created containers that listens for HTTP requests on port 8080.
AbstractConfigurableEmbeddedServletContainer.setPort(int)
,
setContextLifecycleListeners(Collection)
,
TomcatEmbeddedServletContainer
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_PROTOCOL
The class name of default protocol used.
|
logger
Constructor and Description |
---|
TomcatEmbeddedServletContainerFactory()
Create a new
TomcatEmbeddedServletContainerFactory instance. |
TomcatEmbeddedServletContainerFactory(int port)
Create a new
TomcatEmbeddedServletContainerFactory that listens for
requests using the specified port. |
TomcatEmbeddedServletContainerFactory(String contextPath,
int port)
Create a new
TomcatEmbeddedServletContainerFactory with the specified
context path and port. |
Modifier and Type | Method and Description |
---|---|
void |
addAdditionalTomcatConnectors(org.apache.catalina.connector.Connector... connectors)
Add
Connector s in addition to the default connector, e.g. |
void |
addConnectorCustomizers(TomcatConnectorCustomizer... tomcatConnectorCustomizers)
Add
TomcatContextCustomizer s that should be added to the Tomcat
Connector . |
void |
addContextCustomizers(TomcatContextCustomizer... tomcatContextCustomizers)
Add
TomcatContextCustomizer s that should be added to the Tomcat
Context . |
void |
addContextLifecycleListeners(org.apache.catalina.LifecycleListener... contextLifecycleListeners)
Add
LifecycleListener s that should be added to the Tomcat Context . |
void |
addContextValves(org.apache.catalina.Valve... contextValves)
Add
Valve s that should be applied to the Tomcat Context . |
void |
addEngineValves(org.apache.catalina.Valve... engineValves)
Add
Valve s that should be applied to the Tomcat Engine . |
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 Tomcat
Context . |
protected void |
configureSsl(org.apache.coyote.http11.AbstractHttp11JsseProtocol<?> protocol,
Ssl ssl)
Configure Tomcat's
AbstractHttp11JsseProtocol for SSL. |
protected void |
configureSslStoreProvider(org.apache.coyote.http11.AbstractHttp11JsseProtocol<?> protocol,
SslStoreProvider sslStoreProvider) |
protected void |
customizeConnector(org.apache.catalina.connector.Connector connector) |
List<org.apache.catalina.connector.Connector> |
getAdditionalTomcatConnectors()
Returns a mutable collection of the
Connector s that will be added to the
Tomcat. |
Collection<org.apache.catalina.LifecycleListener> |
getContextLifecycleListeners()
Returns a mutable collection of the
LifecycleListener s that will be applied
to the Tomcat Context . |
Collection<org.apache.catalina.Valve> |
getContextValves()
Returns a mutable collection of the
Valve s that will be applied to the
Tomcat Context . |
EmbeddedServletContainer |
getEmbeddedServletContainer(ServletContextInitializer... initializers)
Gets a new fully configured but paused
EmbeddedServletContainer instance. |
Collection<org.apache.catalina.Valve> |
getEngineValves()
Returns a mutable collection of the
Valve s that will be applied to the
Tomcat Engine . |
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 the
TomcatConnectorCustomizer s that will be
applied to the Tomcat Context . |
Collection<TomcatContextCustomizer> |
getTomcatContextCustomizers()
Returns a mutable collection of the
TomcatContextCustomizer s that will be
applied to the Tomcat Context . |
protected TomcatEmbeddedServletContainer |
getTomcatEmbeddedServletContainer(org.apache.catalina.startup.Tomcat tomcat)
Factory method called to create the
TomcatEmbeddedServletContainer . |
Charset |
getUriEncoding()
Returns the character encoding to use for URL decoding.
|
protected void |
postProcessContext(org.apache.catalina.Context context)
Post process the Tomcat
Context before it 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)
Set
LifecycleListener s that should be applied to the Tomcat Context
. |
void |
setContextValves(Collection<? extends org.apache.catalina.Valve> contextValves)
Set
Valve s that should be applied to the Tomcat Context . |
void |
setEngineValves(Collection<? extends org.apache.catalina.Valve> engineValves)
Set
Valve s that should be applied to the Tomcat Engine . |
void |
setProtocol(String protocol)
The Tomcat protocol to use when create the
Connector . |
void |
setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader) |
void |
setTldSkip(String tldSkip)
Deprecated.
as of 1.5 in favor of
setTldSkipPatterns(Collection) |
void |
setTldSkipPatterns(Collection<String> patterns)
Set the patterns that match jars to ignore for TLD scanning.
|
void |
setTomcatConnectorCustomizers(Collection<? extends TomcatConnectorCustomizer> tomcatConnectorCustomizers)
Set
TomcatConnectorCustomizer s that should be applied to the Tomcat
Connector . |
void |
setTomcatContextCustomizers(Collection<? extends TomcatContextCustomizer> tomcatContextCustomizers)
Set
TomcatContextCustomizer s that should be applied to the Tomcat
Context . |
void |
setUriEncoding(Charset uriEncoding)
Set the character encoding to use for URL decoding.
|
createTempDir, getValidDocumentRoot, getValidSessionStoreDir, getValidSessionStoreDir
addErrorPages, addInitializers, getAddress, getCompression, getContextPath, getDisplayName, getDocumentRoot, getErrorPages, getJspServlet, getLocaleCharsetMappings, getMimeMappings, getPort, getServerHeader, getSessionStoreDir, getSessionTimeout, getSsl, getSslStoreProvider, isPersistSession, isRegisterDefaultServlet, mergeInitializers, setAddress, setCompression, setContextPath, setDisplayName, setDocumentRoot, setErrorPages, setInitializers, setJspServlet, setLocaleCharsetMappings, setMimeMappings, setPersistSession, setPort, setRegisterDefaultServlet, setServerHeader, setSessionStoreDir, setSessionTimeout, setSessionTimeout, setSsl, setSslStoreProvider, shouldRegisterJspServlet
public static final String DEFAULT_PROTOCOL
public TomcatEmbeddedServletContainerFactory()
TomcatEmbeddedServletContainerFactory
instance.public TomcatEmbeddedServletContainerFactory(int port)
TomcatEmbeddedServletContainerFactory
that listens for
requests using the specified port.port
- the port to listen onpublic TomcatEmbeddedServletContainerFactory(String contextPath, int port)
TomcatEmbeddedServletContainerFactory
with the specified
context path and port.contextPath
- the root context pathport
- the port to listen onpublic EmbeddedServletContainer getEmbeddedServletContainer(ServletContextInitializer... initializers)
EmbeddedServletContainerFactory
EmbeddedServletContainer
instance.
Clients should not be able to connect to the returned server until
EmbeddedServletContainer.start()
is called (which happens when the
ApplicationContext
has been fully refreshed).getEmbeddedServletContainer
in interface EmbeddedServletContainerFactory
initializers
- ServletContextInitializer
s that should be applied as
the container startsEmbeddedServletContainer
EmbeddedServletContainer.stop()
protected void prepareContext(org.apache.catalina.Host host, ServletContextInitializer[] initializers)
protected void customizeConnector(org.apache.catalina.connector.Connector connector)
protected void configureSsl(org.apache.coyote.http11.AbstractHttp11JsseProtocol<?> protocol, Ssl ssl)
AbstractHttp11JsseProtocol
for SSL.protocol
- the protocolssl
- the ssl detailsprotected void configureSslStoreProvider(org.apache.coyote.http11.AbstractHttp11JsseProtocol<?> protocol, SslStoreProvider sslStoreProvider)
protected void configureContext(org.apache.catalina.Context context, ServletContextInitializer[] initializers)
Context
.context
- the Tomcat contextinitializers
- initializers to applyprotected void postProcessContext(org.apache.catalina.Context context)
Context
before it used with the Tomcat Server.
Subclasses can override this method to apply additional processing to the
Context
.context
- the Tomcat Context
protected TomcatEmbeddedServletContainer getTomcatEmbeddedServletContainer(org.apache.catalina.startup.Tomcat tomcat)
TomcatEmbeddedServletContainer
.
Subclasses can override this method to return a different
TomcatEmbeddedServletContainer
or apply additional processing to the Tomcat
server.tomcat
- the Tomcat server.TomcatEmbeddedServletContainer
instancepublic void setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader)
setResourceLoader
in interface org.springframework.context.ResourceLoaderAware
public void setBaseDirectory(File baseDirectory)
baseDirectory
- the tomcat base directory@Deprecated public void setTldSkip(String tldSkip)
setTldSkipPatterns(Collection)
tldSkip
- the jars to skip when scanning for TLDs etcpublic Set<String> getTldSkipPatterns()
public void setTldSkipPatterns(Collection<String> patterns)
patterns
- the jar patterns to skip when scanning for TLDs etcpublic void addTldSkipPatterns(String... patterns)
patterns
- the additional jar patterns to skip when scanning for TLDs etcpublic void setProtocol(String protocol)
Connector
.protocol
- the protocolConnector.Connector(String)
public void setEngineValves(Collection<? extends org.apache.catalina.Valve> engineValves)
Valve
s that should be applied to the Tomcat Engine
. Calling
this method will replace any existing valves.engineValves
- the valves to setpublic Collection<org.apache.catalina.Valve> getEngineValves()
Valve
s that will be applied to the
Tomcat Engine
.public void addEngineValves(org.apache.catalina.Valve... engineValves)
Valve
s that should be applied to the Tomcat Engine
.engineValves
- the valves to addpublic void setContextValves(Collection<? extends org.apache.catalina.Valve> contextValves)
Valve
s that should be applied to the Tomcat Context
. Calling
this method will replace any existing valves.contextValves
- the valves to setpublic Collection<org.apache.catalina.Valve> getContextValves()
Valve
s that will be applied to the
Tomcat Context
.getEngineValves()
public void addContextValves(org.apache.catalina.Valve... contextValves)
Valve
s that should be applied to the Tomcat Context
.contextValves
- the valves to addpublic void setContextLifecycleListeners(Collection<? extends org.apache.catalina.LifecycleListener> contextLifecycleListeners)
LifecycleListener
s that should be applied to the Tomcat Context
. Calling this method will replace any existing listeners.contextLifecycleListeners
- the listeners to setpublic Collection<org.apache.catalina.LifecycleListener> getContextLifecycleListeners()
LifecycleListener
s that will be applied
to the Tomcat Context
.public void addContextLifecycleListeners(org.apache.catalina.LifecycleListener... contextLifecycleListeners)
LifecycleListener
s that should be added to the Tomcat Context
.contextLifecycleListeners
- the listeners to addpublic void setTomcatContextCustomizers(Collection<? extends TomcatContextCustomizer> tomcatContextCustomizers)
TomcatContextCustomizer
s that should be applied to the Tomcat
Context
. Calling this method will replace any existing customizers.tomcatContextCustomizers
- the customizers to setpublic Collection<TomcatContextCustomizer> getTomcatContextCustomizers()
TomcatContextCustomizer
s that will be
applied to the Tomcat Context
.public void addContextCustomizers(TomcatContextCustomizer... tomcatContextCustomizers)
TomcatContextCustomizer
s that should be added to the Tomcat
Context
.tomcatContextCustomizers
- the customizers to addpublic void setTomcatConnectorCustomizers(Collection<? extends TomcatConnectorCustomizer> tomcatConnectorCustomizers)
TomcatConnectorCustomizer
s that should be applied to the Tomcat
Connector
. Calling this method will replace any existing customizers.tomcatConnectorCustomizers
- the customizers to setpublic void addConnectorCustomizers(TomcatConnectorCustomizer... tomcatConnectorCustomizers)
TomcatContextCustomizer
s that should be added to the Tomcat
Connector
.tomcatConnectorCustomizers
- the customizers to addpublic Collection<TomcatConnectorCustomizer> getTomcatConnectorCustomizers()
TomcatConnectorCustomizer
s that will be
applied to the Tomcat Context
.public void addAdditionalTomcatConnectors(org.apache.catalina.connector.Connector... connectors)
Connector
s in addition to the default connector, e.g. for SSL or AJPconnectors
- the connectors to addpublic List<org.apache.catalina.connector.Connector> getAdditionalTomcatConnectors()
Connector
s that will be added to the
Tomcat.public void setUriEncoding(Charset uriEncoding)
uriEncoding
- the uri encoding to setpublic Charset getUriEncoding()
public void setBackgroundProcessorDelay(int delay)
delay
- the delay in secondsCopyright © 2017 Pivotal Software, Inc.. All rights reserved.