public class MergeContextLoader
extends org.springframework.web.context.ContextLoader
MergeContextLoaderListener
.
Processes a "contextConfigLocation"
context-param and passes its value to the context instance, parsing it into
potentially multiple file paths which can be separated by any number of
commas and spaces, e.g. "WEB-INF/applicationContext1.xml,
WEB-INF/applicationContext2.xml". Ant-style path patterns are supported as well,
e.g. "WEB-INF/*Context.xml,WEB-INF/spring*.xml" or "WEB-INF/**/*Context.xml".
If not explicitly specified, the context implementation is supposed to use a
default location (with XmlWebApplicationContext: "/WEB-INF/applicationContext.xml").
Note: In case of multiple config locations, later bean definitions will override ones defined in previously loaded files, at least when using one of Spring's default ApplicationContext implementations. This can be leveraged to deliberately override certain bean definitions via an extra XML file.
Above and beyond loading the rootId application context, this class
can optionally load or obtain and hook up a shared parent context to
the rootId application context. See the
ContextLoader.loadParentContext(ServletContext)
method for more information.
Additionally, Processes a "patchConfigLocation"
context-param and passes its value to the context instance, parsing it into
potentially multiple file paths which can be separated by any number of
commas and spaces, e.g. "WEB-INF/patch1.xml,
WEB-INF/patch2.xml". Ant-style path patterns are supported as well,
e.g. "WEB-INF/*Patch.xml,WEB-INF/spring*.xml" or "WEB-INF/**/*Patch.xml".
The patch configuration files are merged into the above config
MergeXmlConfigResource
.
Modifier and Type | Field and Description |
---|---|
static String |
PATCH_LOCATION_PARAM
Name of servlet context parameter (i.e., "
patchConfigLocation ")
that can specify the config location for the rootId context. |
static String |
SHUTDOWN_HOOK_BEAN
Name of a bean to hook before Spring shutdown for this
context commences.
|
static String |
SHUTDOWN_HOOK_METHOD
Name of method to call on the shutdown hook bean before
Spring shutdown for this context commences
|
Constructor and Description |
---|
MergeContextLoader() |
Modifier and Type | Method and Description |
---|---|
protected org.springframework.web.context.WebApplicationContext |
createWebApplicationContext(javax.servlet.ServletContext servletContext)
Instantiate the rootId WebApplicationContext for this loader, either the
default context class or a custom context class if specified.
|
protected org.springframework.web.context.WebApplicationContext |
createWebApplicationContext(javax.servlet.ServletContext servletContext,
org.springframework.context.ApplicationContext parent)
Deprecated.
|
public static final String PATCH_LOCATION_PARAM
patchConfigLocation
")
that can specify the config location for the rootId context.public static final String SHUTDOWN_HOOK_BEAN
public static final String SHUTDOWN_HOOK_METHOD
@Deprecated protected org.springframework.web.context.WebApplicationContext createWebApplicationContext(javax.servlet.ServletContext servletContext, org.springframework.context.ApplicationContext parent) throws org.springframework.beans.BeansException
This implementation expects custom contexts to implement the
ConfigurableWebApplicationContext
interface.
Can be overridden in subclasses.
In addition, ContextLoader.customizeContext(javax.servlet.ServletContext, org.springframework.web.context.ConfigurableWebApplicationContext)
gets called prior to refreshing the
context, allowing subclasses to perform custom modifications to the context.
createWebApplicationContext
in class org.springframework.web.context.ContextLoader
servletContext
- current servlet contextparent
- the parent ApplicationContext to use, or null
if noneorg.springframework.beans.BeansException
- if the context couldn't be initializedConfigurableWebApplicationContext
protected org.springframework.web.context.WebApplicationContext createWebApplicationContext(javax.servlet.ServletContext servletContext) throws org.springframework.beans.BeansException
This implementation expects custom contexts to implement the
ConfigurableWebApplicationContext
interface.
Can be overridden in subclasses.
In addition, ContextLoader.customizeContext(javax.servlet.ServletContext, org.springframework.web.context.ConfigurableWebApplicationContext)
gets called prior to refreshing the
context, allowing subclasses to perform custom modifications to the context.
createWebApplicationContext
in class org.springframework.web.context.ContextLoader
servletContext
- current servlet contextorg.springframework.beans.BeansException
- if the context couldn't be initializedConfigurableWebApplicationContext
Copyright © 2014. All rights reserved.