Class AbstractServletWebServerFactory
- java.lang.Object
- org.springframework.boot.web.server.AbstractConfigurableWebServerFactory
- org.springframework.boot.web.servlet.server.AbstractServletWebServerFactory
- All Implemented Interfaces:
ConfigurableWebServerFactory
,ErrorPageRegistry
,WebServerFactory
,ConfigurableServletWebServerFactory
,ServletWebServerFactory
- Direct Known Subclasses:
JettyServletWebServerFactory
,TomcatServletWebServerFactory
,UndertowServletWebServerFactory
public abstract class AbstractServletWebServerFactory extends AbstractConfigurableWebServerFactory implements ConfigurableServletWebServerFactory
Abstract base class forConfigurableServletWebServerFactory
implementations.- Since:
- 2.0.0
Field Summary
Fields Modifier and Type Field Description protected org.apache.commons.logging.Log
logger
Constructor Summary
Constructors Constructor Description AbstractServletWebServerFactory()
Create a newAbstractServletWebServerFactory
instance.AbstractServletWebServerFactory(int port)
Create a newAbstractServletWebServerFactory
instance with the specified port.AbstractServletWebServerFactory(String contextPath, int port)
Create a newAbstractServletWebServerFactory
instance with the specified context path and port.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addInitializers(ServletContextInitializer... initializers)
AddServletContextInitializer
s to those that should be applied in addition toServletWebServerFactory.getWebServer(ServletContextInitializer...)
parameters.String
getContextPath()
Returns the context path for the web server.String
getDisplayName()
File
getDocumentRoot()
Returns the document root which will be used by the web context to serve static files.Map<String,String>
getInitParameters()
Jsp
getJsp()
Map<Locale,Charset>
getLocaleCharsetMappings()
Return the Locale to Charset mappings.MimeMappings
getMimeMappings()
Returns the mime-type mappings.Session
getSession()
protected List<URL>
getUrlsOfJarsWithMetaInfResources()
protected File
getValidDocumentRoot()
Returns the absolute document root when it points to a valid directory, logging a warning and returningnull
otherwise.protected File
getValidSessionStoreDir()
protected File
getValidSessionStoreDir(boolean mkdirs)
boolean
isRegisterDefaultServlet()
Flag to indicate that the default servlet should be registered.protected ServletContextInitializer[]
mergeInitializers(ServletContextInitializer... initializers)
Utility method that can be used by subclasses wishing to combine the specifiedServletContextInitializer
parameters with those defined in this instance.void
setContextPath(String contextPath)
Sets the context path for the web server.void
setDisplayName(String displayName)
Sets the display name of the application deployed in the web server.void
setDocumentRoot(File documentRoot)
Sets the document root directory which will be used by the web context to serve static files.void
setInitializers(List<? extends ServletContextInitializer> initializers)
SetsServletContextInitializer
that should be applied in addition toServletWebServerFactory.getWebServer(ServletContextInitializer...)
parameters.void
setInitParameters(Map<String,String> initParameters)
Sets the init parameters that are applied to the container'sServletContext
.void
setJsp(Jsp jsp)
Sets the configuration that will be applied to the server's JSP servlet.void
setLocaleCharsetMappings(Map<Locale,Charset> localeCharsetMappings)
Sets the Locale to Charset mappings.void
setMimeMappings(MimeMappings mimeMappings)
Sets the mime-type mappings.void
setRegisterDefaultServlet(boolean registerDefaultServlet)
Set if the DefaultServlet should be registered.void
setSession(Session session)
Sets the configuration that will be applied to the container's HTTP session support.protected boolean
shouldRegisterJspServlet()
Returns whether or not the JSP servlet should be registered with the web server.Methods inherited from class org.springframework.boot.web.server.AbstractConfigurableWebServerFactory
addErrorPages, createTempDir, getAddress, getCompression, getErrorPages, getHttp2, getPort, getServerHeader, getSsl, getSslStoreProvider, setAddress, setCompression, setErrorPages, setHttp2, setPort, setServerHeader, setSsl, setSslStoreProvider
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.boot.web.server.ConfigurableWebServerFactory
setAddress, setCompression, setErrorPages, setHttp2, setPort, setServerHeader, setSsl, setSslStoreProvider
Methods inherited from interface org.springframework.boot.web.server.ErrorPageRegistry
addErrorPages
Methods inherited from interface org.springframework.boot.web.servlet.server.ServletWebServerFactory
getWebServer
Field Detail
logger
protected final org.apache.commons.logging.Log logger
Constructor Detail
AbstractServletWebServerFactory
public AbstractServletWebServerFactory()
Create a newAbstractServletWebServerFactory
instance.
AbstractServletWebServerFactory
public AbstractServletWebServerFactory(int port)
Create a newAbstractServletWebServerFactory
instance with the specified port.- Parameters:
port
- the port number for the web server
AbstractServletWebServerFactory
public AbstractServletWebServerFactory(String contextPath, int port)
Create a newAbstractServletWebServerFactory
instance with the specified context path and port.- Parameters:
contextPath
- the context path for the web serverport
- the port number for the web server
Method Detail
getContextPath
public String getContextPath()
Returns the context path for the web server. The path will start with "/" and not end with "/". The root context is represented by an empty string.- Returns:
- the context path
setContextPath
public void setContextPath(String contextPath)
Description copied from interface:ConfigurableServletWebServerFactory
Sets the context path for the web server. The context should start with a "/" character but not end with a "/" character. The default context path can be specified using an empty string.- Specified by:
setContextPath
in interfaceConfigurableServletWebServerFactory
- Parameters:
contextPath
- the contextPath to set
getDisplayName
public String getDisplayName()
setDisplayName
public void setDisplayName(String displayName)
Description copied from interface:ConfigurableServletWebServerFactory
Sets the display name of the application deployed in the web server.- Specified by:
setDisplayName
in interfaceConfigurableServletWebServerFactory
- Parameters:
displayName
- the displayName to set
isRegisterDefaultServlet
public boolean isRegisterDefaultServlet()
Flag to indicate that the default servlet should be registered.- Returns:
- true if the default servlet is to be registered
setRegisterDefaultServlet
public void setRegisterDefaultServlet(boolean registerDefaultServlet)
Description copied from interface:ConfigurableServletWebServerFactory
Set if the DefaultServlet should be registered. Defaults totrue
so that files from thedocument root
will be served.- Specified by:
setRegisterDefaultServlet
in interfaceConfigurableServletWebServerFactory
- Parameters:
registerDefaultServlet
- if the default servlet should be registered
getMimeMappings
public MimeMappings getMimeMappings()
Returns the mime-type mappings.- Returns:
- the mimeMappings the mime-type mappings.
setMimeMappings
public void setMimeMappings(MimeMappings mimeMappings)
Description copied from interface:ConfigurableServletWebServerFactory
Sets the mime-type mappings.- Specified by:
setMimeMappings
in interfaceConfigurableServletWebServerFactory
- Parameters:
mimeMappings
- the mime type mappings (defaults toMimeMappings.DEFAULT
)
getDocumentRoot
public File getDocumentRoot()
Returns the document root which will be used by the web context to serve static files.- Returns:
- the document root
setDocumentRoot
public void setDocumentRoot(File documentRoot)
Description copied from interface:ConfigurableServletWebServerFactory
Sets the document root directory which will be used by the web context to serve static files.- Specified by:
setDocumentRoot
in interfaceConfigurableServletWebServerFactory
- Parameters:
documentRoot
- the document root ornull
if not required
setInitializers
public void setInitializers(List<? extends ServletContextInitializer> initializers)
Description copied from interface:ConfigurableServletWebServerFactory
SetsServletContextInitializer
that should be applied in addition toServletWebServerFactory.getWebServer(ServletContextInitializer...)
parameters. This method will replace any previously set or added initializers.- Specified by:
setInitializers
in interfaceConfigurableServletWebServerFactory
- Parameters:
initializers
- the initializers to set- See Also:
ConfigurableServletWebServerFactory.addInitializers(org.springframework.boot.web.servlet.ServletContextInitializer...)
addInitializers
public void addInitializers(ServletContextInitializer... initializers)
Description copied from interface:ConfigurableServletWebServerFactory
AddServletContextInitializer
s to those that should be applied in addition toServletWebServerFactory.getWebServer(ServletContextInitializer...)
parameters.- Specified by:
addInitializers
in interfaceConfigurableServletWebServerFactory
- Parameters:
initializers
- the initializers to add- See Also:
ConfigurableServletWebServerFactory.setInitializers(java.util.List<? extends org.springframework.boot.web.servlet.ServletContextInitializer>)
setJsp
public void setJsp(Jsp jsp)
Description copied from interface:ConfigurableServletWebServerFactory
Sets the configuration that will be applied to the server's JSP servlet.- Specified by:
setJsp
in interfaceConfigurableServletWebServerFactory
- Parameters:
jsp
- the JSP servlet configuration
getSession
public Session getSession()
setSession
public void setSession(Session session)
Description copied from interface:ConfigurableServletWebServerFactory
Sets the configuration that will be applied to the container's HTTP session support.- Specified by:
setSession
in interfaceConfigurableServletWebServerFactory
- Parameters:
session
- the session configuration
getLocaleCharsetMappings
public Map<Locale,Charset> getLocaleCharsetMappings()
Return the Locale to Charset mappings.- Returns:
- the charset mappings
setLocaleCharsetMappings
public void setLocaleCharsetMappings(Map<Locale,Charset> localeCharsetMappings)
Description copied from interface:ConfigurableServletWebServerFactory
Sets the Locale to Charset mappings.- Specified by:
setLocaleCharsetMappings
in interfaceConfigurableServletWebServerFactory
- Parameters:
localeCharsetMappings
- the Locale to Charset mappings
setInitParameters
public void setInitParameters(Map<String,String> initParameters)
Description copied from interface:ConfigurableServletWebServerFactory
Sets the init parameters that are applied to the container'sServletContext
.- Specified by:
setInitParameters
in interfaceConfigurableServletWebServerFactory
- Parameters:
initParameters
- the init parameters
getInitParameters
public Map<String,String> getInitParameters()
mergeInitializers
protected final ServletContextInitializer[] mergeInitializers(ServletContextInitializer... initializers)
Utility method that can be used by subclasses wishing to combine the specifiedServletContextInitializer
parameters with those defined in this instance.- Parameters:
initializers
- the initializers to merge- Returns:
- a complete set of merged initializers (with the specified parameters appearing first)
shouldRegisterJspServlet
protected boolean shouldRegisterJspServlet()
Returns whether or not the JSP servlet should be registered with the web server.- Returns:
true
if the servlet should be registered, otherwisefalse
getValidDocumentRoot
protected final File getValidDocumentRoot()
Returns the absolute document root when it points to a valid directory, logging a warning and returningnull
otherwise.- Returns:
- the valid document root
getUrlsOfJarsWithMetaInfResources
protected final List<URL> getUrlsOfJarsWithMetaInfResources()
getValidSessionStoreDir
protected final File getValidSessionStoreDir()
getValidSessionStoreDir
protected final File getValidSessionStoreDir(boolean mkdirs)