| java.lang.Object org.springframework.web.context.ContextLoader
ContextLoader | public class ContextLoader (Code) | | Performs the actual initialization work for the root application context.
Called by
ContextLoaderListener and
ContextLoaderServlet .
Looks for a "contextClass" parameter at the web.xml context-param level
to specify the context class type, falling back to the default of
org.springframework.web.context.support.XmlWebApplicationContext if not found. With the default ContextLoader implementation, any context class
specified needs to implement the ConfigurableWebApplicationContext interface.
Processes a "
ContextLoader.CONFIG_LOCATION_PARAM 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 root application context, this class can
optionally load or obtain and hook up a shared parent context to the root
application context. See the
ContextLoader.loadParentContext(ServletContext) method for more information.
author: Juergen Hoeller author: Colin Sampaleanu author: Sam Brannen since: 17.02.2003 See Also: ContextLoaderListener See Also: ContextLoaderServlet See Also: ConfigurableWebApplicationContext See Also: org.springframework.web.context.support.XmlWebApplicationContext |
CONTEXT_CLASS_PARAM | final public static String CONTEXT_CLASS_PARAM(Code) | | Config param for the root WebApplicationContext implementation class to
use: "contextClass "
|
LOCATOR_FACTORY_KEY_PARAM | final public static String LOCATOR_FACTORY_KEY_PARAM(Code) | | Optional servlet context parameter (i.e., "parentContextKey ")
used only when obtaining a parent context using the default implementation
of
ContextLoader.loadParentContext(ServletContext servletContext) .
Specifies the 'factoryKey' used in the
BeanFactoryLocator.useBeanFactory(String factoryKey) method call,
obtaining the parent application context from the BeanFactoryLocator instance.
Supplying this "parentContextKey" parameter is sufficient when relying
on the default classpath*:beanRefContext.xml selector for
candidate factory references.
|
closeWebApplicationContext | public void closeWebApplicationContext(ServletContext servletContext)(Code) | | Close Spring's web application context for the given servlet context. If
the default
ContextLoader.loadParentContext(ServletContext) implementation,
which uses ContextSingletonBeanFactoryLocator, has loaded any shared
parent context, release one reference to that shared parent context.
If overriding
ContextLoader.loadParentContext(ServletContext) , you may have
to override this method as well.
Parameters: servletContext - the ServletContext that the WebApplicationContext runs in |
createWebApplicationContext | protected WebApplicationContext createWebApplicationContext(ServletContext servletContext, ApplicationContext parent) throws BeansException(Code) | | Instantiate the root 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 gets called prior to refreshing the
context, allowing subclasses to perform custom modifications to the context.
Parameters: servletContext - current servlet context Parameters: parent - the parent ApplicationContext to use, or null if none the root WebApplicationContext throws: BeansException - if the context couldn't be initialized See Also: ConfigurableWebApplicationContext |
|
|