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 SummaryFields
- 
Constructor SummaryConstructorsConstructorDescriptionCreate 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 SummaryModifier 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.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.AbstractConfigurableWebServerFactoryaddErrorPages, createTempDir, getAddress, getCompression, getErrorPages, getHttp2, getOrCreateSslStoreProvider, getPort, getServerHeader, getShutdown, getSsl, getSslBundle, getSslBundles, getSslStoreProvider, setAddress, setCompression, setErrorPages, setHttp2, setPort, setServerHeader, setShutdown, setSsl, setSslBundles, setSslStoreProviderMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.boot.web.server.ConfigurableWebServerFactorysetAddress, setCompression, setErrorPages, setHttp2, setPort, setServerHeader, setShutdown, setSsl, setSslBundles, setSslStoreProviderMethods inherited from interface org.springframework.boot.web.server.ErrorPageRegistryaddErrorPagesMethods inherited from interface org.springframework.boot.web.servlet.server.ServletWebServerFactorygetWebServer
- 
Field Details- 
logger
 
- 
- 
Constructor Details- 
AbstractServletWebServerFactorypublic AbstractServletWebServerFactory()Create a newAbstractServletWebServerFactoryinstance.
- 
AbstractServletWebServerFactorypublic AbstractServletWebServerFactory(int port) Create a newAbstractServletWebServerFactoryinstance with the specified port.- Parameters:
- port- the port number for the web server
 
- 
AbstractServletWebServerFactoryCreate a newAbstractServletWebServerFactoryinstance with the specified context path and port.- Parameters:
- contextPath- the context path for the web server
- port- the port number for the web server
 
 
- 
- 
Method Details- 
getContextPathReturns 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
 
- 
setContextPathDescription 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 interface- ConfigurableServletWebServerFactory
- Parameters:
- contextPath- the contextPath to set
 
- 
getDisplayName
- 
setDisplayNameDescription copied from interface:ConfigurableServletWebServerFactorySets the display name of the application deployed in the web server.- Specified by:
- setDisplayNamein interface- ConfigurableServletWebServerFactory
- Parameters:
- displayName- the displayName to set
 
- 
isRegisterDefaultServletpublic boolean isRegisterDefaultServlet()Flag to indicate that the default servlet should be registered.- Returns:
- true if the default servlet is to be registered
 
- 
setRegisterDefaultServletpublic void setRegisterDefaultServlet(boolean registerDefaultServlet) Description copied from interface:ConfigurableServletWebServerFactorySet if the DefaultServlet should be registered. Defaults tofalsesince 2.4.- Specified by:
- setRegisterDefaultServletin interface- ConfigurableServletWebServerFactory
- Parameters:
- registerDefaultServlet- if the default servlet should be registered
 
- 
getMimeMappingsReturns the mime-type mappings.- Returns:
- the mimeMappings the mime-type mappings.
 
- 
setMimeMappingsDescription copied from interface:ConfigurableServletWebServerFactorySets the mime-type mappings.- Specified by:
- setMimeMappingsin interface- ConfigurableServletWebServerFactory
- Parameters:
- mimeMappings- the mime type mappings (defaults to- MimeMappings.DEFAULT)
 
- 
getDocumentRootReturns the document root which will be used by the web context to serve static files.- Returns:
- the document root
 
- 
setDocumentRootDescription copied from interface:ConfigurableServletWebServerFactorySets the document root directory which will be used by the web context to serve static files.- Specified by:
- setDocumentRootin interface- ConfigurableServletWebServerFactory
- Parameters:
- documentRoot- the document root or- nullif not required
 
- 
setInitializersDescription 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 interface- ConfigurableServletWebServerFactory
- Parameters:
- initializers- the initializers to set
- See Also:
 
- 
addInitializersDescription copied from interface:ConfigurableServletWebServerFactoryAddServletContextInitializers to those that should be applied in addition toServletWebServerFactory.getWebServer(ServletContextInitializer...)parameters.- Specified by:
- addInitializersin interface- ConfigurableServletWebServerFactory
- Parameters:
- initializers- the initializers to add
- See Also:
 
- 
getJsp
- 
setJspDescription copied from interface:ConfigurableServletWebServerFactorySets the configuration that will be applied to the server's JSP servlet.- Specified by:
- setJspin interface- ConfigurableServletWebServerFactory
- Parameters:
- jsp- the JSP servlet configuration
 
- 
getSession
- 
setSessionDescription copied from interface:ConfigurableServletWebServerFactorySets the configuration that will be applied to the container's HTTP session support.- Specified by:
- setSessionin interface- ConfigurableServletWebServerFactory
- Parameters:
- session- the session configuration
 
- 
getLocaleCharsetMappingsReturn the Locale to Charset mappings.- Returns:
- the charset mappings
 
- 
setLocaleCharsetMappingsDescription copied from interface:ConfigurableServletWebServerFactorySets the Locale to Charset mappings.- Specified by:
- setLocaleCharsetMappingsin interface- ConfigurableServletWebServerFactory
- Parameters:
- localeCharsetMappings- the Locale to Charset mappings
 
- 
setInitParametersDescription copied from interface:ConfigurableServletWebServerFactorySets the init parameters that are applied to the container'sServletContext.- Specified by:
- setInitParametersin interface- ConfigurableServletWebServerFactory
- Parameters:
- initParameters- the init parameters
 
- 
getInitParameters
- 
setCookieSameSiteSupplierspublic 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 interface- ConfigurableServletWebServerFactory
- Parameters:
- cookieSameSiteSuppliers- the suppliers to add
- See Also:
 
- 
addCookieSameSiteSuppliersDescription copied from interface:ConfigurableServletWebServerFactoryAddCookieSameSiteSuppliersto those that should be used to obtain theCookie.SameSiteattribute of any added cookie.- Specified by:
- addCookieSameSiteSuppliersin interface- ConfigurableServletWebServerFactory
- Parameters:
- cookieSameSiteSuppliers- the suppliers to add
- See Also:
 
- 
getCookieSameSiteSuppliers
- 
mergeInitializersprotected 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)
 
- 
shouldRegisterJspServletprotected boolean shouldRegisterJspServlet()Returns whether the JSP servlet should be registered with the web server.- Returns:
- trueif the servlet should be registered, otherwise- false
 
- 
getValidDocumentRootReturns the absolute document root when it points to a valid directory, logging a warning and returningnullotherwise.- Returns:
- the valid document root
 
- 
getUrlsOfJarsWithMetaInfResources
- 
getValidSessionStoreDir
- 
getValidSessionStoreDir
- 
addWebListenersDescription copied from interface:WebListenerRegistryAdds web listeners that will be registered with the servlet container.- Specified by:
- addWebListenersin interface- WebListenerRegistry
- Parameters:
- webListenerClassNames- the class names of the web listeners
 
- 
getWebListenerClassNames
 
-