Class DefaultBeanDefinitionDocumentReader
- All Implemented Interfaces:
BeanDefinitionDocumentReader
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.
- Since:
- 18.12.2003
- Author:
- Rod Johnson, Juergen Hoeller, Rob Harrop, Erik Wiersma
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected BeanDefinitionParserDelegate
createDelegate
(XmlReaderContext readerContext, Element root, BeanDefinitionParserDelegate parentDelegate) protected void
Register each bean definition within the given root<beans/>
element.protected Object
extractSource
(Element ele) Invoke theSourceExtractor
to pull the source metadata from the suppliedElement
.protected final XmlReaderContext
Return the descriptor for the XML resource that this parser works on.protected void
Parse an "import" element and load the bean definitions from the given resource into the bean factory.protected void
parseBeanDefinitions
(Element root, BeanDefinitionParserDelegate delegate) Parse the elements at the root level in the document: "import", "alias", "bean".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
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.void
registerBeanDefinitions
(Document doc, XmlReaderContext readerContext) This implementation parses bean definitions according to the "spring-beans" XSD (or DTD, historically).
-
Field Details
-
BEAN_ELEMENT
- See Also:
-
NESTED_BEANS_ELEMENT
- See Also:
-
ALIAS_ELEMENT
- See Also:
-
NAME_ATTRIBUTE
- See Also:
-
ALIAS_ATTRIBUTE
- See Also:
-
IMPORT_ELEMENT
- See Also:
-
RESOURCE_ATTRIBUTE
- See Also:
-
PROFILE_ATTRIBUTE
- See Also:
-
logger
-
-
Constructor Details
-
DefaultBeanDefinitionDocumentReader
public DefaultBeanDefinitionDocumentReader()
-
-
Method Details
-
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.- Specified by:
registerBeanDefinitions
in interfaceBeanDefinitionDocumentReader
- Parameters:
doc
- the DOM documentreaderContext
- the current context of the reader (includes the target registry and the resource being parsed)
-
getReaderContext
Return the descriptor for the XML resource that this parser works on. -
extractSource
Invoke theSourceExtractor
to pull the source metadata from the suppliedElement
. -
doRegisterBeanDefinitions
Register each bean definition within the given root<beans/>
element. -
createDelegate
protected BeanDefinitionParserDelegate createDelegate(XmlReaderContext readerContext, Element root, @Nullable BeanDefinitionParserDelegate parentDelegate) -
parseBeanDefinitions
Parse the elements at the root level in the document: "import", "alias", "bean".- Parameters:
root
- the DOM root element of the document
-
importBeanDefinitionResource
Parse an "import" element and load the bean definitions from the given resource into the bean factory. -
processAliasRegistration
Process the given alias element, registering the alias with the registry. -
processBeanDefinition
Process the given bean element, parsing the bean definition and registering it with the registry. -
preProcessXml
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:
-
postProcessXml
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:
-