public abstract class AbstractAnnotationConfigDispatcherServletInitializer extends AbstractDispatcherServletInitializer
WebApplicationInitializer
implementations that register a
DispatcherServlet
configured with annotated classes, e.g. Spring's
@Configuration
classes.
Concrete implementations are required to implement getRootConfigClasses()
and getServletConfigClasses()
as well as AbstractDispatcherServletInitializer.getServletMappings()
.
Further template and customization methods are provided by
AbstractDispatcherServletInitializer
.
This is the preferred approach for applications that use Java-based Spring configuration.
DEFAULT_SERVLET_NAME
logger
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()
Specify
@Configuration
and/or @Component classes to be
provided to the dispatcher servlet
application context. |
createDispatcherServlet, customizeRegistration, getServletApplicationContextInitializers, getServletFilters, getServletMappings, getServletName, isAsyncSupported, onStartup, registerDispatcherServlet, registerServletFilter
getRootApplicationContextInitializers, registerContextLoaderListener
public AbstractAnnotationConfigDispatcherServletInitializer()
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 AbstractContextLoaderInitializer
null
if a root context is not
desiredAbstractDispatcherServletInitializer
protected 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()
.
protected abstract java.lang.Class<?>[] getRootConfigClasses()
null
if creation and registration of a root context is not desiredprotected abstract java.lang.Class<?>[] getServletConfigClasses()
@Configuration
and/or @Component
classes to be
provided to the dispatcher servlet
application context.null
if all configuration is specified through root config classes.