public class DefaultBeanDefinitionDocumentReader extends Object implements BeanDefinitionDocumentReader
BeanDefinitionDocumentReader
interface.
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>
doesn't need to be the root
element of the XML document: This class will parse all bean definition elements
in the XML file, not regarding the actual root element.
Modifier and Type | Field and Description |
---|---|
static String |
ALIAS_ATTRIBUTE |
static String |
ALIAS_ELEMENT |
static String |
BEAN_ELEMENT |
static String |
IMPORT_ELEMENT |
protected Log |
logger |
static String |
NAME_ATTRIBUTE |
static String |
NESTED_BEANS_ELEMENT |
static String |
PROFILE_ATTRIBUTE |
static String |
RESOURCE_ATTRIBUTE |
Constructor and Description |
---|
DefaultBeanDefinitionDocumentReader() |
Modifier and Type | Method and Description |
---|---|
protected BeanDefinitionParserDelegate |
createDelegate(XmlReaderContext readerContext,
Element root,
BeanDefinitionParserDelegate parentDelegate) |
protected BeanDefinitionParserDelegate |
createHelper(XmlReaderContext readerContext,
Element root,
BeanDefinitionParserDelegate parentDelegate)
Deprecated.
|
protected void |
doRegisterBeanDefinitions(Element root)
Register each bean definition within the given root
<beans/> element. |
protected Object |
extractSource(Element ele)
Invoke the
SourceExtractor to pull the
source metadata from the supplied Element . |
protected 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 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 |
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.
|
void |
registerBeanDefinitions(Document doc,
XmlReaderContext readerContext)
This implementation parses bean definitions according to the "spring-beans" XSD
(or DTD, historically).
|
void |
setEnvironment(Environment environment)
Deprecated.
|
public static final String BEAN_ELEMENT
public static final String NESTED_BEANS_ELEMENT
public static final String ALIAS_ELEMENT
public static final String NAME_ATTRIBUTE
public static final String ALIAS_ATTRIBUTE
public static final String IMPORT_ELEMENT
public static final String RESOURCE_ATTRIBUTE
public static final String PROFILE_ATTRIBUTE
protected final Log logger
@Deprecated public void setEnvironment(Environment environment)
BeanDefinitionDocumentReader
Used for evaluating profile information to determine whether a
<beans/>
document/element should be included or ignored.
setEnvironment
in interface BeanDefinitionDocumentReader
public void registerBeanDefinitions(Document doc, XmlReaderContext readerContext)
Opens a DOM Document; then initializes the default settings
specified at the <beans/>
level; then parses the contained bean definitions.
registerBeanDefinitions
in interface BeanDefinitionDocumentReader
doc
- the DOM documentreaderContext
- the current context of the reader
(includes the target registry and the resource being parsed)protected final XmlReaderContext getReaderContext()
protected Object extractSource(Element ele)
SourceExtractor
to pull the
source metadata from the supplied Element
.protected void doRegisterBeanDefinitions(Element root)
<beans/>
element.protected BeanDefinitionParserDelegate createDelegate(XmlReaderContext readerContext, Element root, BeanDefinitionParserDelegate parentDelegate)
@Deprecated protected BeanDefinitionParserDelegate createHelper(XmlReaderContext readerContext, Element root, BeanDefinitionParserDelegate parentDelegate)
protected void parseBeanDefinitions(Element root, BeanDefinitionParserDelegate delegate)
root
- the DOM root element of the documentprotected void importBeanDefinitionResource(Element ele)
protected void processAliasRegistration(Element ele)
protected void processBeanDefinition(Element ele, BeanDefinitionParserDelegate delegate)
protected void preProcessXml(Element root)
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.
getReaderContext()
protected void postProcessXml(Element root)
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.
getReaderContext()