org.springframework.beans.factory.xml
Class DefaultXmlBeanDefinitionParser

java.lang.Object
  extended byorg.springframework.beans.factory.xml.DefaultXmlBeanDefinitionParser
All Implemented Interfaces:
XmlBeanDefinitionParser

public class DefaultXmlBeanDefinitionParser
extends java.lang.Object
implements XmlBeanDefinitionParser

Default implementation of the XmlBeanDefinitionParser interface. Parses bean definitions according to the "spring-beans" DTD.

Since:
18.12.2003
Author:
Rod Johnson, Juergen Hoeller

Field Summary
static java.lang.String AUTOWIRE_ATTRIBUTE
           
static java.lang.String AUTOWIRE_AUTODETECT_VALUE
           
static java.lang.String AUTOWIRE_BY_NAME_VALUE
           
static java.lang.String AUTOWIRE_BY_TYPE_VALUE
           
static java.lang.String AUTOWIRE_CONSTRUCTOR_VALUE
           
static java.lang.String BEAN_ELEMENT
           
static java.lang.String BEAN_NAME_DELIMITERS
           
static java.lang.String BEAN_REF_ATTRIBUTE
           
static java.lang.String CLASS_ATTRIBUTE
           
static java.lang.String CONSTRUCTOR_ARG_ELEMENT
           
static java.lang.String DEFAULT_AUTOWIRE_ATTRIBUTE
           
static java.lang.String DEFAULT_DEPENDENCY_CHECK_ATTRIBUTE
           
static java.lang.String DEFAULT_LAZY_INIT_ATTRIBUTE
           
static java.lang.String DEFAULT_VALUE
           
static java.lang.String DEPENDENCY_CHECK_ALL_ATTRIBUTE_VALUE
           
static java.lang.String DEPENDENCY_CHECK_ATTRIBUTE
           
static java.lang.String DEPENDENCY_CHECK_OBJECTS_ATTRIBUTE_VALUE
           
static java.lang.String DEPENDENCY_CHECK_SIMPLE_ATTRIBUTE_VALUE
           
static java.lang.String DEPENDS_ON_ATTRIBUTE
           
static java.lang.String DESCRIPTION_ELEMENT
           
static java.lang.String DESTROY_METHOD_ATTRIBUTE
           
static java.lang.String ENTRY_ELEMENT
           
static java.lang.String ID_ATTRIBUTE
           
static java.lang.String IDREF_ELEMENT
           
static java.lang.String INDEX_ATTRIBUTE
           
static java.lang.String INIT_METHOD_ATTRIBUTE
           
static java.lang.String KEY_ATTRIBUTE
           
static java.lang.String LAZY_INIT_ATTRIBUTE
           
static java.lang.String LIST_ELEMENT
           
static java.lang.String LOCAL_REF_ATTRIBUTE
           
protected  org.apache.commons.logging.Log logger
           
static java.lang.String MAP_ELEMENT
           
static java.lang.String NAME_ATTRIBUTE
           
static java.lang.String NULL_ELEMENT
           
static java.lang.String PARENT_ATTRIBUTE
           
static java.lang.String PROP_ELEMENT
           
static java.lang.String PROPERTY_ELEMENT
           
static java.lang.String PROPS_ELEMENT
           
static java.lang.String REF_ELEMENT
           
static java.lang.String SET_ELEMENT
           
static java.lang.String SINGLETON_ATTRIBUTE
           
static java.lang.String TRUE_VALUE
          Value of a T/F attribute that represents true.
static java.lang.String TYPE_ATTRIBUTE
           
static java.lang.String VALUE_ELEMENT
           
 
Constructor Summary
DefaultXmlBeanDefinitionParser()
           
 
Method Summary
protected  int getAutowireMode(java.lang.String att)
           
protected  java.lang.ClassLoader getBeanClassLoader()
           
protected  BeanDefinitionRegistry getBeanFactory()
           
protected  java.util.List getChildElementsByTagName(org.w3c.dom.Element mapEle, java.lang.String elementName)
          Don't use the horrible DOM API to get child elements: Get an element's children with a given element name
protected  ConstructorArgumentValues getConstructorArgSubElements(java.lang.String beanName, org.w3c.dom.Element beanEle)
          Parse constructor argument subelements of the given bean element.
protected  java.lang.String getDefaultAutowire()
           
protected  java.lang.String getDefaultDependencyCheck()
           
protected  java.lang.String getDefaultLazyInit()
           
protected  int getDependencyCheck(java.lang.String att)
           
protected  java.util.List getList(org.w3c.dom.Element collectionEle, java.lang.String beanName)
           
protected  java.util.Map getMap(org.w3c.dom.Element mapEle, java.lang.String beanName)
           
protected  java.lang.Object getPropertyValue(org.w3c.dom.Element ele, java.lang.String beanName)
          Get the value of a property element.
protected  MutablePropertyValues getPropertyValueSubElements(java.lang.String beanName, org.w3c.dom.Element beanEle)
          Parse property value subelements of the given bean element.
protected  java.util.Properties getProps(org.w3c.dom.Element propsEle, java.lang.String beanName)
           
protected  java.util.Set getSet(org.w3c.dom.Element collectionEle, java.lang.String beanName)
           
protected  java.lang.String getTextValue(org.w3c.dom.Element ele, java.lang.String beanName)
          Make the horrible DOM API slightly more bearable: get the text value we know this element contains
protected  void loadBeanDefinition(org.w3c.dom.Element ele)
          Parse an element definition: We know this is a BEAN element.
protected  AbstractBeanDefinition parseBeanDefinition(org.w3c.dom.Element ele, java.lang.String beanName)
          Parse a standard bean definition.
protected  void parseConstructorArgElement(java.lang.String beanName, ConstructorArgumentValues cargs, org.w3c.dom.Element ele)
          Parse a constructor-arg element.
protected  void parsePropertyElement(java.lang.String beanName, MutablePropertyValues pvs, org.w3c.dom.Element ele)
          Parse a property element.
protected  java.lang.Object parsePropertySubelement(org.w3c.dom.Element ele, java.lang.String beanName)
          Parse a value, ref or collection subelement of a property element
 void registerBeanDefinitions(BeanDefinitionRegistry beanFactory, java.lang.ClassLoader beanClassLoader, org.w3c.dom.Document doc, Resource resource)
          Parse bean definitions from the given DOM document, and register them with the given bean factory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BEAN_NAME_DELIMITERS

public static final java.lang.String BEAN_NAME_DELIMITERS
See Also:
Constant Field Values

TRUE_VALUE

public static final java.lang.String TRUE_VALUE
Value of a T/F attribute that represents true. Anything else represents false. Case seNsItive.

See Also:
Constant Field Values

DEFAULT_VALUE

public static final java.lang.String DEFAULT_VALUE
See Also:
Constant Field Values

DEFAULT_LAZY_INIT_ATTRIBUTE

public static final java.lang.String DEFAULT_LAZY_INIT_ATTRIBUTE
See Also:
Constant Field Values

DEFAULT_DEPENDENCY_CHECK_ATTRIBUTE

public static final java.lang.String DEFAULT_DEPENDENCY_CHECK_ATTRIBUTE
See Also:
Constant Field Values

DEFAULT_AUTOWIRE_ATTRIBUTE

public static final java.lang.String DEFAULT_AUTOWIRE_ATTRIBUTE
See Also:
Constant Field Values

BEAN_ELEMENT

public static final java.lang.String BEAN_ELEMENT
See Also:
Constant Field Values

DESCRIPTION_ELEMENT

public static final java.lang.String DESCRIPTION_ELEMENT
See Also:
Constant Field Values

CLASS_ATTRIBUTE

public static final java.lang.String CLASS_ATTRIBUTE
See Also:
Constant Field Values

PARENT_ATTRIBUTE

public static final java.lang.String PARENT_ATTRIBUTE
See Also:
Constant Field Values

ID_ATTRIBUTE

public static final java.lang.String ID_ATTRIBUTE
See Also:
Constant Field Values

NAME_ATTRIBUTE

public static final java.lang.String NAME_ATTRIBUTE
See Also:
Constant Field Values

SINGLETON_ATTRIBUTE

public static final java.lang.String SINGLETON_ATTRIBUTE
See Also:
Constant Field Values

DEPENDS_ON_ATTRIBUTE

public static final java.lang.String DEPENDS_ON_ATTRIBUTE
See Also:
Constant Field Values

INIT_METHOD_ATTRIBUTE

public static final java.lang.String INIT_METHOD_ATTRIBUTE
See Also:
Constant Field Values

DESTROY_METHOD_ATTRIBUTE

public static final java.lang.String DESTROY_METHOD_ATTRIBUTE
See Also:
Constant Field Values

CONSTRUCTOR_ARG_ELEMENT

public static final java.lang.String CONSTRUCTOR_ARG_ELEMENT
See Also:
Constant Field Values

INDEX_ATTRIBUTE

public static final java.lang.String INDEX_ATTRIBUTE
See Also:
Constant Field Values

TYPE_ATTRIBUTE

public static final java.lang.String TYPE_ATTRIBUTE
See Also:
Constant Field Values

PROPERTY_ELEMENT

public static final java.lang.String PROPERTY_ELEMENT
See Also:
Constant Field Values

REF_ELEMENT

public static final java.lang.String REF_ELEMENT
See Also:
Constant Field Values

IDREF_ELEMENT

public static final java.lang.String IDREF_ELEMENT
See Also:
Constant Field Values

BEAN_REF_ATTRIBUTE

public static final java.lang.String BEAN_REF_ATTRIBUTE
See Also:
Constant Field Values

LOCAL_REF_ATTRIBUTE

public static final java.lang.String LOCAL_REF_ATTRIBUTE
See Also:
Constant Field Values

LIST_ELEMENT

public static final java.lang.String LIST_ELEMENT
See Also:
Constant Field Values

SET_ELEMENT

public static final java.lang.String SET_ELEMENT
See Also:
Constant Field Values

MAP_ELEMENT

public static final java.lang.String MAP_ELEMENT
See Also:
Constant Field Values

KEY_ATTRIBUTE

public static final java.lang.String KEY_ATTRIBUTE
See Also:
Constant Field Values

ENTRY_ELEMENT

public static final java.lang.String ENTRY_ELEMENT
See Also:
Constant Field Values

VALUE_ELEMENT

public static final java.lang.String VALUE_ELEMENT
See Also:
Constant Field Values

NULL_ELEMENT

public static final java.lang.String NULL_ELEMENT
See Also:
Constant Field Values

PROPS_ELEMENT

public static final java.lang.String PROPS_ELEMENT
See Also:
Constant Field Values

PROP_ELEMENT

public static final java.lang.String PROP_ELEMENT
See Also:
Constant Field Values

LAZY_INIT_ATTRIBUTE

public static final java.lang.String LAZY_INIT_ATTRIBUTE
See Also:
Constant Field Values

DEPENDENCY_CHECK_ATTRIBUTE

public static final java.lang.String DEPENDENCY_CHECK_ATTRIBUTE
See Also:
Constant Field Values

DEPENDENCY_CHECK_ALL_ATTRIBUTE_VALUE

public static final java.lang.String DEPENDENCY_CHECK_ALL_ATTRIBUTE_VALUE
See Also:
Constant Field Values

DEPENDENCY_CHECK_SIMPLE_ATTRIBUTE_VALUE

public static final java.lang.String DEPENDENCY_CHECK_SIMPLE_ATTRIBUTE_VALUE
See Also:
Constant Field Values

DEPENDENCY_CHECK_OBJECTS_ATTRIBUTE_VALUE

public static final java.lang.String DEPENDENCY_CHECK_OBJECTS_ATTRIBUTE_VALUE
See Also:
Constant Field Values

AUTOWIRE_ATTRIBUTE

public static final java.lang.String AUTOWIRE_ATTRIBUTE
See Also:
Constant Field Values

AUTOWIRE_BY_NAME_VALUE

public static final java.lang.String AUTOWIRE_BY_NAME_VALUE
See Also:
Constant Field Values

AUTOWIRE_BY_TYPE_VALUE

public static final java.lang.String AUTOWIRE_BY_TYPE_VALUE
See Also:
Constant Field Values

AUTOWIRE_CONSTRUCTOR_VALUE

public static final java.lang.String AUTOWIRE_CONSTRUCTOR_VALUE
See Also:
Constant Field Values

AUTOWIRE_AUTODETECT_VALUE

public static final java.lang.String AUTOWIRE_AUTODETECT_VALUE
See Also:
Constant Field Values

logger

protected final org.apache.commons.logging.Log logger
Constructor Detail

DefaultXmlBeanDefinitionParser

public DefaultXmlBeanDefinitionParser()
Method Detail

registerBeanDefinitions

public void registerBeanDefinitions(BeanDefinitionRegistry beanFactory,
                                    java.lang.ClassLoader beanClassLoader,
                                    org.w3c.dom.Document doc,
                                    Resource resource)
Description copied from interface: XmlBeanDefinitionParser
Parse bean definitions from the given DOM document, and register them with the given bean factory.

Specified by:
registerBeanDefinitions in interface XmlBeanDefinitionParser
Parameters:
beanFactory - the bean factory to register the bean definitions with
beanClassLoader - class loader to use for bean classes (null suggests to not load bean classes but just register bean definitions with class names, for example when just registering beans in a registry but not actually instantiating them in a factory)
doc - the DOM document
resource - descriptor of the original XML resource (useful for displaying parse errors)

getBeanFactory

protected BeanDefinitionRegistry getBeanFactory()

getBeanClassLoader

protected java.lang.ClassLoader getBeanClassLoader()

getDefaultLazyInit

protected java.lang.String getDefaultLazyInit()

getDefaultDependencyCheck

protected java.lang.String getDefaultDependencyCheck()

getDefaultAutowire

protected java.lang.String getDefaultAutowire()

loadBeanDefinition

protected void loadBeanDefinition(org.w3c.dom.Element ele)
Parse an element definition: We know this is a BEAN element. Bean elements specify their canonical name as id attribute and their aliases as a delimited name attribute. If no id specified, use the first name in the name attribute as canonical name, registering all others as aliases.


parseBeanDefinition

protected AbstractBeanDefinition parseBeanDefinition(org.w3c.dom.Element ele,
                                                     java.lang.String beanName)
Parse a standard bean definition.


getConstructorArgSubElements

protected ConstructorArgumentValues getConstructorArgSubElements(java.lang.String beanName,
                                                                 org.w3c.dom.Element beanEle)
                                                          throws java.lang.ClassNotFoundException
Parse constructor argument subelements of the given bean element.

Throws:
java.lang.ClassNotFoundException

getPropertyValueSubElements

protected MutablePropertyValues getPropertyValueSubElements(java.lang.String beanName,
                                                            org.w3c.dom.Element beanEle)
Parse property value subelements of the given bean element.


parseConstructorArgElement

protected void parseConstructorArgElement(java.lang.String beanName,
                                          ConstructorArgumentValues cargs,
                                          org.w3c.dom.Element ele)
                                   throws org.w3c.dom.DOMException,
                                          java.lang.ClassNotFoundException
Parse a constructor-arg element.

Throws:
org.w3c.dom.DOMException
java.lang.ClassNotFoundException

parsePropertyElement

protected void parsePropertyElement(java.lang.String beanName,
                                    MutablePropertyValues pvs,
                                    org.w3c.dom.Element ele)
                             throws org.w3c.dom.DOMException
Parse a property element.

Throws:
org.w3c.dom.DOMException

getPropertyValue

protected java.lang.Object getPropertyValue(org.w3c.dom.Element ele,
                                            java.lang.String beanName)
Get the value of a property element. May be a list.

Parameters:
ele - property element

parsePropertySubelement

protected java.lang.Object parsePropertySubelement(org.w3c.dom.Element ele,
                                                   java.lang.String beanName)
Parse a value, ref or collection subelement of a property element

Parameters:
ele - subelement of property element; we don't know which yet

getList

protected java.util.List getList(org.w3c.dom.Element collectionEle,
                                 java.lang.String beanName)

getSet

protected java.util.Set getSet(org.w3c.dom.Element collectionEle,
                               java.lang.String beanName)

getMap

protected java.util.Map getMap(org.w3c.dom.Element mapEle,
                               java.lang.String beanName)

getChildElementsByTagName

protected java.util.List getChildElementsByTagName(org.w3c.dom.Element mapEle,
                                                   java.lang.String elementName)
Don't use the horrible DOM API to get child elements: Get an element's children with a given element name


getProps

protected java.util.Properties getProps(org.w3c.dom.Element propsEle,
                                        java.lang.String beanName)

getTextValue

protected java.lang.String getTextValue(org.w3c.dom.Element ele,
                                        java.lang.String beanName)
Make the horrible DOM API slightly more bearable: get the text value we know this element contains


getDependencyCheck

protected int getDependencyCheck(java.lang.String att)

getAutowireMode

protected int getAutowireMode(java.lang.String att)


Copyright (C) 2003-2004 The Spring Framework Project.