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
,WebListenerRegistry
- Direct Known Subclasses:
JettyServletWebServerFactory
,TomcatServletWebServerFactory
,UndertowServletWebServerFactory
public abstract class AbstractServletWebServerFactory
extends AbstractConfigurableWebServerFactory
implements ConfigurableServletWebServerFactory
Abstract base class for
ConfigurableServletWebServerFactory
implementations.- Since:
- 2.0.0
- Author:
- Phillip Webb, Dave Syer, Andy Wilkinson, Stephane Nicoll, Ivan Sopov, EddĂș MelĂ©ndez, Brian Clozel
-
Field Summary
-
Constructor Summary
ConstructorDescriptionCreate 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
Modifier and TypeMethodDescriptionvoid
addCookieSameSiteSuppliers
(CookieSameSiteSupplier... cookieSameSiteSuppliers) AddCookieSameSiteSuppliers
to those that should be used to obtain theCookie.SameSite
attribute of any added cookie.void
addInitializers
(ServletContextInitializer... initializers) AddServletContextInitializer
s to those that should be applied in addition toServletWebServerFactory.getWebServer(ServletContextInitializer...)
parameters.void
addWebListeners
(String... webListenerClassNames) Adds web listeners that will be registered with the servlet container.Returns the context path for the web server.Returns the document root which will be used by the web context to serve static files.getJsp()
Return the Locale to Charset mappings.Returns the mime-type mappings.protected final File
Returns the absolute document root when it points to a valid directory, logging a warning and returningnull
otherwise.protected final File
protected final File
getValidSessionStoreDir
(boolean mkdirs) boolean
Flag to indicate that the default servlet should be registered.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.void
setContextPath
(String contextPath) Sets the context path for the web server.void
setCookieSameSiteSuppliers
(List<? extends CookieSameSiteSupplier> cookieSameSiteSuppliers) SetsCookieSameSiteSuppliers
that should be used to obtain theCookie.SameSite
attribute of any added cookie.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
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
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, getOrCreateSslStoreProvider, getPort, getServerHeader, getShutdown, getSsl, getSslStoreProvider, setAddress, setCompression, setErrorPages, setHttp2, setPort, setServerHeader, setShutdown, 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, setShutdown, 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 Details
-
logger
-
-
Constructor Details
-
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
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 Details
-
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
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
-
setDisplayName
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 tofalse
since 2.4.- Specified by:
setRegisterDefaultServlet
in interfaceConfigurableServletWebServerFactory
- Parameters:
registerDefaultServlet
- if the default servlet should be registered
-
getMimeMappings
Returns the mime-type mappings.- Returns:
- the mimeMappings the mime-type mappings.
-
setMimeMappings
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
Returns the document root which will be used by the web context to serve static files.- Returns:
- the document root
-
setDocumentRoot
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
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:
-
addInitializers
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:
-
getJsp
-
setJsp
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
-
setSession
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
Return the Locale to Charset mappings.- Returns:
- the charset mappings
-
setLocaleCharsetMappings
Description copied from interface:ConfigurableServletWebServerFactory
Sets the Locale to Charset mappings.- Specified by:
setLocaleCharsetMappings
in interfaceConfigurableServletWebServerFactory
- Parameters:
localeCharsetMappings
- the Locale to Charset mappings
-
setInitParameters
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
-
setCookieSameSiteSuppliers
public void setCookieSameSiteSuppliers(List<? extends CookieSameSiteSupplier> cookieSameSiteSuppliers) Description copied from interface:ConfigurableServletWebServerFactory
SetsCookieSameSiteSuppliers
that should be used to obtain theCookie.SameSite
attribute of any added cookie. This method will replace any previously set or added suppliers.- Specified by:
setCookieSameSiteSuppliers
in interfaceConfigurableServletWebServerFactory
- Parameters:
cookieSameSiteSuppliers
- the suppliers to add- See Also:
-
addCookieSameSiteSuppliers
Description copied from interface:ConfigurableServletWebServerFactory
AddCookieSameSiteSuppliers
to those that should be used to obtain theCookie.SameSite
attribute of any added cookie.- Specified by:
addCookieSameSiteSuppliers
in interfaceConfigurableServletWebServerFactory
- Parameters:
cookieSameSiteSuppliers
- the suppliers to add- See Also:
-
getCookieSameSiteSuppliers
-
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
Returns the absolute document root when it points to a valid directory, logging a warning and returningnull
otherwise.- Returns:
- the valid document root
-
getUrlsOfJarsWithMetaInfResources
-
getValidSessionStoreDir
-
getValidSessionStoreDir
-
addWebListeners
Description copied from interface:WebListenerRegistry
Adds web listeners that will be registered with the servlet container.- Specified by:
addWebListeners
in interfaceWebListenerRegistry
- Parameters:
webListenerClassNames
- the class names of the web listeners
-
getWebListenerClassNames
-