public abstract class AbstractContextLoaderInitializer extends java.lang.Object implements WebApplicationInitializer
WebApplicationInitializer
implementations
that register a ContextLoaderListener
in the servlet context.
The only method required to be implemented by subclasses is
createRootApplicationContext()
, which gets invoked from
registerContextLoaderListener(ServletContext)
.
Modifier and Type | Field and Description |
---|---|
protected Log |
logger
Logger available to subclasses.
|
Constructor and Description |
---|
AbstractContextLoaderInitializer() |
Modifier and Type | Method and Description |
---|---|
protected abstract WebApplicationContext |
createRootApplicationContext()
Create the "root" application context to be provided to the
ContextLoaderListener . |
protected ApplicationContextInitializer<?>[] |
getRootApplicationContextInitializers()
Specify application context initializers to be applied to the root application
context that the
ContextLoaderListener is being created with. |
void |
onStartup(ServletContext servletContext)
Configure the given
ServletContext with any servlets, filters, listeners
context-params and attributes necessary for initializing this web application. |
protected void |
registerContextLoaderListener(ServletContext servletContext)
Register a
ContextLoaderListener against the given servlet context. |
protected final Log logger
public void onStartup(ServletContext servletContext) throws ServletException
WebApplicationInitializer
ServletContext
with any servlets, filters, listeners
context-params and attributes necessary for initializing this web application. See
examples above.onStartup
in interface WebApplicationInitializer
servletContext
- the ServletContext
to initializeServletException
- if any call against the given ServletContext
throws a ServletException
protected void registerContextLoaderListener(ServletContext servletContext)
ContextLoaderListener
against the given servlet context. The
ContextLoaderListener
is initialized with the application context returned
from the createRootApplicationContext()
template method.servletContext
- the servlet context to register the listener against@Nullable protected abstract 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.
null
if a root context is not
desiredAbstractDispatcherServletInitializer
@Nullable protected ApplicationContextInitializer<?>[] getRootApplicationContextInitializers()
ContextLoaderListener
is being created with.