Top Description Fields Constructors Methods
org.springframework.beans.factory.xml

public Class DefaultBeanDefinitionDocumentReader

extends Object
implements BeanDefinitionDocumentReader
Class Inheritance
All Implemented Interfaces
org.springframework.beans.factory.xml.BeanDefinitionDocumentReader
Imports
java.io.IOException, java.net.URISyntaxException, java.util.LinkedHashSet, .Set, org.apache.commons.logging.Log, .LogFactory, org.w3c.dom.Document, .Element, .Node, .NodeList, org.springframework.beans.factory.BeanDefinitionStoreException, org.springframework.beans.factory.config.BeanDefinitionHolder, org.springframework.beans.factory.parsing.BeanComponentDefinition, org.springframework.beans.factory.support.BeanDefinitionReaderUtils, org.springframework.core.io.Resource, org.springframework.core.io.support.ResourcePatternUtils, org.springframework.lang.Nullable, org.springframework.util.Assert, .ResourceUtils, .StringUtils

Default implementation of the BeanDefinitionDocumentReader interface that reads bean definitions according to the "spring-beans" DTD and XSD format (Spring's default XML bean definition format).

The structure, elements, and attribute names of the required XML document are hard-coded in this class. (Of course a transform could be run if necessary to produce this format). <beans> does not need to be the root element of the XML document: this class will parse all bean definition elements in the XML file, regardless of the actual root element.

Authors
Rod Johnson, Juergen Hoeller, Rob Harrop, Erik Wiersma
Since
18.12.2003

Field Summary

Modifier and TypeField and Description
public static final String
public static final String
public static final String
private BeanDefinitionParserDelegate
public static final String
protected final Log
public static final String
public static final String
public static final String
private XmlReaderContext
public static final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected BeanDefinitionParserDelegate
protected void
doRegisterBeanDefinitions(Element root)

Register each bean definition within the given root <beans/> element.

protected Object
extractSource(Element ele)

Invoke the org.springframework.beans.factory.parsing.SourceExtractor to pull the source metadata from the supplied Element.

protected final XmlReaderContext
getReaderContext()

Return the descriptor for the XML resource that this parser works on.

protected void
importBeanDefinitionResource(Element ele)

Parse an "import" element and load the bean definitions from the given resource into the bean factory.

protected void
parseBeanDefinitions(Element
the DOM root element of the document
root
,
BeanDefinitionParserDelegate delegate)

Parse the elements at the root level in the document: "import", "alias", "bean".

private void
protected void
postProcessXml(Element root)

Allow the XML to be extensible by processing any custom element types last, after we finished processing the bean definitions.

protected void
preProcessXml(Element root)

Allow the XML to be extensible by processing any custom element types first, before we start to process the bean definitions.

protected void
processAliasRegistration(Element ele)

Process the given alias element, registering the alias with the registry.

protected void
processBeanDefinition(Element ele, BeanDefinitionParserDelegate delegate)

Process the given bean element, parsing the bean definition and registering it with the registry.

public void
registerBeanDefinitions(Document
the DOM document
doc
,
XmlReaderContext
the current context of the reader (includes the target registry and the resource being parsed)
readerContext
)

Implements org.springframework.beans.factory.xml.BeanDefinitionDocumentReader.registerBeanDefinitions.

This implementation parses bean definitions according to the "spring-beans" XSD (or DTD, historically).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ALIAS_ATTRIBUTEback to summary
public static final String ALIAS_ATTRIBUTE
ALIAS_ELEMENTback to summary
public static final String ALIAS_ELEMENT
BEAN_ELEMENTback to summary
public static final String BEAN_ELEMENT
delegateback to summary
private BeanDefinitionParserDelegate delegate
Annotations
@Nullable
IMPORT_ELEMENTback to summary
public static final String IMPORT_ELEMENT
loggerback to summary
protected final Log logger
NAME_ATTRIBUTEback to summary
public static final String NAME_ATTRIBUTE
NESTED_BEANS_ELEMENTback to summary
public static final String NESTED_BEANS_ELEMENT
PROFILE_ATTRIBUTEback to summary
public static final String PROFILE_ATTRIBUTE
readerContextback to summary
private XmlReaderContext readerContext
Annotations
@Nullable
RESOURCE_ATTRIBUTEback to summary
public static final String RESOURCE_ATTRIBUTE

Constructor Detail

DefaultBeanDefinitionDocumentReaderback to summary
public DefaultBeanDefinitionDocumentReader()

Method Detail

createDelegateback to summary
protected BeanDefinitionParserDelegate createDelegate(XmlReaderContext readerContext, Element root, BeanDefinitionParserDelegate parentDelegate)
doRegisterBeanDefinitionsback to summary
protected void doRegisterBeanDefinitions(Element root)

Register each bean definition within the given root <beans/> element.

Annotations
@SuppressWarnings:deprecation
extractSourceback to summary
protected Object extractSource(Element ele)

Invoke the org.springframework.beans.factory.parsing.SourceExtractor to pull the source metadata from the supplied Element.

Annotations
@Nullable
getReaderContextback to summary
protected final XmlReaderContext getReaderContext()

Return the descriptor for the XML resource that this parser works on.

importBeanDefinitionResourceback to summary
protected void importBeanDefinitionResource(Element ele)

Parse an "import" element and load the bean definitions from the given resource into the bean factory.

parseBeanDefinitionsback to summary
protected void parseBeanDefinitions(Element root, BeanDefinitionParserDelegate delegate)

Parse the elements at the root level in the document: "import", "alias", "bean".

Parameters
root:Element

the DOM root element of the document

parseDefaultElementback to summary
private void parseDefaultElement(Element ele, BeanDefinitionParserDelegate delegate)
postProcessXmlback to summary
protected void postProcessXml(Element root)

Allow the XML to be extensible by processing any custom element types last, after we finished processing the bean definitions. This method is a natural extension point for any other custom post-processing of the XML.

The default implementation is empty. Subclasses can override this method to convert custom elements into standard Spring bean definitions, for example. Implementors have access to the parser's bean definition reader and the underlying XML resource, through the corresponding accessors.

See Also
getReaderContext()
preProcessXmlback to summary
protected void preProcessXml(Element root)

Allow the XML to be extensible by processing any custom element types first, before we start to process the bean definitions. This method is a natural extension point for any other custom pre-processing of the XML.

The default implementation is empty. Subclasses can override this method to convert custom elements into standard Spring bean definitions, for example. Implementors have access to the parser's bean definition reader and the underlying XML resource, through the corresponding accessors.

See Also
getReaderContext()
processAliasRegistrationback to summary
protected void processAliasRegistration(Element ele)

Process the given alias element, registering the alias with the registry.

processBeanDefinitionback to summary
protected void processBeanDefinition(Element ele, BeanDefinitionParserDelegate delegate)

Process the given bean element, parsing the bean definition and registering it with the registry.

registerBeanDefinitionsback to summary
public void registerBeanDefinitions(Document doc, XmlReaderContext readerContext)

Implements org.springframework.beans.factory.xml.BeanDefinitionDocumentReader.registerBeanDefinitions.

This implementation parses bean definitions according to the "spring-beans" XSD (or DTD, historically).

Opens a DOM Document; then initializes the default settings specified at the <beans/> level; then parses the contained bean definitions.

Parameters
doc:Document

Doc from org.springframework.beans.factory.xml.BeanDefinitionDocumentReader.registerBeanDefinitions.

the DOM document

readerContext:XmlReaderContext

Doc from org.springframework.beans.factory.xml.BeanDefinitionDocumentReader.registerBeanDefinitions.

the current context of the reader (includes the target registry and the resource being parsed)

Annotations
@Override