public class TomcatEmbeddedServletContainerFactory extends AbstractEmbeddedServletContainerFactory implements ResourceLoaderAware
EmbeddedServletContainerFactory that can be used to create
TomcatEmbeddedServletContainers. Can be initialized using Spring's
ServletContextInitializers or Tomcat LifecycleListeners.
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 |
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(Connector... connectors)
Add
Connectors in addition to the default connector, e.g. |
void |
addConnectorCustomizers(TomcatConnectorCustomizer... tomcatConnectorCustomizers)
Add
TomcatContextCustomizers that should be added to the Tomcat
Connector. |
void |
addContextCustomizers(TomcatContextCustomizer... tomcatContextCustomizers)
Add
TomcatContextCustomizers that should be added to the Tomcat
Context. |
void |
addContextLifecycleListeners(LifecycleListener... contextLifecycleListeners)
Add
LifecycleListeners that should be added to the Tomcat Context. |
void |
addContextValves(Valve... contextValves)
|
protected void |
configureContext(Context context,
ServletContextInitializer[] initializers)
Configure the Tomcat
Context. |
protected void |
configureSsl(AbstractHttp11JsseProtocol<?> protocol,
Ssl ssl)
Configure Tomcat's
AbstractHttp11JsseProtocol for SSL. |
protected void |
customizeConnector(Connector connector) |
List<Connector> |
getAdditionalTomcatConnectors()
Returns a mutable collection of the
Connectors that will be added to the
Tomcat |
Collection<LifecycleListener> |
getContextLifecycleListeners()
Returns a mutable collection of the
LifecycleListeners that will be applied
to the Tomcat Context . |
EmbeddedServletContainer |
getEmbeddedServletContainer(ServletContextInitializer... initializers)
Gets a new fully configured but paused
EmbeddedServletContainer instance. |
Collection<TomcatConnectorCustomizer> |
getTomcatConnectorCustomizers()
Returns a mutable collection of the
TomcatConnectorCustomizers that will be
applied to the Tomcat Context . |
Collection<TomcatContextCustomizer> |
getTomcatContextCustomizers()
Returns a mutable collection of the
TomcatContextCustomizers that will be
applied to the Tomcat Context . |
protected TomcatEmbeddedServletContainer |
getTomcatEmbeddedServletContainer(Tomcat tomcat)
Factory method called to create the
TomcatEmbeddedServletContainer. |
String |
getUriEncoding()
Returns the character encoding to use for URL decoding.
|
Collection<Valve> |
getValves()
|
protected void |
postProcessContext(Context context)
Post process the Tomcat
Context before it used with the Tomcat Server. |
protected void |
prepareContext(Host host,
ServletContextInitializer[] initializers) |
void |
setBaseDirectory(File baseDirectory)
Set the Tomcat base directory.
|
void |
setContextLifecycleListeners(Collection<? extends LifecycleListener> contextLifecycleListeners)
Set
LifecycleListeners that should be applied to the Tomcat Context
. |
void |
setContextValves(Collection<? extends Valve> contextValves)
|
void |
setProtocol(String protocol)
The Tomcat protocol to use when create the
Connector. |
void |
setResourceLoader(ResourceLoader resourceLoader) |
void |
setTldSkip(String tldSkip)
A comma-separated list of jars to ignore for TLD scanning.
|
void |
setTomcatConnectorCustomizers(Collection<? extends TomcatConnectorCustomizer> tomcatConnectorCustomizers)
Set
TomcatConnectorCustomizers that should be applied to the Tomcat
Connector . |
void |
setTomcatContextCustomizers(Collection<? extends TomcatContextCustomizer> tomcatContextCustomizers)
Set
TomcatContextCustomizers that should be applied to the Tomcat
Context . |
void |
setUriEncoding(String uriEncoding)
Set the character encoding to use for URL decoding.
|
getValidDocumentRootaddErrorPages, addInitializers, getAddress, getContextPath, getDocumentRoot, getErrorPages, getJspServletClassName, getMimeMappings, getPort, getSessionTimeout, getSsl, isRegisterDefaultServlet, isRegisterJspServlet, mergeInitializers, setAddress, setContextPath, setDocumentRoot, setErrorPages, setInitializers, setJspServletClassName, setMimeMappings, setPort, setRegisterDefaultServlet, setRegisterJspServlet, setSessionTimeout, setSessionTimeout, setSslpublic 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 - root the context pathport - the port to listen onpublic EmbeddedServletContainer getEmbeddedServletContainer(ServletContextInitializer... initializers)
EmbeddedServletContainerFactoryEmbeddedServletContainer 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 EmbeddedServletContainerFactoryinitializers - ServletContextInitializers that should be applied as
the container startsEmbeddedServletContainerEmbeddedServletContainer.stop()protected void prepareContext(Host host, ServletContextInitializer[] initializers)
protected void customizeConnector(Connector connector)
protected void configureSsl(AbstractHttp11JsseProtocol<?> protocol, Ssl ssl)
AbstractHttp11JsseProtocol for SSL.protocol - the protocolssl - the ssl detailsprotected void configureContext(Context context, ServletContextInitializer[] initializers)
Context.context - the Tomcat contextinitializers - initializers to applyprotected void postProcessContext(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 Contextprotected TomcatEmbeddedServletContainer getTomcatEmbeddedServletContainer(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(ResourceLoader resourceLoader)
setResourceLoader in interface ResourceLoaderAwarepublic void setBaseDirectory(File baseDirectory)
baseDirectory - the tomcat base directorypublic void setTldSkip(String tldSkip)
tldSkip - the jars to skip when scanning for TLDs etcpublic void setProtocol(String protocol)
Connector.protocol - the protocolConnector.Connector(String)public void setContextValves(Collection<? extends Valve> contextValves)
Valves that should be applied to the Tomcat Context. Calling
this method will replace any existing listeners.contextValves - the valves to setpublic Collection<Valve> getValves()
public void addContextValves(Valve... contextValves)
contextValves - the valves to addpublic void setContextLifecycleListeners(Collection<? extends LifecycleListener> contextLifecycleListeners)
LifecycleListeners that should be applied to the Tomcat Context
. Calling this method will replace any existing listeners.contextLifecycleListeners - the listeners to setpublic Collection<LifecycleListener> getContextLifecycleListeners()
LifecycleListeners that will be applied
to the Tomcat Context .public void addContextLifecycleListeners(LifecycleListener... contextLifecycleListeners)
LifecycleListeners that should be added to the Tomcat Context.contextLifecycleListeners - the listeners to addpublic void setTomcatContextCustomizers(Collection<? extends TomcatContextCustomizer> tomcatContextCustomizers)
TomcatContextCustomizers that should be applied to the Tomcat
Context . Calling this method will replace any existing customizers.tomcatContextCustomizers - the customizers to setpublic Collection<TomcatContextCustomizer> getTomcatContextCustomizers()
TomcatContextCustomizers that will be
applied to the Tomcat Context .public void addContextCustomizers(TomcatContextCustomizer... tomcatContextCustomizers)
TomcatContextCustomizers that should be added to the Tomcat
Context.tomcatContextCustomizers - the customizers to addpublic void setTomcatConnectorCustomizers(Collection<? extends TomcatConnectorCustomizer> tomcatConnectorCustomizers)
TomcatConnectorCustomizers 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)
TomcatContextCustomizers that should be added to the Tomcat
Connector.tomcatConnectorCustomizers - the customizers to addpublic Collection<TomcatConnectorCustomizer> getTomcatConnectorCustomizers()
TomcatConnectorCustomizers that will be
applied to the Tomcat Context .public void addAdditionalTomcatConnectors(Connector... connectors)
Connectors in addition to the default connector, e.g. for SSL or AJPconnectors - the connectors to addpublic List<Connector> getAdditionalTomcatConnectors()
Connectors that will be added to the
Tomcatpublic void setUriEncoding(String uriEncoding)
uriEncoding - the uri encoding to setpublic String getUriEncoding()
Copyright © 2015 Pivotal Software, Inc.. All rights reserved.