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
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreate a newAbstractServletWebServerFactoryinstance.AbstractServletWebServerFactory(int port) Create a newAbstractServletWebServerFactoryinstance with the specified port.AbstractServletWebServerFactory(String contextPath, int port) Create a newAbstractServletWebServerFactoryinstance with the specified context path and port. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCookieSameSiteSuppliers(CookieSameSiteSupplier... cookieSameSiteSuppliers) AddCookieSameSiteSuppliersto those that should be used to obtain theCookie.SameSiteattribute of any added cookie.voidaddInitializers(ServletContextInitializer... initializers) AddServletContextInitializers to those that should be applied in addition toServletWebServerFactory.getWebServer(ServletContextInitializer...)parameters.voidaddMimeMappings(MimeMappings mimeMappings) Adds mime-type mappings.voidaddWebListeners(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 FileReturns the absolute document root when it points to a valid directory, logging a warning and returningnullotherwise.protected final Fileprotected final FilegetValidSessionStoreDir(boolean mkdirs) booleanFlag 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 specifiedServletContextInitializerparameters with those defined in this instance.voidsetContextPath(String contextPath) Sets the context path for the web server.voidsetCookieSameSiteSuppliers(List<? extends CookieSameSiteSupplier> cookieSameSiteSuppliers) SetsCookieSameSiteSuppliersthat should be used to obtain theCookie.SameSiteattribute of any added cookie.voidsetDisplayName(String displayName) Sets the display name of the application deployed in the web server.voidsetDocumentRoot(File documentRoot) Sets the document root directory which will be used by the web context to serve static files.voidsetInitializers(List<? extends ServletContextInitializer> initializers) SetsServletContextInitializerthat should be applied in addition toServletWebServerFactory.getWebServer(ServletContextInitializer...)parameters.voidsetInitParameters(Map<String, String> initParameters) Sets the init parameters that are applied to the container'sServletContext.voidSets the configuration that will be applied to the server's JSP servlet.voidsetLocaleCharsetMappings(Map<Locale, Charset> localeCharsetMappings) Sets the Locale to Charset mappings.voidsetMimeMappings(MimeMappings mimeMappings) Sets the mime-type mappings.voidsetRegisterDefaultServlet(boolean registerDefaultServlet) Set if the DefaultServlet should be registered.voidsetSession(Session session) Sets the configuration that will be applied to the container's HTTP session support.protected booleanReturns whether 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, getServerNameSslBundles, getShutdown, getSsl, getSslBundle, getSslBundles, setAddress, setCompression, setErrorPages, setHttp2, setPort, setServerHeader, setShutdown, setSsl, setSslBundlesMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.boot.web.server.ConfigurableWebServerFactory
setAddress, setCompression, setErrorPages, setHttp2, setPort, setServerHeader, setShutdown, setSsl, setSslBundlesMethods inherited from interface org.springframework.boot.web.server.ErrorPageRegistry
addErrorPagesMethods inherited from interface org.springframework.boot.web.servlet.server.ServletWebServerFactory
getWebServer
-
Field Details
-
logger
-
-
Constructor Details
-
AbstractServletWebServerFactory
public AbstractServletWebServerFactory()Create a newAbstractServletWebServerFactoryinstance. -
AbstractServletWebServerFactory
public AbstractServletWebServerFactory(int port) Create a newAbstractServletWebServerFactoryinstance with the specified port.- Parameters:
port- the port number for the web server
-
AbstractServletWebServerFactory
Create a newAbstractServletWebServerFactoryinstance 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:ConfigurableServletWebServerFactorySets 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:
setContextPathin interfaceConfigurableServletWebServerFactory- Parameters:
contextPath- the contextPath to set
-
getDisplayName
-
setDisplayName
Description copied from interface:ConfigurableServletWebServerFactorySets the display name of the application deployed in the web server.- Specified by:
setDisplayNamein 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:ConfigurableServletWebServerFactorySet if the DefaultServlet should be registered. Defaults tofalsesince 2.4.- Specified by:
setRegisterDefaultServletin 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:ConfigurableServletWebServerFactorySets the mime-type mappings.- Specified by:
setMimeMappingsin interfaceConfigurableServletWebServerFactory- Parameters:
mimeMappings- the mime type mappings (defaults toMimeMappings.DEFAULT)
-
addMimeMappings
Description copied from interface:ConfigurableServletWebServerFactoryAdds mime-type mappings.- Specified by:
addMimeMappingsin interfaceConfigurableServletWebServerFactory- Parameters:
mimeMappings- the mime type mappings to add
-
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:ConfigurableServletWebServerFactorySets the document root directory which will be used by the web context to serve static files.- Specified by:
setDocumentRootin interfaceConfigurableServletWebServerFactory- Parameters:
documentRoot- the document root ornullif not required
-
setInitializers
Description copied from interface:ConfigurableServletWebServerFactorySetsServletContextInitializerthat should be applied in addition toServletWebServerFactory.getWebServer(ServletContextInitializer...)parameters. This method will replace any previously set or added initializers.- Specified by:
setInitializersin interfaceConfigurableServletWebServerFactory- Parameters:
initializers- the initializers to set- See Also:
-
addInitializers
Description copied from interface:ConfigurableServletWebServerFactoryAddServletContextInitializers to those that should be applied in addition toServletWebServerFactory.getWebServer(ServletContextInitializer...)parameters.- Specified by:
addInitializersin interfaceConfigurableServletWebServerFactory- Parameters:
initializers- the initializers to add- See Also:
-
getJsp
-
setJsp
Description copied from interface:ConfigurableServletWebServerFactorySets the configuration that will be applied to the server's JSP servlet.- Specified by:
setJspin interfaceConfigurableServletWebServerFactory- Parameters:
jsp- the JSP servlet configuration
-
getSession
-
setSession
Description copied from interface:ConfigurableServletWebServerFactorySets the configuration that will be applied to the container's HTTP session support.- Specified by:
setSessionin interfaceConfigurableServletWebServerFactory- Parameters:
session- the session configuration
-
getLocaleCharsetMappings
Return the Locale to Charset mappings.- Returns:
- the charset mappings
-
setLocaleCharsetMappings
Description copied from interface:ConfigurableServletWebServerFactorySets the Locale to Charset mappings.- Specified by:
setLocaleCharsetMappingsin interfaceConfigurableServletWebServerFactory- Parameters:
localeCharsetMappings- the Locale to Charset mappings
-
setInitParameters
Description copied from interface:ConfigurableServletWebServerFactorySets the init parameters that are applied to the container'sServletContext.- Specified by:
setInitParametersin interfaceConfigurableServletWebServerFactory- Parameters:
initParameters- the init parameters
-
getInitParameters
-
setCookieSameSiteSuppliers
public void setCookieSameSiteSuppliers(List<? extends CookieSameSiteSupplier> cookieSameSiteSuppliers) Description copied from interface:ConfigurableServletWebServerFactorySetsCookieSameSiteSuppliersthat should be used to obtain theCookie.SameSiteattribute of any added cookie. This method will replace any previously set or added suppliers.- Specified by:
setCookieSameSiteSuppliersin interfaceConfigurableServletWebServerFactory- Parameters:
cookieSameSiteSuppliers- the suppliers to add- See Also:
-
addCookieSameSiteSuppliers
Description copied from interface:ConfigurableServletWebServerFactoryAddCookieSameSiteSuppliersto those that should be used to obtain theCookie.SameSiteattribute of any added cookie.- Specified by:
addCookieSameSiteSuppliersin 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 specifiedServletContextInitializerparameters 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 the JSP servlet should be registered with the web server.- Returns:
trueif the servlet should be registered, otherwisefalse
-
getValidDocumentRoot
Returns the absolute document root when it points to a valid directory, logging a warning and returningnullotherwise.- Returns:
- the valid document root
-
getUrlsOfJarsWithMetaInfResources
-
getValidSessionStoreDir
-
getValidSessionStoreDir
-
addWebListeners
Description copied from interface:WebListenerRegistryAdds web listeners that will be registered with the servlet container.- Specified by:
addWebListenersin interfaceWebListenerRegistry- Parameters:
webListenerClassNames- the class names of the web listeners
-
getWebListenerClassNames
-