Deprecated
as a consequence of AbstractRefreshableWebApplicationContext being deprecated. See corresponding docs for further information.
org.springframework.web.context.WebApplicationContext implementation
which takes its configuration from XML documents, understood by an
org.springframework.beans.factory.xml.XmlBeanDefinitionReader .
This is essentially the equivalent of
org.springframework.context.support.GenericXmlApplicationContext
for a web environment.
By default, the configuration will be taken from "/WEB-INF/applicationContext.xml" for the root context, and "/WEB-INF/test-servlet.xml" for a context with the namespace "test-servlet" (like for a DispatcherServlet instance with the servlet-name "test").
The config location defaults can be overridden via the "contextConfigLocation"
context-param of org. and servlet
init-param of org.. Config locations
can either denote concrete files like "/WEB-INF/context.xml" or Ant-style patterns
like "/WEB-INF/*-context.xml" (see org.
javadoc for pattern details).
Note
In case of multiple config locations, later bean definitions will override ones defined in earlier loaded files. This can be leveraged to deliberately override certain bean definitions via an extra XML file.
For a WebApplicationContext that reads in a different bean definition format,
create an analogous subclass of AbstractRefreshableWebApplicationContext.
Such a context implementation can be specified as "contextClass" context-param
for ContextLoader or "contextClass" init-param for FrameworkServlet.
setNamespace, setConfigLocations, org.springframework.beans.factory.xml.XmlBeanDefinitionReader , org.springframework.web.context.ContextLoader#initWebApplicationContext , org.springframework.web.servlet.FrameworkServlet#initWebApplicationContext
| Modifier and Type | Field and Description |
|---|---|
| public static final String | DEFAULT_CONFIG_LOCATION
Default config location for the root context. |
| public static final String | DEFAULT_CONFIG_LOCATION_PREFIX
Default prefix for building a config location for a namespace. |
| public static final String | DEFAULT_CONFIG_LOCATION_SUFFIX
Default suffix for building a config location for a namespace. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected String[] | getDefaultConfigLocations()
The default location for the root context is "/WEB-INF/applicationContext.xml",
and "/WEB-INF/test-servlet.xml" for a context with the namespace "test-servlet"
(like for a DispatcherServlet instance with the servlet-name "test").
|
| protected void | initBeanDefinitionReader(XmlBeanDefinitionReader
the bean definition reader used by this context beanDefinitionReader)Initialize the bean definition reader used for loading the bean definitions of this context. |
| protected void | loadBeanDefinitions(DefaultListableBeanFactory
the bean factory to load bean definitions into beanFactory)Implements abstract org. |
| protected void | loadBeanDefinitions(XmlBeanDefinitionReader reader)
Load the bean definitions with the given XmlBeanDefinitionReader. |
| DEFAULT_CONFIG_LOCATION | back to summary |
|---|---|
| public static final String DEFAULT_CONFIG_LOCATION Default config location for the root context. | |
| DEFAULT_CONFIG_LOCATION_PREFIX | back to summary |
|---|---|
| public static final String DEFAULT_CONFIG_LOCATION_PREFIX Default prefix for building a config location for a namespace. | |
| DEFAULT_CONFIG_LOCATION_SUFFIX | back to summary |
|---|---|
| public static final String DEFAULT_CONFIG_LOCATION_SUFFIX Default suffix for building a config location for a namespace. | |
| XmlWebApplicationContext | back to summary |
|---|---|
| public XmlWebApplicationContext() | |
| getDefaultConfigLocations | back to summary |
|---|---|
| protected String[] getDefaultConfigLocations() The default location for the root context is "/WEB-INF/applicationContext.xml", and "/WEB-INF/test-servlet.xml" for a context with the namespace "test-servlet" (like for a DispatcherServlet instance with the servlet-name "test").
| |
| initBeanDefinitionReader | back to summary |
|---|---|
| protected void initBeanDefinitionReader(XmlBeanDefinitionReader beanDefinitionReader) Initialize the bean definition reader used for loading the bean definitions of this context. Default implementation is empty. Can be overridden in subclasses, e.g. for turning off XML validation or using a different XmlBeanDefinitionParser implementation.
| |
| loadBeanDefinitions | back to summary |
|---|---|
| protected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) throws BeansException, IOException Implements abstract org. Loads the bean definitions via an XmlBeanDefinitionReader.
| |
| loadBeanDefinitions | back to summary |
|---|---|
| protected void loadBeanDefinitions(XmlBeanDefinitionReader reader) throws IOException Load the bean definitions with the given XmlBeanDefinitionReader. The lifecycle of the bean factory is handled by the refreshBeanFactory method; therefore this method is just supposed to load and/or register bean definitions. Delegates to a ResourcePatternResolver for resolving location patterns into Resource instances.
| |