Class AbstractAnnotationConfigDispatcherServletInitializer
- java.lang.Object
- org.springframework.web.context.AbstractContextLoaderInitializer
- org.springframework.web.servlet.support.AbstractDispatcherServletInitializer
- org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer
- All Implemented Interfaces:
WebApplicationInitializer
public abstract class AbstractAnnotationConfigDispatcherServletInitializer extends AbstractDispatcherServletInitializer
WebApplicationInitializerto register aDispatcherServletand use Java-based Spring configuration.Implementations are required to implement:
getRootConfigClasses()-- for "root" application context (non-web infrastructure) configuration.getServletConfigClasses()-- forDispatcherServletapplication context (Spring MVC infrastructure) configuration.
If an application context hierarchy is not required, applications may return all configuration via
getRootConfigClasses()and returnnullfromgetServletConfigClasses().- 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
Constructors Constructor Description AbstractAnnotationConfigDispatcherServletInitializer()
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected WebApplicationContextcreateRootApplicationContext()Create the "root" application context to be provided to theContextLoaderListener.protected WebApplicationContextcreateServletApplicationContext()Create a servlet application context to be provided to theDispatcherServlet.protected abstract Class<?>[]getRootConfigClasses()protected abstract Class<?>[]getServletConfigClasses()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 Detail
AbstractAnnotationConfigDispatcherServletInitializer
public AbstractAnnotationConfigDispatcherServletInitializer()
Method Detail
createRootApplicationContext
@Nullable protected WebApplicationContext createRootApplicationContext()
Create the "root" application context to be provided to theContextLoaderListener.The returned context is delegated to
ContextLoaderListener(WebApplicationContext)and will be established as the parent context for anyDispatcherServletapplication contexts. As such, it typically contains middle-tier services, data sources, etc.This implementation creates an
AnnotationConfigWebApplicationContext, providing it the annotated classes returned bygetRootConfigClasses(). ReturnsnullifgetRootConfigClasses()returnsnull.- Specified by:
createRootApplicationContextin classAbstractContextLoaderInitializer- Returns:
- the root application context, or
nullif a root context is not desired - See Also:
AbstractDispatcherServletInitializer
createServletApplicationContext
protected 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
@Nullable protected abstract Class<?>[] getRootConfigClasses()
- Returns:
- the configuration for the root application context, or
nullif creation and registration of a root context is not desired
getServletConfigClasses
@Nullable protected abstract Class<?>[] getServletConfigClasses()
- Returns:
- the configuration for the Servlet application context, or
nullif all configuration is specified through root config classes.