Class AbstractMessageDispatcherServletInitializer
- All Implemented Interfaces:
org.springframework.web.WebApplicationInitializer
- Direct Known Subclasses:
AbstractAnnotationConfigMessageDispatcherServletInitializer
WebApplicationInitializer
implementations
that register a MessageDispatcherServlet
in the servlet context.
Concrete implementations are required to implement createServletApplicationContext()
, which gets invoked
from registerMessageDispatcherServlet(ServletContext)
. Further customization can be achieved by overriding
customizeRegistration(ServletRegistration.Dynamic)
.
Because this class extends from AbstractContextLoaderInitializer
, concrete implementations are also required
to implement AbstractContextLoaderInitializer.createRootApplicationContext()
to set up a parent "root" application context.
If a root context is not desired, implementations can simply return null
in the
createRootApplicationContext()
implementation.
- Since:
- 2.2
- Author:
- Arjen Poutsma
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String[]
The default servlet mappings.static final String
The default servlet name.Fields inherited from class org.springframework.web.context.AbstractContextLoaderInitializer
logger
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract org.springframework.web.context.WebApplicationContext
Create a servlet application context to be provided to theMessageDispatcherServlet
.protected void
customizeRegistration
(jakarta.servlet.ServletRegistration.Dynamic registration) Optionally perform further registration customization onceregisterMessageDispatcherServlet(ServletContext)
has completed.protected String[]
Specify the servlet mapping(s) for theMessageDispatcherServlet
.protected String
Return the name under which theMessageDispatcherServlet
will be registered.protected boolean
Indicates whether relative address locations in the XSD are to be transformed using the request URI of the incoming HTTP request.boolean
Indicates whether relative address locations in the WSDL are to be transformed using the request URI of the incoming HTTP request.void
onStartup
(jakarta.servlet.ServletContext servletContext) protected void
registerMessageDispatcherServlet
(jakarta.servlet.ServletContext servletContext) Register aMessageDispatcherServlet
against the given servlet context.Methods inherited from class org.springframework.web.context.AbstractContextLoaderInitializer
createRootApplicationContext, getRootApplicationContextInitializers, registerContextLoaderListener
-
Field Details
-
DEFAULT_SERVLET_NAME
The default servlet name. Can be customized by overridinggetServletName()
.- See Also:
-
DEFAULT_SERVLET_MAPPINGS
The default servlet mappings. Can be customized by overridinggetServletMappings()
.
-
-
Constructor Details
-
AbstractMessageDispatcherServletInitializer
public AbstractMessageDispatcherServletInitializer()
-
-
Method Details
-
onStartup
public void onStartup(jakarta.servlet.ServletContext servletContext) throws jakarta.servlet.ServletException - Specified by:
onStartup
in interfaceorg.springframework.web.WebApplicationInitializer
- Overrides:
onStartup
in classorg.springframework.web.context.AbstractContextLoaderInitializer
- Throws:
jakarta.servlet.ServletException
-
registerMessageDispatcherServlet
protected void registerMessageDispatcherServlet(jakarta.servlet.ServletContext servletContext) Register aMessageDispatcherServlet
against the given servlet context.This method will create a
MessageDispatcherServlet
with the name returned bygetServletName()
, initializing it with the application context returned fromcreateServletApplicationContext()
, and mapping it to the patterns returned fromgetServletMappings()
.Further customization can be achieved by overriding
customizeRegistration(ServletRegistration.Dynamic)
.- Parameters:
servletContext
- the context to register the servlet against
-
getServletName
Return the name under which theMessageDispatcherServlet
will be registered. Defaults toDEFAULT_SERVLET_NAME
. -
createServletApplicationContext
protected abstract org.springframework.web.context.WebApplicationContext createServletApplicationContext()Create a servlet application context to be provided to theMessageDispatcherServlet
.The returned context is delegated to Spring's
MessageDispatcherServlet(WebApplicationContext)
. As such, it typically contains endpoints, interceptors and other web service-related beans. -
getServletMappings
Specify the servlet mapping(s) for theMessageDispatcherServlet
. Defaults toDEFAULT_SERVLET_MAPPINGS
. -
isTransformWsdlLocations
public boolean isTransformWsdlLocations()Indicates whether relative address locations in the WSDL are to be transformed using the request URI of the incoming HTTP request. Defaults tofalse
. -
isTransformSchemaLocations
protected boolean isTransformSchemaLocations()Indicates whether relative address locations in the XSD are to be transformed using the request URI of the incoming HTTP request. Defaults tofalse
. -
customizeRegistration
protected void customizeRegistration(jakarta.servlet.ServletRegistration.Dynamic registration) Optionally perform further registration customization onceregisterMessageDispatcherServlet(ServletContext)
has completed.- Parameters:
registration
- theMessageDispatcherServlet
registration to be customized- See Also:
-