org.broadleafcommerce.common.web.extensibility
Class MergeContextLoader

java.lang.Object
  extended by org.springframework.web.context.ContextLoader
      extended by org.broadleafcommerce.common.web.extensibility.MergeContextLoader

public class MergeContextLoader
extends org.springframework.web.context.ContextLoader

Performs the actual initialization work for the rootId application context. Called by 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.

Author:
Jeff Fischer

Field Summary
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
 
Fields inherited from class org.springframework.web.context.ContextLoader
CONFIG_LOCATION_PARAM, CONTEXT_CLASS_PARAM, LOCATOR_FACTORY_KEY_PARAM, LOCATOR_FACTORY_SELECTOR_PARAM
 
Constructor Summary
MergeContextLoader()
           
 
Method Summary
protected  org.springframework.web.context.WebApplicationContext createWebApplicationContext(javax.servlet.ServletContext servletContext, org.springframework.context.ApplicationContext parent)
          Instantiate the rootId WebApplicationContext for this loader, either the default context class or a custom context class if specified.
 
Methods inherited from class org.springframework.web.context.ContextLoader
closeWebApplicationContext, customizeContext, determineContextClass, getCurrentWebApplicationContext, initWebApplicationContext, loadParentContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PATCH_LOCATION_PARAM

public static final String PATCH_LOCATION_PARAM
Name of servlet context parameter (i.e., "patchConfigLocation") that can specify the config location for the rootId context.

See Also:
Constant Field Values

SHUTDOWN_HOOK_BEAN

public static final String SHUTDOWN_HOOK_BEAN
Name of a bean to hook before Spring shutdown for this context commences.

See Also:
Constant Field Values

SHUTDOWN_HOOK_METHOD

public static final String SHUTDOWN_HOOK_METHOD
Name of method to call on the shutdown hook bean before Spring shutdown for this context commences

See Also:
Constant Field Values
Constructor Detail

MergeContextLoader

public MergeContextLoader()
Method Detail

createWebApplicationContext

protected org.springframework.web.context.WebApplicationContext createWebApplicationContext(javax.servlet.ServletContext servletContext,
                                                                                            org.springframework.context.ApplicationContext parent)
                                                                                     throws org.springframework.beans.BeansException
Instantiate the rootId WebApplicationContext for this loader, either the default context class or a custom context class if specified.

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.

Overrides:
createWebApplicationContext in class org.springframework.web.context.ContextLoader
Parameters:
servletContext - current servlet context
parent - the parent ApplicationContext to use, or null if none
Returns:
the rootId WebApplicationContext
Throws:
org.springframework.beans.BeansException - if the context couldn't be initialized
See Also:
ConfigurableWebApplicationContext


Copyright © 2012. All Rights Reserved.