The Spring Framework

org.springframework.beans.factory.xml
Class BeanDefinitionParserDelegate

java.lang.Object
  extended by org.springframework.beans.factory.xml.BeanDefinitionParserDelegate

public class BeanDefinitionParserDelegate
extends Object

Stateful delegate class used to parse XML bean definitions. Intended for use by both the main parser and any extension BeanDefinitionParsers or BeanDefinitionDecorators.

Since:
2.0
Author:
Rob Harrop, Juergen Hoeller, Rod Johnson
See Also:
ParserContext, DefaultBeanDefinitionDocumentReader

Field Summary
static String ABSTRACT_ATTRIBUTE
           
static String ARG_TYPE_ELEMENT
           
static String ARG_TYPE_MATCH_ATTRIBUTE
           
static String AUTOWIRE_ATTRIBUTE
           
static String AUTOWIRE_AUTODETECT_VALUE
           
static String AUTOWIRE_BY_NAME_VALUE
           
static String AUTOWIRE_BY_TYPE_VALUE
           
static String AUTOWIRE_CANDIDATE_ATTRIBUTE
           
static String AUTOWIRE_CONSTRUCTOR_VALUE
           
static String BEAN_ELEMENT
           
static String BEAN_NAME_DELIMITERS
           
static String BEAN_REF_ATTRIBUTE
           
static String BEANS_NAMESPACE_URI
           
static String CLASS_ATTRIBUTE
           
static String CONSTRUCTOR_ARG_ELEMENT
           
static String DEFAULT_AUTOWIRE_ATTRIBUTE
           
static String DEFAULT_DEPENDENCY_CHECK_ATTRIBUTE
           
static String DEFAULT_DESTROY_METHOD_ATTRIBUTE
           
static String DEFAULT_INIT_METHOD_ATTRIBUTE
           
static String DEFAULT_LAZY_INIT_ATTRIBUTE
           
static String DEFAULT_MERGE_ATTRIBUTE
           
static String DEFAULT_VALUE
           
static String DEPENDENCY_CHECK_ALL_ATTRIBUTE_VALUE
           
static String DEPENDENCY_CHECK_ATTRIBUTE
           
static String DEPENDENCY_CHECK_OBJECTS_ATTRIBUTE_VALUE
           
static String DEPENDENCY_CHECK_SIMPLE_ATTRIBUTE_VALUE
           
static String DEPENDS_ON_ATTRIBUTE
           
static String DESCRIPTION_ELEMENT
           
static String DESTROY_METHOD_ATTRIBUTE
           
static String ENTRY_ELEMENT
           
static String FACTORY_BEAN_ATTRIBUTE
           
static String FACTORY_METHOD_ATTRIBUTE
           
static String ID_ATTRIBUTE
           
static String IDREF_ELEMENT
           
static String INDEX_ATTRIBUTE
           
static String INIT_METHOD_ATTRIBUTE
           
static String KEY_ATTRIBUTE
           
static String KEY_ELEMENT
           
static String KEY_REF_ATTRIBUTE
           
static String KEY_TYPE_ATTRIBUTE
           
static String LAZY_INIT_ATTRIBUTE
           
static String LIST_ELEMENT
           
static String LOCAL_REF_ATTRIBUTE
           
protected  Log logger
           
static String LOOKUP_METHOD_ELEMENT
           
static String MAP_ELEMENT
           
static String MERGE_ATTRIBUTE
           
static String META_ELEMENT
           
static String NAME_ATTRIBUTE
           
static String NULL_ELEMENT
           
static String PARENT_ATTRIBUTE
           
static String PARENT_REF_ATTRIBUTE
           
static String PROP_ELEMENT
           
static String PROPERTY_ELEMENT
           
static String PROPS_ELEMENT
           
static String REF_ATTRIBUTE
           
static String REF_ELEMENT
           
static String REPLACED_METHOD_ELEMENT
           
static String REPLACER_ATTRIBUTE
           
static String SCOPE_ATTRIBUTE
           
static String SET_ELEMENT
           
static String SINGLETON_ATTRIBUTE
           
static String TRUE_VALUE
          Value of a T/F attribute that represents true.
static String TYPE_ATTRIBUTE
           
static String VALUE_ATTRIBUTE
           
static String VALUE_ELEMENT
           
static String VALUE_REF_ATTRIBUTE
           
static String VALUE_TYPE_ATTRIBUTE
           
 
Constructor Summary
BeanDefinitionParserDelegate(XmlReaderContext readerContext)
          Create a new BeanDefinitionParserDelegate associated with the supplied XmlReaderContext.
 
Method Summary
protected  Object buildTypedStringValue(String value, String targetTypeName, Element ele)
          Build a typed String value Object for the given raw value.
protected  Object buildTypedStringValueForMap(String value, String defaultTypeClassName, Element entryEle)
          Build a typed String value Object for the given raw value.
 BeanDefinitionHolder decorateBeanDefinitionIfRequired(Element ele, BeanDefinitionHolder definitionHolder)
           
protected  void error(String message, Element source)
          Report an error with the given message for the given source element.
protected  void error(String message, Element source, Throwable cause)
          Report an error with the given message for the given source element.
protected  Object extractSource(Element ele)
          Invoke the SourceExtractor to pull the source metadata from the supplied Element.
 int getAutowireMode(String att)
           
 DocumentDefaultsDefinition getDefaults()
          Return the defaults definition object, or null if the defaults have been initialized yet.
 int getDependencyCheck(String att)
           
 XmlReaderContext getReaderContext()
          Get the XmlReaderContext associated with this helper instance.
 void initDefaults(Element root)
          Initialize the default lazy-init, autowire, dependency check settings, init-method, destroy-method and merge settings.
 boolean isDefaultNamespace(String namespaceUri)
           
 BeanDefinitionHolder parseBeanDefinitionElement(Element ele)
          Parses the supplied <bean> element.
 BeanDefinitionHolder parseBeanDefinitionElement(Element ele, BeanDefinition containingBean)
          Parses the supplied <bean> element.
 AbstractBeanDefinition parseBeanDefinitionElement(Element ele, String beanName, BeanDefinition containingBean)
          Parse the bean definition itself, without regard to name or aliases.
 void parseConstructorArgElement(Element ele, BeanDefinition bd)
          Parse a constructor-arg element.
 void parseConstructorArgElements(Element beanEle, BeanDefinition bd)
          Parse constructor-arg sub-elements of the given bean element.
 BeanDefinition parseCustomElement(Element ele)
           
 BeanDefinition parseCustomElement(Element ele, BeanDefinition containingBd)
           
 Object parseKeyElement(Element keyEle, BeanDefinition bd, String defaultKeyTypeClassName)
          Parse a key sub-element of a map element.
 List parseListElement(Element collectionEle, BeanDefinition bd)
          Parse a list element.
 void parseLookupOverrideSubElements(Element beanEle, MethodOverrides overrides)
          Parse lookup-override sub-elements of the given bean element.
 Map parseMapElement(Element mapEle, BeanDefinition bd)
          Parse a map element.
 boolean parseMergeAttribute(Element collectionElement)
          Parse the merge attribute of a collection element, if any.
 void parseMetaElements(Element ele, AttributeAccessor attributeAccessor)
           
 void parsePropertyElement(Element ele, BeanDefinition bd)
          Parse a property element.
 void parsePropertyElements(Element beanEle, BeanDefinition bd)
          Parse property sub-elements of the given bean element.
 Object parsePropertySubElement(Element ele, BeanDefinition bd)
           
 Object parsePropertySubElement(Element ele, BeanDefinition bd, String defaultTypeClassName)
          Parse a value, ref or collection sub-element of a property or constructor-arg element.
 Object parsePropertyValue(Element ele, BeanDefinition bd, String propertyName)
          Get the value of a property element.
 Properties parsePropsElement(Element propsEle)
          Parse a props element.
 void parseReplacedMethodSubElements(Element beanEle, MethodOverrides overrides)
          Parse replaced-method sub-elements of the given bean element.
 Set parseSetElement(Element collectionEle, BeanDefinition bd)
          Parse a set element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BEANS_NAMESPACE_URI

public static final String BEANS_NAMESPACE_URI
See Also:
Constant Field Values

BEAN_NAME_DELIMITERS

public static final String BEAN_NAME_DELIMITERS
See Also:
Constant Field Values

TRUE_VALUE

public static final 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 String DEFAULT_VALUE
See Also:
Constant Field Values

DESCRIPTION_ELEMENT

public static final String DESCRIPTION_ELEMENT
See Also:
Constant Field Values

AUTOWIRE_BY_NAME_VALUE

public static final String AUTOWIRE_BY_NAME_VALUE
See Also:
Constant Field Values

AUTOWIRE_BY_TYPE_VALUE

public static final String AUTOWIRE_BY_TYPE_VALUE
See Also:
Constant Field Values

AUTOWIRE_CONSTRUCTOR_VALUE

public static final String AUTOWIRE_CONSTRUCTOR_VALUE
See Also:
Constant Field Values

AUTOWIRE_AUTODETECT_VALUE

public static final String AUTOWIRE_AUTODETECT_VALUE
See Also:
Constant Field Values

DEPENDENCY_CHECK_ALL_ATTRIBUTE_VALUE

public static final String DEPENDENCY_CHECK_ALL_ATTRIBUTE_VALUE
See Also:
Constant Field Values

DEPENDENCY_CHECK_SIMPLE_ATTRIBUTE_VALUE

public static final String DEPENDENCY_CHECK_SIMPLE_ATTRIBUTE_VALUE
See Also:
Constant Field Values

DEPENDENCY_CHECK_OBJECTS_ATTRIBUTE_VALUE

public static final String DEPENDENCY_CHECK_OBJECTS_ATTRIBUTE_VALUE
See Also:
Constant Field Values

NAME_ATTRIBUTE

public static final String NAME_ATTRIBUTE
See Also:
Constant Field Values

BEAN_ELEMENT

public static final String BEAN_ELEMENT
See Also:
Constant Field Values

META_ELEMENT

public static final String META_ELEMENT
See Also:
Constant Field Values

ID_ATTRIBUTE

public static final String ID_ATTRIBUTE
See Also:
Constant Field Values

PARENT_ATTRIBUTE

public static final String PARENT_ATTRIBUTE
See Also:
Constant Field Values

CLASS_ATTRIBUTE

public static final String CLASS_ATTRIBUTE
See Also:
Constant Field Values

ABSTRACT_ATTRIBUTE

public static final String ABSTRACT_ATTRIBUTE
See Also:
Constant Field Values

SCOPE_ATTRIBUTE

public static final String SCOPE_ATTRIBUTE
See Also:
Constant Field Values

SINGLETON_ATTRIBUTE

public static final String SINGLETON_ATTRIBUTE
See Also:
Constant Field Values

LAZY_INIT_ATTRIBUTE

public static final String LAZY_INIT_ATTRIBUTE
See Also:
Constant Field Values

AUTOWIRE_ATTRIBUTE

public static final String AUTOWIRE_ATTRIBUTE
See Also:
Constant Field Values

AUTOWIRE_CANDIDATE_ATTRIBUTE

public static final String AUTOWIRE_CANDIDATE_ATTRIBUTE
See Also:
Constant Field Values

DEPENDENCY_CHECK_ATTRIBUTE

public static final String DEPENDENCY_CHECK_ATTRIBUTE
See Also:
Constant Field Values

DEPENDS_ON_ATTRIBUTE

public static final String DEPENDS_ON_ATTRIBUTE
See Also:
Constant Field Values

INIT_METHOD_ATTRIBUTE

public static final String INIT_METHOD_ATTRIBUTE
See Also:
Constant Field Values

DESTROY_METHOD_ATTRIBUTE

public static final String DESTROY_METHOD_ATTRIBUTE
See Also:
Constant Field Values

FACTORY_METHOD_ATTRIBUTE

public static final String FACTORY_METHOD_ATTRIBUTE
See Also:
Constant Field Values

FACTORY_BEAN_ATTRIBUTE

public static final String FACTORY_BEAN_ATTRIBUTE
See Also:
Constant Field Values

CONSTRUCTOR_ARG_ELEMENT

public static final String CONSTRUCTOR_ARG_ELEMENT
See Also:
Constant Field Values

INDEX_ATTRIBUTE

public static final String INDEX_ATTRIBUTE
See Also:
Constant Field Values

TYPE_ATTRIBUTE

public static final String TYPE_ATTRIBUTE
See Also:
Constant Field Values

VALUE_TYPE_ATTRIBUTE

public static final String VALUE_TYPE_ATTRIBUTE
See Also:
Constant Field Values

KEY_TYPE_ATTRIBUTE

public static final String KEY_TYPE_ATTRIBUTE
See Also:
Constant Field Values

PROPERTY_ELEMENT

public static final String PROPERTY_ELEMENT
See Also:
Constant Field Values

REF_ATTRIBUTE

public static final String REF_ATTRIBUTE
See Also:
Constant Field Values

VALUE_ATTRIBUTE

public static final String VALUE_ATTRIBUTE
See Also:
Constant Field Values

LOOKUP_METHOD_ELEMENT

public static final String LOOKUP_METHOD_ELEMENT
See Also:
Constant Field Values

REPLACED_METHOD_ELEMENT

public static final String REPLACED_METHOD_ELEMENT
See Also:
Constant Field Values

REPLACER_ATTRIBUTE

public static final String REPLACER_ATTRIBUTE
See Also:
Constant Field Values

ARG_TYPE_ELEMENT

public static final String ARG_TYPE_ELEMENT
See Also:
Constant Field Values

ARG_TYPE_MATCH_ATTRIBUTE

public static final String ARG_TYPE_MATCH_ATTRIBUTE
See Also:
Constant Field Values

REF_ELEMENT

public static final String REF_ELEMENT
See Also:
Constant Field Values

IDREF_ELEMENT

public static final String IDREF_ELEMENT
See Also:
Constant Field Values

BEAN_REF_ATTRIBUTE

public static final String BEAN_REF_ATTRIBUTE
See Also:
Constant Field Values

LOCAL_REF_ATTRIBUTE

public static final String LOCAL_REF_ATTRIBUTE
See Also:
Constant Field Values

PARENT_REF_ATTRIBUTE

public static final String PARENT_REF_ATTRIBUTE
See Also:
Constant Field Values

VALUE_ELEMENT

public static final String VALUE_ELEMENT
See Also:
Constant Field Values

NULL_ELEMENT

public static final String NULL_ELEMENT
See Also:
Constant Field Values

LIST_ELEMENT

public static final String LIST_ELEMENT
See Also:
Constant Field Values

SET_ELEMENT

public static final String SET_ELEMENT
See Also:
Constant Field Values

MAP_ELEMENT

public static final String MAP_ELEMENT
See Also:
Constant Field Values

ENTRY_ELEMENT

public static final String ENTRY_ELEMENT
See Also:
Constant Field Values

KEY_ELEMENT

public static final String KEY_ELEMENT
See Also:
Constant Field Values

KEY_ATTRIBUTE

public static final String KEY_ATTRIBUTE
See Also:
Constant Field Values

KEY_REF_ATTRIBUTE

public static final String KEY_REF_ATTRIBUTE
See Also:
Constant Field Values

VALUE_REF_ATTRIBUTE

public static final String VALUE_REF_ATTRIBUTE
See Also:
Constant Field Values

PROPS_ELEMENT

public static final String PROPS_ELEMENT
See Also:
Constant Field Values

PROP_ELEMENT

public static final String PROP_ELEMENT
See Also:
Constant Field Values

MERGE_ATTRIBUTE

public static final String MERGE_ATTRIBUTE
See Also:
Constant Field Values

DEFAULT_LAZY_INIT_ATTRIBUTE

public static final String DEFAULT_LAZY_INIT_ATTRIBUTE
See Also:
Constant Field Values

DEFAULT_AUTOWIRE_ATTRIBUTE

public static final String DEFAULT_AUTOWIRE_ATTRIBUTE
See Also:
Constant Field Values

DEFAULT_DEPENDENCY_CHECK_ATTRIBUTE

public static final String DEFAULT_DEPENDENCY_CHECK_ATTRIBUTE
See Also:
Constant Field Values

DEFAULT_INIT_METHOD_ATTRIBUTE

public static final String DEFAULT_INIT_METHOD_ATTRIBUTE
See Also:
Constant Field Values

DEFAULT_DESTROY_METHOD_ATTRIBUTE

public static final String DEFAULT_DESTROY_METHOD_ATTRIBUTE
See Also:
Constant Field Values

DEFAULT_MERGE_ATTRIBUTE

public static final String DEFAULT_MERGE_ATTRIBUTE
See Also:
Constant Field Values

logger

protected final Log logger
Constructor Detail

BeanDefinitionParserDelegate

public BeanDefinitionParserDelegate(XmlReaderContext readerContext)
Create a new BeanDefinitionParserDelegate associated with the supplied XmlReaderContext.

Method Detail

getReaderContext

public final XmlReaderContext getReaderContext()
Get the XmlReaderContext associated with this helper instance.


extractSource

protected Object extractSource(Element ele)
Invoke the SourceExtractor to pull the source metadata from the supplied Element.


error

protected void error(String message,
                     Element source)
Report an error with the given message for the given source element.


error

protected void error(String message,
                     Element source,
                     Throwable cause)
Report an error with the given message for the given source element.


initDefaults

public void initDefaults(Element root)
Initialize the default lazy-init, autowire, dependency check settings, init-method, destroy-method and merge settings.

See Also:
getDefaults()

getDefaults

public DocumentDefaultsDefinition getDefaults()
Return the defaults definition object, or null if the defaults have been initialized yet.


parseBeanDefinitionElement

public BeanDefinitionHolder parseBeanDefinitionElement(Element ele)
Parses the supplied <bean> element. May return null if there were errors during parse. Errors are reported to the ProblemReporter.


parseBeanDefinitionElement

public BeanDefinitionHolder parseBeanDefinitionElement(Element ele,
                                                       BeanDefinition containingBean)
Parses the supplied <bean> element. May return null if there were errors during parse. Errors are reported to the ProblemReporter.


parseBeanDefinitionElement

public AbstractBeanDefinition parseBeanDefinitionElement(Element ele,
                                                         String beanName,
                                                         BeanDefinition containingBean)
Parse the bean definition itself, without regard to name or aliases. May return null if problems occured during the parse of the bean definition.


parseMetaElements

public void parseMetaElements(Element ele,
                              AttributeAccessor attributeAccessor)

getDependencyCheck

public int getDependencyCheck(String att)

getAutowireMode

public int getAutowireMode(String att)

parseConstructorArgElements

public void parseConstructorArgElements(Element beanEle,
                                        BeanDefinition bd)
Parse constructor-arg sub-elements of the given bean element.


parsePropertyElements

public void parsePropertyElements(Element beanEle,
                                  BeanDefinition bd)
Parse property sub-elements of the given bean element.


parseLookupOverrideSubElements

public void parseLookupOverrideSubElements(Element beanEle,
                                           MethodOverrides overrides)
Parse lookup-override sub-elements of the given bean element.


parseReplacedMethodSubElements

public void parseReplacedMethodSubElements(Element beanEle,
                                           MethodOverrides overrides)
Parse replaced-method sub-elements of the given bean element.


parseConstructorArgElement

public void parseConstructorArgElement(Element ele,
                                       BeanDefinition bd)
Parse a constructor-arg element.


parsePropertyElement

public void parsePropertyElement(Element ele,
                                 BeanDefinition bd)
Parse a property element.


parsePropertyValue

public Object parsePropertyValue(Element ele,
                                 BeanDefinition bd,
                                 String propertyName)
Get the value of a property element. May be a list etc. Also used for constructor arguments, "propertyName" being null in this case.


parsePropertySubElement

public Object parsePropertySubElement(Element ele,
                                      BeanDefinition bd)

parsePropertySubElement

public Object parsePropertySubElement(Element ele,
                                      BeanDefinition bd,
                                      String defaultTypeClassName)
Parse a value, ref or collection sub-element of a property or constructor-arg element.

Parameters:
ele - subelement of property element; we don't know which yet
defaultTypeClassName - the default type (class name) for any <value> tag that might be created

buildTypedStringValue

protected Object buildTypedStringValue(String value,
                                       String targetTypeName,
                                       Element ele)
                                throws ClassNotFoundException
Build a typed String value Object for the given raw value.

Throws:
ClassNotFoundException
See Also:
TypedStringValue

parseListElement

public List parseListElement(Element collectionEle,
                             BeanDefinition bd)
Parse a list element.


parseSetElement

public Set parseSetElement(Element collectionEle,
                           BeanDefinition bd)
Parse a set element.


parseMapElement

public Map parseMapElement(Element mapEle,
                           BeanDefinition bd)
Parse a map element.


buildTypedStringValueForMap

protected final Object buildTypedStringValueForMap(String value,
                                                   String defaultTypeClassName,
                                                   Element entryEle)
Build a typed String value Object for the given raw value.

See Also:
TypedStringValue

parseKeyElement

public Object parseKeyElement(Element keyEle,
                              BeanDefinition bd,
                              String defaultKeyTypeClassName)
Parse a key sub-element of a map element.


parsePropsElement

public Properties parsePropsElement(Element propsEle)
Parse a props element.


parseMergeAttribute

public boolean parseMergeAttribute(Element collectionElement)
Parse the merge attribute of a collection element, if any.


parseCustomElement

public BeanDefinition parseCustomElement(Element ele)

parseCustomElement

public BeanDefinition parseCustomElement(Element ele,
                                         BeanDefinition containingBd)

decorateBeanDefinitionIfRequired

public BeanDefinitionHolder decorateBeanDefinitionIfRequired(Element ele,
                                                             BeanDefinitionHolder definitionHolder)

isDefaultNamespace

public boolean isDefaultNamespace(String namespaceUri)

The Spring Framework

Copyright © 2002-2007 The Spring Framework.