|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader
public class DefaultBeanDefinitionDocumentReader
Default implementation of the 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.
Field Summary | |
---|---|
static java.lang.String |
ALIAS_ATTRIBUTE
|
static java.lang.String |
ALIAS_ELEMENT
|
static java.lang.String |
BEAN_ELEMENT
|
private BeanDefinitionParserDelegate |
delegate
|
private Environment |
environment
|
static java.lang.String |
IMPORT_ELEMENT
|
protected Log |
logger
|
static java.lang.String |
NAME_ATTRIBUTE
|
static java.lang.String |
NESTED_BEANS_ELEMENT
|
static java.lang.String |
PROFILE_ATTRIBUTE
|
private XmlReaderContext |
readerContext
|
static java.lang.String |
RESOURCE_ATTRIBUTE
|
Constructor Summary | |
---|---|
DefaultBeanDefinitionDocumentReader()
|
Method Summary | |
---|---|
protected BeanDefinitionParserDelegate |
createHelper(XmlReaderContext readerContext,
org.w3c.dom.Element root,
BeanDefinitionParserDelegate parentDelegate)
|
protected void |
doRegisterBeanDefinitions(org.w3c.dom.Element root)
Register each bean definition within the given root <beans/> element. |
protected java.lang.Object |
extractSource(org.w3c.dom.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(org.w3c.dom.Element ele)
Parse an "import" element and load the bean definitions from the given resource into the bean factory. |
protected void |
parseBeanDefinitions(org.w3c.dom.Element root,
BeanDefinitionParserDelegate delegate)
Parse the elements at the root level in the document: "import", "alias", "bean". |
private void |
parseDefaultElement(org.w3c.dom.Element ele,
BeanDefinitionParserDelegate delegate)
|
protected void |
postProcessXml(org.w3c.dom.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(org.w3c.dom.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(org.w3c.dom.Element ele)
Process the given alias element, registering the alias with the registry. |
protected void |
processBeanDefinition(org.w3c.dom.Element ele,
BeanDefinitionParserDelegate delegate)
Process the given bean element, parsing the bean definition and registering it with the registry. |
void |
registerBeanDefinitions(org.w3c.dom.Document doc,
XmlReaderContext readerContext)
Read bean definitions from the given DOM document, and register them with the given bean factory. |
void |
setEnvironment(Environment environment)
Set the Environment to use when reading bean definitions. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String BEAN_ELEMENT
public static final java.lang.String NESTED_BEANS_ELEMENT
public static final java.lang.String ALIAS_ELEMENT
public static final java.lang.String NAME_ATTRIBUTE
public static final java.lang.String ALIAS_ATTRIBUTE
public static final java.lang.String IMPORT_ELEMENT
public static final java.lang.String RESOURCE_ATTRIBUTE
public static final java.lang.String PROFILE_ATTRIBUTE
Profile
,
Constant Field Valuesprotected final Log logger
private XmlReaderContext readerContext
private Environment environment
private BeanDefinitionParserDelegate delegate
Constructor Detail |
---|
public DefaultBeanDefinitionDocumentReader()
Method Detail |
---|
public void setEnvironment(Environment environment)
<beans/>
document/element should
be included or omitted.
Default value is null
; property is required for parsing any
<beans/>
element with a profile
attribute present.
setEnvironment
in interface BeanDefinitionDocumentReader
doRegisterBeanDefinitions(org.w3c.dom.Element)
public void registerBeanDefinitions(org.w3c.dom.Document doc, XmlReaderContext readerContext)
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.
registerBeanDefinitions
in interface BeanDefinitionDocumentReader
doc
- the DOM documentreaderContext
- the current context of the reader. Includes the resource being parsedprotected void doRegisterBeanDefinitions(org.w3c.dom.Element root)
<beans/>
element.
java.lang.IllegalStateException
- if <beans profile="..."
attribute is present
and Environment property has not been setsetEnvironment(org.springframework.core.env.Environment)
protected BeanDefinitionParserDelegate createHelper(XmlReaderContext readerContext, org.w3c.dom.Element root, BeanDefinitionParserDelegate parentDelegate)
protected final XmlReaderContext getReaderContext()
protected java.lang.Object extractSource(org.w3c.dom.Element ele)
SourceExtractor
to pull the
source metadata from the supplied Element
.
protected void parseBeanDefinitions(org.w3c.dom.Element root, BeanDefinitionParserDelegate delegate)
root
- the DOM root element of the documentprivate void parseDefaultElement(org.w3c.dom.Element ele, BeanDefinitionParserDelegate delegate)
protected void importBeanDefinitionResource(org.w3c.dom.Element ele)
protected void processAliasRegistration(org.w3c.dom.Element ele)
protected void processBeanDefinition(org.w3c.dom.Element ele, BeanDefinitionParserDelegate delegate)
protected void preProcessXml(org.w3c.dom.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(org.w3c.dom.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()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |