Top Description Fields Constructors Methods
org.springframework.web.servlet.support

public abstract Class AbstractAnnotationConfigDispatcherServletInitializer

extends AbstractDispatcherServletInitializer
Class Inheritance
Imports
org.springframework.lang.Nullable, org.springframework.util.ObjectUtils, org.springframework.web.context.WebApplicationContext, org.springframework.web.context.support.AnnotationConfigWebApplicationContext

WebApplicationInitializer to register a DispatcherServlet and use Java-based Spring configuration.

Implementations are required to implement:

If an application context hierarchy is not required, applications may return all configuration via getRootConfigClasses() and return null from getServletConfigClasses().

Authors
Arjen Poutsma, Chris Beams
Since
3.2

Field Summary

Inherited from org.springframework.web.servlet.support.AbstractDispatcherServletInitializer:
DEFAULT_SERVLET_NAME

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected WebApplicationContext
createRootApplicationContext()

Implements abstract org.springframework.web.context.AbstractContextLoaderInitializer.createRootApplicationContext.

Create the "root" application context to be provided to the ContextLoaderListener.

protected WebApplicationContext
createServletApplicationContext()

Implements abstract org.springframework.web.servlet.support.AbstractDispatcherServletInitializer.createServletApplicationContext.

Create a servlet application context to be provided to the DispatcherServlet.

protected abstract Class<?>[]

Returns:

the configuration for the root application context, or null if creation and registration of a root context is not desired
getRootConfigClasses
()

Specify @Configuration and/or @Component classes for the root application context.

protected abstract Class<?>[]

Returns:

the configuration for the Servlet application context, or null if all configuration is specified through root config classes.
getServletConfigClasses
()

Specify @Configuration and/or @Component classes for the Servlet application context.

Inherited from org.springframework.web.servlet.support.AbstractDispatcherServletInitializer:
createDispatcherServletcustomizeRegistrationgetServletApplicationContextInitializersgetServletFiltersgetServletMappingsgetServletNameisAsyncSupportedonStartupregisterDispatcherServletregisterServletFilter

Constructor Detail

AbstractAnnotationConfigDispatcherServletInitializerback to summary
public AbstractAnnotationConfigDispatcherServletInitializer()

Method Detail

createRootApplicationContextback to summary
protected WebApplicationContext createRootApplicationContext()

Implements abstract org.springframework.web.context.AbstractContextLoaderInitializer.createRootApplicationContext.

Doc from org.springframework.web.context.AbstractContextLoaderInitializer.createRootApplicationContext.

Create the "root" application context to be provided to the ContextLoaderListener.

The returned context is delegated to ContextLoaderListener#ContextLoaderListener(WebApplicationContext) and will be established as the parent context for any DispatcherServlet application contexts. As such, it typically contains middle-tier services, data sources, etc.

This implementation creates an AnnotationConfigWebApplicationContext, providing it the annotated classes returned by getRootConfigClasses(). Returns null if getRootConfigClasses() returns null.

Returns:WebApplicationContext

the root application context, or null if a root context is not desired

Annotations
@Override
@Nullable
createServletApplicationContextback to summary
protected WebApplicationContext createServletApplicationContext()

Implements abstract org.springframework.web.servlet.support.AbstractDispatcherServletInitializer.createServletApplicationContext.

Doc from org.springframework.web.servlet.support.AbstractDispatcherServletInitializer.createServletApplicationContext.

Create a servlet application context to be provided to the DispatcherServlet.

The returned context is delegated to Spring's DispatcherServlet#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 by getServletConfigClasses().

Annotations
@Override
getRootConfigClassesback to summary
protected abstract Class<?>[] getRootConfigClasses()

Specify @Configuration and/or @Component classes for the root application context.

Returns:Class<?>[]

the configuration for the root application context, or null if creation and registration of a root context is not desired

Annotations
@Nullable
getServletConfigClassesback to summary
protected abstract Class<?>[] getServletConfigClasses()

Specify @Configuration and/or @Component classes for the Servlet application context.

Returns:Class<?>[]

the configuration for the Servlet application context, or null if all configuration is specified through root config classes.

Annotations
@Nullable