public abstract class AbstractAnnotationConfigDispatcherServletInitializer extends AbstractDispatcherServletInitializer
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() -- for DispatcherServlet
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().
DEFAULT_SERVLET_NAMElogger| Constructor and Description |
|---|
AbstractAnnotationConfigDispatcherServletInitializer() |
| Modifier and Type | Method and Description |
|---|---|
protected WebApplicationContext |
createRootApplicationContext()
Create the "root" application context to be provided to the
ContextLoaderListener. |
protected WebApplicationContext |
createServletApplicationContext()
Create a servlet application context to be provided to the
DispatcherServlet. |
protected abstract java.lang.Class<?>[] |
getRootConfigClasses()
|
protected abstract java.lang.Class<?>[] |
getServletConfigClasses()
|
createDispatcherServlet, customizeRegistration, getServletApplicationContextInitializers, getServletFilters, getServletMappings, getServletName, isAsyncSupported, onStartup, registerDispatcherServlet, registerServletFiltergetRootApplicationContextInitializers, registerContextLoaderListenerpublic AbstractAnnotationConfigDispatcherServletInitializer()
@Nullable protected WebApplicationContext createRootApplicationContext()
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.
createRootApplicationContext in class AbstractContextLoaderInitializernull if a root context is not
desiredAbstractDispatcherServletInitializerprotected WebApplicationContext createServletApplicationContext()
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().
@Nullable protected abstract java.lang.Class<?>[] getRootConfigClasses()
null
if creation and registration of a root context is not desired@Nullable protected abstract java.lang.Class<?>[] getServletConfigClasses()
null if all configuration is specified through root config classes.