Class AbstractAnnotationConfigDispatcherServletInitializer
- All Implemented Interfaces:
org.springframework.web.WebApplicationInitializer
WebApplicationInitializer
to register a DispatcherServlet
and use Java-based Spring configuration.
Implementations are required to implement:
getRootConfigClasses()
-- for "root" application context (non-web infrastructure) configuration.getServletConfigClasses()
-- forDispatcherServlet
application context (Spring MVC infrastructure) configuration.
If an application context hierarchy is not required, applications may
return all configuration via getRootConfigClasses()
and return
null
from getServletConfigClasses()
.
- Since:
- 3.2
- Author:
- Arjen Poutsma, Chris Beams
-
Field Summary
Fields inherited from class org.springframework.web.servlet.support.AbstractDispatcherServletInitializer
DEFAULT_SERVLET_NAME
Fields inherited from class org.springframework.web.context.AbstractContextLoaderInitializer
logger
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected org.springframework.web.context.WebApplicationContext
protected org.springframework.web.context.WebApplicationContext
Create a servlet application context to be provided to theDispatcherServlet
.protected abstract Class<?>[]
protected abstract Class<?>[]
Methods inherited from class org.springframework.web.servlet.support.AbstractDispatcherServletInitializer
createDispatcherServlet, customizeRegistration, getServletApplicationContextInitializers, getServletFilters, getServletMappings, getServletName, isAsyncSupported, onStartup, registerDispatcherServlet, registerServletFilter
Methods inherited from class org.springframework.web.context.AbstractContextLoaderInitializer
getRootApplicationContextInitializers, registerContextLoaderListener
-
Constructor Details
-
AbstractAnnotationConfigDispatcherServletInitializer
public AbstractAnnotationConfigDispatcherServletInitializer()
-
-
Method Details
-
createRootApplicationContext
@Nullable protected org.springframework.web.context.WebApplicationContext createRootApplicationContext()This implementation creates an
AnnotationConfigWebApplicationContext
, providing it the annotated classes returned bygetRootConfigClasses()
. Returnsnull
ifgetRootConfigClasses()
returnsnull
.- Specified by:
createRootApplicationContext
in classorg.springframework.web.context.AbstractContextLoaderInitializer
-
createServletApplicationContext
protected org.springframework.web.context.WebApplicationContext createServletApplicationContext()Create a servlet application context to be provided to theDispatcherServlet
.The returned context is delegated to Spring's
DispatcherServlet(WebApplicationContext)
. As such, it typically contains controllers, view resolvers, locale resolvers, and other web-related beans.This implementation creates an
AnnotationConfigWebApplicationContext
, providing it the annotated classes returned bygetServletConfigClasses()
. -
getRootConfigClasses
- Returns:
- the configuration for the root application context, or
null
if creation and registration of a root context is not desired
-
getServletConfigClasses
- Returns:
- the configuration for the Servlet application context, or
null
if all configuration is specified through root config classes.
-