Top Description Fields Constructors Methods
org.springframework.context.support

public abstract Class AbstractXmlApplicationContext

extends AbstractRefreshableConfigApplicationContext
Class Inheritance
Known Direct Subclasses
org.springframework.context.support.ClassPathXmlApplicationContext, org.springframework.context.support.FileSystemXmlApplicationContext
Imports
java.io.IOException, org.springframework.beans.BeansException, org.springframework.beans.factory.support.DefaultListableBeanFactory, org.springframework.beans.factory.xml.BeanDefinitionDocumentReader, .ResourceEntityResolver, .XmlBeanDefinitionReader, org.springframework.context.ApplicationContext, org.springframework.core.io.Resource, org.springframework.lang.Nullable

Convenient base class for org.springframework.context.ApplicationContext implementations, drawing configuration from XML documents containing bean definitions understood by an org.springframework.beans.factory.xml.XmlBeanDefinitionReader.

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

Authors
Rod Johnson, Juergen Hoeller
See Also
getConfigResources, getConfigLocations, org.springframework.beans.factory.xml.XmlBeanDefinitionReader

Field Summary

Modifier and TypeField and Description
private boolean

Constructor Summary

AccessConstructor and Description
public
AbstractXmlApplicationContext()

Create a new AbstractXmlApplicationContext with no parent.

public
AbstractXmlApplicationContext(ApplicationContext
the parent context
parent
)

Create a new AbstractXmlApplicationContext with the given parent context.

Method Summary

Modifier and TypeMethod and Description
protected Resource[]

Returns:

an array of Resource objects, or null if none
getConfigResources
()

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

protected void
initBeanDefinitionReader(XmlBeanDefinitionReader
the bean definition reader used by this context
reader
)

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.springframework.context.support.AbstractRefreshableApplicationContext.loadBeanDefinitions.

Loads the bean definitions via an XmlBeanDefinitionReader.
protected void
loadBeanDefinitions(XmlBeanDefinitionReader
the XmlBeanDefinitionReader to use
reader
)

Load the bean definitions with the given XmlBeanDefinitionReader.

public void
setValidating(boolean validating)

Set whether to use XML validation.

Inherited from org.springframework.context.support.AbstractRefreshableConfigApplicationContext:
afterPropertiesSetgetConfigLocationsgetDefaultConfigLocationsresolvePathsetBeanNamesetConfigLocationsetConfigLocationssetId

Field Detail

validatingback to summary
private boolean validating

Constructor Detail

AbstractXmlApplicationContextback to summary
public AbstractXmlApplicationContext()

Create a new AbstractXmlApplicationContext with no parent.

AbstractXmlApplicationContextback to summary
public AbstractXmlApplicationContext(ApplicationContext parent)

Create a new AbstractXmlApplicationContext with the given parent context.

Parameters
parent:ApplicationContext

the parent context

Method Detail

getConfigResourcesback to summary
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:Resource[]

an array of Resource objects, or null if none

Annotations
@Nullable
See Also
getConfigLocations()
initBeanDefinitionReaderback to summary
protected void initBeanDefinitionReader(XmlBeanDefinitionReader reader)

Initialize the bean definition reader used for loading the bean definitions of this context. The default implementation sets the validating flag.

Can be overridden in subclasses, e.g. for turning off XML validation or using a different BeanDefinitionDocumentReader implementation.

Parameters
reader:XmlBeanDefinitionReader

the bean definition reader used by this context

See Also
XmlBeanDefinitionReader#setValidating, XmlBeanDefinitionReader#setDocumentReaderClass
loadBeanDefinitionsback to summary
protected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) throws BeansException, IOException

Implements abstract org.springframework.context.support.AbstractRefreshableApplicationContext.loadBeanDefinitions.

Loads the bean definitions via an XmlBeanDefinitionReader.

Parameters
beanFactory:DefaultListableBeanFactory

Doc from org.springframework.context.support.AbstractRefreshableApplicationContext.loadBeanDefinitions.

the bean factory to load bean definitions into

Annotations
@Override
Exceptions
BeansException:

Doc from org.springframework.context.support.AbstractRefreshableApplicationContext.loadBeanDefinitions.

if parsing of the bean definitions failed

IOException:

Doc from org.springframework.context.support.AbstractRefreshableApplicationContext.loadBeanDefinitions.

if loading of bean definition files failed

See Also
org.springframework.beans.factory.xml.XmlBeanDefinitionReader, initBeanDefinitionReader, loadBeanDefinitions
loadBeanDefinitionsback to summary
protected void loadBeanDefinitions(XmlBeanDefinitionReader reader) throws BeansException, IOException

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:XmlBeanDefinitionReader

the XmlBeanDefinitionReader to use

Exceptions
BeansException:
in case of bean registration errors
IOException:
if the required XML document isn't found
See Also
refreshBeanFactory, getConfigLocations, getResources, getResourcePatternResolver
setValidatingback to summary
public void setValidating(boolean validating)

Set whether to use XML validation. Default is true.