public abstract class AbstractEmbeddedServletContainerFactory extends Object implements ConfigurableEmbeddedServletContainerFactory
EmbeddedServletContainerFactory
implementations.Modifier and Type | Field and Description |
---|---|
protected org.apache.commons.logging.Log |
logger |
Constructor and Description |
---|
AbstractEmbeddedServletContainerFactory()
Create a new
AbstractEmbeddedServletContainerFactory instance. |
AbstractEmbeddedServletContainerFactory(int port)
Create a new
AbstractEmbeddedServletContainerFactory instance with the
specified port. |
AbstractEmbeddedServletContainerFactory(String contextPath,
int port)
Create a new
AbstractEmbeddedServletContainerFactory instance with the
specified context path and port. |
Modifier and Type | Method and Description |
---|---|
void |
addErrorPages(ErrorPage... errorPages)
Adds error pages that will be used when handling exceptions.
|
void |
addInitializers(ServletContextInitializer... initializers)
Add
ServletContextInitializer s to those that should be applied in addition
to EmbeddedServletContainerFactory.getEmbeddedServletContainer(ServletContextInitializer...) parameters. |
InetAddress |
getAddress() |
String |
getContextPath()
Returns the context path for the embedded servlet container.
|
File |
getDocumentRoot()
Returns the document root which will be used by the web context to serve static
files.
|
Set<ErrorPage> |
getErrorPages()
Returns a mutable set of
ErrorPage s that will be used when handling
exceptions. |
List<ServletContextInitializer> |
getInitializers()
Returns a mutable list of
ServletContextInitializer that should be applied
in addition to EmbeddedServletContainerFactory.getEmbeddedServletContainer(ServletContextInitializer...)
parameters. |
protected String |
getJspServletClassName() |
MimeMappings |
getMimeMappings()
Returns the mime-type mappings.
|
int |
getPort()
Returns the port that the embedded servlet container should listen on.
|
int |
getSessionTimeout() |
protected File |
getValidDocumentRoot()
Returns the absolute document root when it points to a valid folder, logging a
warning and returning
null otherwise. |
boolean |
isRegisterDefaultServlet()
Flag to indicate that the default servlet should be registered.
|
boolean |
isRegisterJspServlet()
Flag to indicate that the JSP servlet should be registered if available on the
classpath.
|
protected ServletContextInitializer[] |
mergeInitializers(ServletContextInitializer... initializers)
Utility method that can be used by subclasses wishing to combine the specified
ServletContextInitializer parameters with those defined in this instance. |
void |
setAddress(InetAddress address)
Sets the specific network address that the server should bind to.
|
void |
setContextPath(String contextPath)
Sets the context path for the embedded servlet container.
|
void |
setDocumentRoot(File documentRoot)
Sets the document root folder which will be used by the web context to serve static
files.
|
void |
setErrorPages(Set<ErrorPage> errorPages)
Sets the error pages that will be used when handling exceptions.
|
void |
setInitializers(List<? extends ServletContextInitializer> initializers)
Sets
ServletContextInitializer that should be applied in addition to
EmbeddedServletContainerFactory.getEmbeddedServletContainer(ServletContextInitializer...) parameters. |
void |
setJspServletClassName(String jspServletClassName)
The class name for the jsp servlet if used.
|
void |
setMimeMappings(MimeMappings mimeMappings)
Sets the mime-type mappings.
|
void |
setPort(int port)
Sets the port that the embedded servlet container should listen on.
|
void |
setRegisterDefaultServlet(boolean registerDefaultServlet)
Set if the DefaultServlet should be registered.
|
void |
setRegisterJspServlet(boolean registerJspServlet)
Set if the JspServlet should be registered if it is on the classpath.
|
void |
setSessionTimeout(int sessionTimeout)
The session timeout in seconds (default 30).
|
void |
setSessionTimeout(int sessionTimeout,
TimeUnit timeUnit)
The session timeout in the specified
TimeUnit (default 30 seconds). |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getEmbeddedServletContainer
public AbstractEmbeddedServletContainerFactory()
AbstractEmbeddedServletContainerFactory
instance.public AbstractEmbeddedServletContainerFactory(int port)
AbstractEmbeddedServletContainerFactory
instance with the
specified port.port
- the port number for the embedded servlet containerpublic AbstractEmbeddedServletContainerFactory(String contextPath, int port)
AbstractEmbeddedServletContainerFactory
instance with the
specified context path and port.contextPath
- the context path for the embedded servlet containerport
- the port number for the embedded servlet containerpublic void setContextPath(String contextPath)
ConfigurableEmbeddedServletContainerFactory
setContextPath
in interface ConfigurableEmbeddedServletContainerFactory
contextPath
- the contextPath to setpublic String getContextPath()
public void setPort(int port)
ConfigurableEmbeddedServletContainerFactory
setPort
in interface ConfigurableEmbeddedServletContainerFactory
port
- the port to setpublic int getPort()
getPort
in interface ConfigurableEmbeddedServletContainerFactory
public void setAddress(InetAddress address)
ConfigurableEmbeddedServletContainerFactory
setAddress
in interface ConfigurableEmbeddedServletContainerFactory
address
- the address to set (defaults to null
)public InetAddress getAddress()
public void setSessionTimeout(int sessionTimeout)
ConfigurableEmbeddedServletContainerFactory
setSessionTimeout
in interface ConfigurableEmbeddedServletContainerFactory
sessionTimeout
- the session timeoutpublic void setSessionTimeout(int sessionTimeout, TimeUnit timeUnit)
ConfigurableEmbeddedServletContainerFactory
TimeUnit
(default 30 seconds). If 0 or
negative then sessions never expire.setSessionTimeout
in interface ConfigurableEmbeddedServletContainerFactory
sessionTimeout
- the session timeouttimeUnit
- the time unitpublic int getSessionTimeout()
public void setInitializers(List<? extends ServletContextInitializer> initializers)
ConfigurableEmbeddedServletContainerFactory
ServletContextInitializer
that should be applied in addition to
EmbeddedServletContainerFactory.getEmbeddedServletContainer(ServletContextInitializer...)
parameters. This
method will replace any previously set or added initializers.setInitializers
in interface ConfigurableEmbeddedServletContainerFactory
initializers
- the initializers to setConfigurableEmbeddedServletContainerFactory.addInitializers(org.springframework.boot.context.embedded.ServletContextInitializer...)
public void addInitializers(ServletContextInitializer... initializers)
ConfigurableEmbeddedServletContainerFactory
ServletContextInitializer
s to those that should be applied in addition
to EmbeddedServletContainerFactory.getEmbeddedServletContainer(ServletContextInitializer...)
parameters.addInitializers
in interface ConfigurableEmbeddedServletContainerFactory
initializers
- the initializers to addConfigurableEmbeddedServletContainerFactory.setInitializers(java.util.List<? extends org.springframework.boot.context.embedded.ServletContextInitializer>)
public List<ServletContextInitializer> getInitializers()
ServletContextInitializer
that should be applied
in addition to EmbeddedServletContainerFactory.getEmbeddedServletContainer(ServletContextInitializer...)
parameters.public void setDocumentRoot(File documentRoot)
ConfigurableEmbeddedServletContainerFactory
setDocumentRoot
in interface ConfigurableEmbeddedServletContainerFactory
documentRoot
- the document root or null
if not requiredpublic File getDocumentRoot()
public void setErrorPages(Set<ErrorPage> errorPages)
ConfigurableEmbeddedServletContainerFactory
setErrorPages
in interface ConfigurableEmbeddedServletContainerFactory
errorPages
- the error pagespublic void addErrorPages(ErrorPage... errorPages)
ConfigurableEmbeddedServletContainerFactory
addErrorPages
in interface ConfigurableEmbeddedServletContainerFactory
errorPages
- the error pagespublic Set<ErrorPage> getErrorPages()
ErrorPage
s that will be used when handling
exceptions.public void setMimeMappings(MimeMappings mimeMappings)
ConfigurableEmbeddedServletContainerFactory
setMimeMappings
in interface ConfigurableEmbeddedServletContainerFactory
mimeMappings
- the mime type mappings (defaults to
MimeMappings.DEFAULT
)public MimeMappings getMimeMappings()
public void setRegisterDefaultServlet(boolean registerDefaultServlet)
ConfigurableEmbeddedServletContainerFactory
true
so that
files from the document root
will be served.setRegisterDefaultServlet
in interface ConfigurableEmbeddedServletContainerFactory
registerDefaultServlet
- if the default servlet should be registeredpublic boolean isRegisterJspServlet()
public void setRegisterJspServlet(boolean registerJspServlet)
ConfigurableEmbeddedServletContainerFactory
true
so that files from the document root
will be served.setRegisterJspServlet
in interface ConfigurableEmbeddedServletContainerFactory
registerJspServlet
- if the JSP servlet should be registeredpublic boolean isRegisterDefaultServlet()
public void setJspServletClassName(String jspServletClassName)
ConfigurableEmbeddedServletContainerFactory
registerJspServlet
is true
and this class is on the classpath then it will be registered. Since both
Tomcat and Jetty use Jasper for their JSP implementation the default is
org.apache.jasper.servlet.JspServlet
.setJspServletClassName
in interface ConfigurableEmbeddedServletContainerFactory
jspServletClassName
- the class name for the JSP servlet if usedprotected String getJspServletClassName()
protected final ServletContextInitializer[] mergeInitializers(ServletContextInitializer... initializers)
ServletContextInitializer
parameters with those defined in this instance.initializers
- the initializers to mergeprotected final File getValidDocumentRoot()
null
otherwise.Copyright © 2013. All rights reserved.