public abstract class

AbstractXmlApplicationContext

extends AbstractRefreshableConfigApplicationContext
java.lang.Object
   ↳ org.springframework.core.io.DefaultResourceLoader
     ↳ org.springframework.context.support.AbstractApplicationContext
       ↳ org.springframework.context.support.AbstractRefreshableApplicationContext
         ↳ org.springframework.context.support.AbstractRefreshableConfigApplicationContext
           ↳ org.springframework.context.support.AbstractXmlApplicationContext
Known Direct Subclasses

Class Overview

Convenient base class for ApplicationContext implementations, drawing configuration from XML documents containing bean definitions understood by an XmlBeanDefinitionReader.

Subclasses just have to implement the getConfigResources() and/or the getConfigLocations() method. Furthermore, they might override the getResourceByPath(String) hook to interpret relative paths in an environment-specific fashion, and/or getResourcePatternResolver() for extended pattern resolution.

Summary

[Expand]
Inherited Constants
From class org.springframework.context.support.AbstractApplicationContext
From interface org.springframework.beans.factory.BeanFactory
From interface org.springframework.context.ConfigurableApplicationContext
From interface org.springframework.core.io.ResourceLoader
From interface org.springframework.core.io.support.ResourcePatternResolver
[Expand]
Inherited Fields
From class org.springframework.context.support.AbstractApplicationContext
Public Constructors
AbstractXmlApplicationContext()
Create a new AbstractXmlApplicationContext with no parent.
AbstractXmlApplicationContext(ApplicationContext parent)
Create a new AbstractXmlApplicationContext with the given parent context.
Public Methods
void setValidating(boolean validating)
Set whether to use XML validation.
Protected Methods
Resource[] getConfigResources()
Return an array of Resource objects, referring to the XML bean definition files that this context should be built with.
void initBeanDefinitionReader(XmlBeanDefinitionReader reader)
Initialize the bean definition reader used for loading the bean definitions of this context.
void loadBeanDefinitions(DefaultListableBeanFactory beanFactory)
Loads the bean definitions via an XmlBeanDefinitionReader.
void loadBeanDefinitions(XmlBeanDefinitionReader reader)
Load the bean definitions with the given XmlBeanDefinitionReader.
[Expand]
Inherited Methods
From class org.springframework.context.support.AbstractRefreshableConfigApplicationContext
From class org.springframework.context.support.AbstractRefreshableApplicationContext
From class org.springframework.context.support.AbstractApplicationContext
From class org.springframework.core.io.DefaultResourceLoader
From class java.lang.Object
From interface org.springframework.beans.factory.BeanFactory
From interface org.springframework.beans.factory.BeanNameAware
From interface org.springframework.beans.factory.DisposableBean
From interface org.springframework.beans.factory.HierarchicalBeanFactory
From interface org.springframework.beans.factory.InitializingBean
From interface org.springframework.beans.factory.ListableBeanFactory
From interface org.springframework.context.ApplicationContext
From interface org.springframework.context.ApplicationEventPublisher
From interface org.springframework.context.ConfigurableApplicationContext
From interface org.springframework.context.Lifecycle
From interface org.springframework.context.MessageSource
From interface org.springframework.core.env.EnvironmentCapable
From interface org.springframework.core.io.ResourceLoader
From interface org.springframework.core.io.support.ResourcePatternResolver

Public Constructors

public AbstractXmlApplicationContext ()

Create a new AbstractXmlApplicationContext with no parent.

public AbstractXmlApplicationContext (ApplicationContext parent)

Create a new AbstractXmlApplicationContext with the given parent context.

Parameters
parent the parent context

Public Methods

public void setValidating (boolean validating)

Set whether to use XML validation. Default is true.

Protected Methods

protected Resource[] getConfigResources ()

Return an array of Resource objects, referring to the XML bean definition files that this context should be built with.

The default implementation returns null. Subclasses can override this to provide pre-built Resource objects rather than location Strings.

Returns
  • an array of Resource objects, or null if none

protected void initBeanDefinitionReader (XmlBeanDefinitionReader reader)

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.

Parameters
reader the bean definition reader used by this context

protected void loadBeanDefinitions (DefaultListableBeanFactory beanFactory)

Loads the bean definitions via an XmlBeanDefinitionReader.

Parameters
beanFactory the bean factory to load bean definitions into

protected void loadBeanDefinitions (XmlBeanDefinitionReader reader)

Load the bean definitions with the given XmlBeanDefinitionReader.

The lifecycle of the bean factory is handled by the refreshBeanFactory() method; hence this method is just supposed to load and/or register bean definitions.

Parameters
reader the XmlBeanDefinitionReader to use
Throws
BeansException in case of bean registration errors
IOException if the required XML document isn't found