Class BeanDefinitionParserDelegate
java.lang.Object
org.springframework.beans.factory.xml.BeanDefinitionParserDelegate
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, Mark Fisher, Gary Russell
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected final org.apache.commons.logging.Logstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringValue of a T/F attribute that represents true.static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final String -
Constructor Summary
ConstructorsConstructorDescriptionBeanDefinitionParserDelegate(XmlReaderContext readerContext) Create a new BeanDefinitionParserDelegate associated with the suppliedXmlReaderContext. -
Method Summary
Modifier and TypeMethodDescriptionprotected TypedStringValuebuildTypedStringValue(String value, @Nullable String targetTypeName) Build a typed String value Object for the given raw value.protected final ObjectbuildTypedStringValueForMap(String value, String defaultTypeName, Element entryEle) Build a typed String value Object for the given raw value.protected voidcheckNameUniqueness(String beanName, List<String> aliases, Element beanElement) Validate that the specified bean name and aliases have not been used already within the current level of beans element nesting.protected AbstractBeanDefinitioncreateBeanDefinition(@Nullable String className, @Nullable String parentName) Create a bean definition for the given class name and parent name.decorateBeanDefinitionIfRequired(Element ele, BeanDefinitionHolder originalDef) Decorate the given bean definition through a namespace handler, if applicable.decorateBeanDefinitionIfRequired(Element ele, BeanDefinitionHolder originalDef, @Nullable BeanDefinition containingBd) Decorate the given bean definition through a namespace handler, if applicable.decorateIfRequired(Node node, BeanDefinitionHolder originalDef, @Nullable BeanDefinition containingBd) Decorate the given bean definition through a namespace handler, if applicable.protected voidReport an error with the given message for the given source element.protected voidReport an error with the given message for the given source element.protected voidReport an error with the given message for the given source element.extractSource(Element ele) Invoke theSourceExtractorto pull the source metadata from the suppliedElement.Return any patterns provided in the 'default-autowire-candidates' attribute of the top-level<beans/>element.intgetAutowireMode(String attrValue) Parse the given autowire attribute value intoAbstractBeanDefinitionautowire constants.Return the default settings for bean definitions as indicated within the attributes of the top-level<beans/>element.Return the defaults definition object.getLocalName(Node node) Get the local name for the suppliedNode.getNamespaceURI(Node node) Get the namespace URI for the supplied node.final XmlReaderContextGet theXmlReaderContextassociated with this helper instance.voidinitDefaults(Element root) Initialize the default settings assuming anullparent delegate.voidinitDefaults(Element root, @Nullable BeanDefinitionParserDelegate parent) Initialize the default lazy-init, autowire, dependency check settings, init-method, destroy-method and merge settings.booleanisDefaultNamespace(@Nullable String namespaceUri) Determine whether the given URI indicates the default namespace.booleanisDefaultNamespace(Node node) Determine whether the given node indicates the default namespace.booleannodeNameEquals(Node node, String desiredName) Determine whether the name of the supplied node is equal to the supplied name.parseArrayElement(Element arrayEle, @Nullable BeanDefinition bd) Parse an array element.parseBeanDefinitionAttributes(Element ele, String beanName, @Nullable BeanDefinition containingBean, AbstractBeanDefinition bd) Apply the attributes of the given bean element to the given bean * definition.Parses the supplied<bean>element.parseBeanDefinitionElement(Element ele, String beanName, @Nullable BeanDefinition containingBean) Parse the bean definition itself, without regard to name or aliases.parseBeanDefinitionElement(Element ele, @Nullable BeanDefinition containingBean) Parses the supplied<bean>element.protected voidparseCollectionElements(NodeList elementNodes, Collection<Object> target, @Nullable BeanDefinition bd, String defaultElementType) voidParse a constructor-arg element.voidparseConstructorArgElements(Element beanEle, BeanDefinition bd) Parse constructor-arg sub-elements of the given bean element.Parse a custom element (outside the default namespace).parseCustomElement(Element ele, @Nullable BeanDefinition containingBd) Parse a custom element (outside the default namespace).parseIdRefElement(Element ele) Return a typed String value Object for the given 'idref' element.parseKeyElement(Element keyEle, @Nullable BeanDefinition bd, String defaultKeyTypeName) Parse a key sub-element of a map element.parseListElement(Element collectionEle, @Nullable BeanDefinition bd) Parse a list element.voidparseLookupOverrideSubElements(Element beanEle, MethodOverrides overrides) Parse lookup-override sub-elements of the given bean element.parseMapElement(Element mapEle, @Nullable BeanDefinition bd) Parse a map element.booleanparseMergeAttribute(Element collectionElement) Parse the merge attribute of a collection element, if any.voidparseMetaElements(Element ele, BeanMetadataAttributeAccessor attributeAccessor) Parse the meta elements underneath the given element, if any.voidparsePropertyElement(Element ele, BeanDefinition bd) Parse a property element.voidparsePropertyElements(Element beanEle, BeanDefinition bd) Parse property sub-elements of the given bean element.Parse a value, ref or collection sub-element of a property or constructor-arg element.parsePropertySubElement(Element ele, @Nullable BeanDefinition bd, @Nullable String defaultValueType) Parse a value, ref or collection sub-element of a property or constructor-arg element.parsePropertyValue(Element ele, BeanDefinition bd, @Nullable String propertyName) Get the value of a property element.parsePropsElement(Element propsEle) Parse a props element.voidParse a qualifier element.voidparseQualifierElements(Element beanEle, AbstractBeanDefinition bd) Parse qualifier sub-elements of the given bean element.voidparseReplacedMethodSubElements(Element beanEle, MethodOverrides overrides) Parse replaced-method sub-elements of the given bean element.parseSetElement(Element collectionEle, @Nullable BeanDefinition bd) Parse a set element.parseValueElement(Element ele, @Nullable String defaultTypeName) Return a typed String value Object for the given value element.protected voidpopulateDefaults(DocumentDefaultsDefinition defaults, @Nullable DocumentDefaultsDefinition parentDefaults, Element root) Populate the given DocumentDefaultsDefinition instance with the default lazy-init, autowire, dependency check settings, init-method, destroy-method and merge settings.
-
Field Details
-
BEANS_NAMESPACE_URI
- See Also:
-
MULTI_VALUE_ATTRIBUTE_DELIMITERS
- See Also:
-
TRUE_VALUE
Value of a T/F attribute that represents true. Anything else represents false.- See Also:
-
FALSE_VALUE
- See Also:
-
DEFAULT_VALUE
- See Also:
-
DESCRIPTION_ELEMENT
- See Also:
-
AUTOWIRE_NO_VALUE
- See Also:
-
AUTOWIRE_BY_NAME_VALUE
- See Also:
-
AUTOWIRE_BY_TYPE_VALUE
- See Also:
-
AUTOWIRE_CONSTRUCTOR_VALUE
- See Also:
-
AUTOWIRE_AUTODETECT_VALUE
- See Also:
-
NAME_ATTRIBUTE
- See Also:
-
BEAN_ELEMENT
- See Also:
-
META_ELEMENT
- See Also:
-
ID_ATTRIBUTE
- See Also:
-
PARENT_ATTRIBUTE
- See Also:
-
CLASS_ATTRIBUTE
- See Also:
-
ABSTRACT_ATTRIBUTE
- See Also:
-
SCOPE_ATTRIBUTE
- See Also:
-
LAZY_INIT_ATTRIBUTE
- See Also:
-
AUTOWIRE_ATTRIBUTE
- See Also:
-
AUTOWIRE_CANDIDATE_ATTRIBUTE
- See Also:
-
PRIMARY_ATTRIBUTE
- See Also:
-
DEPENDS_ON_ATTRIBUTE
- See Also:
-
INIT_METHOD_ATTRIBUTE
- See Also:
-
DESTROY_METHOD_ATTRIBUTE
- See Also:
-
FACTORY_METHOD_ATTRIBUTE
- See Also:
-
FACTORY_BEAN_ATTRIBUTE
- See Also:
-
CONSTRUCTOR_ARG_ELEMENT
- See Also:
-
INDEX_ATTRIBUTE
- See Also:
-
TYPE_ATTRIBUTE
- See Also:
-
VALUE_TYPE_ATTRIBUTE
- See Also:
-
KEY_TYPE_ATTRIBUTE
- See Also:
-
PROPERTY_ELEMENT
- See Also:
-
REF_ATTRIBUTE
- See Also:
-
VALUE_ATTRIBUTE
- See Also:
-
LOOKUP_METHOD_ELEMENT
- See Also:
-
REPLACED_METHOD_ELEMENT
- See Also:
-
REPLACER_ATTRIBUTE
- See Also:
-
ARG_TYPE_ELEMENT
- See Also:
-
ARG_TYPE_MATCH_ATTRIBUTE
- See Also:
-
REF_ELEMENT
- See Also:
-
IDREF_ELEMENT
- See Also:
-
BEAN_REF_ATTRIBUTE
- See Also:
-
PARENT_REF_ATTRIBUTE
- See Also:
-
VALUE_ELEMENT
- See Also:
-
NULL_ELEMENT
- See Also:
-
ARRAY_ELEMENT
- See Also:
-
LIST_ELEMENT
- See Also:
-
SET_ELEMENT
- See Also:
-
MAP_ELEMENT
- See Also:
-
ENTRY_ELEMENT
- See Also:
-
KEY_ELEMENT
- See Also:
-
KEY_ATTRIBUTE
- See Also:
-
KEY_REF_ATTRIBUTE
- See Also:
-
VALUE_REF_ATTRIBUTE
- See Also:
-
PROPS_ELEMENT
- See Also:
-
PROP_ELEMENT
- See Also:
-
MERGE_ATTRIBUTE
- See Also:
-
QUALIFIER_ELEMENT
- See Also:
-
QUALIFIER_ATTRIBUTE_ELEMENT
- See Also:
-
DEFAULT_LAZY_INIT_ATTRIBUTE
- See Also:
-
DEFAULT_MERGE_ATTRIBUTE
- See Also:
-
DEFAULT_AUTOWIRE_ATTRIBUTE
- See Also:
-
DEFAULT_AUTOWIRE_CANDIDATES_ATTRIBUTE
- See Also:
-
DEFAULT_INIT_METHOD_ATTRIBUTE
- See Also:
-
DEFAULT_DESTROY_METHOD_ATTRIBUTE
- See Also:
-
logger
protected final org.apache.commons.logging.Log logger
-
-
Constructor Details
-
BeanDefinitionParserDelegate
Create a new BeanDefinitionParserDelegate associated with the suppliedXmlReaderContext.
-
-
Method Details
-
getReaderContext
Get theXmlReaderContextassociated with this helper instance. -
extractSource
Invoke theSourceExtractorto pull the source metadata from the suppliedElement. -
error
-
error
-
error
-
initDefaults
Initialize the default settings assuming anullparent delegate. -
initDefaults
Initialize the default lazy-init, autowire, dependency check settings, init-method, destroy-method and merge settings. Support nested 'beans' element use cases by falling back to the given parent in case the defaults are not explicitly set locally.- See Also:
-
populateDefaults
protected void populateDefaults(DocumentDefaultsDefinition defaults, @Nullable DocumentDefaultsDefinition parentDefaults, Element root) Populate the given DocumentDefaultsDefinition instance with the default lazy-init, autowire, dependency check settings, init-method, destroy-method and merge settings. Support nested 'beans' element use cases by falling back toparentDefaultsin case the defaults are not explicitly set locally.- Parameters:
defaults- the defaults to populateparentDefaults- the parent BeanDefinitionParserDelegate (if any) defaults to fall back toroot- the root element of the current bean definition document (or nested beans element)
-
getDefaults
Return the defaults definition object. -
getBeanDefinitionDefaults
Return the default settings for bean definitions as indicated within the attributes of the top-level<beans/>element. -
getAutowireCandidatePatterns
-
parseBeanDefinitionElement
Parses the supplied<bean>element. May returnnullif there were errors during parse. Errors are reported to theProblemReporter. -
parseBeanDefinitionElement
public @Nullable BeanDefinitionHolder parseBeanDefinitionElement(Element ele, @Nullable BeanDefinition containingBean) Parses the supplied<bean>element. May returnnullif there were errors during parse. Errors are reported to theProblemReporter. -
checkNameUniqueness
-
parseBeanDefinitionElement
public @Nullable AbstractBeanDefinition parseBeanDefinitionElement(Element ele, String beanName, @Nullable BeanDefinition containingBean) Parse the bean definition itself, without regard to name or aliases. May returnnullif problems occurred during the parsing of the bean definition. -
parseBeanDefinitionAttributes
public AbstractBeanDefinition parseBeanDefinitionAttributes(Element ele, String beanName, @Nullable BeanDefinition containingBean, AbstractBeanDefinition bd) Apply the attributes of the given bean element to the given bean * definition.- Parameters:
ele- bean declaration elementbeanName- bean namecontainingBean- containing bean definition- Returns:
- a bean definition initialized according to the bean element attributes
-
createBeanDefinition
protected AbstractBeanDefinition createBeanDefinition(@Nullable String className, @Nullable String parentName) throws ClassNotFoundException Create a bean definition for the given class name and parent name.- Parameters:
className- the name of the bean classparentName- the name of the bean's parent bean- Returns:
- the newly created bean definition
- Throws:
ClassNotFoundException- if bean class resolution was attempted but failed
-
parseMetaElements
Parse the meta elements underneath the given element, if any. -
getAutowireMode
Parse the given autowire attribute value intoAbstractBeanDefinitionautowire constants. -
parseConstructorArgElements
Parse constructor-arg sub-elements of the given bean element. -
parsePropertyElements
Parse property sub-elements of the given bean element. -
parseQualifierElements
Parse qualifier sub-elements of the given bean element. -
parseLookupOverrideSubElements
Parse lookup-override sub-elements of the given bean element. -
parseReplacedMethodSubElements
Parse replaced-method sub-elements of the given bean element. -
parseConstructorArgElement
Parse a constructor-arg element. -
parsePropertyElement
Parse a property element. -
parseQualifierElement
Parse a qualifier element. -
parsePropertyValue
-
parsePropertySubElement
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 yetbd- the current bean definition (if any)
-
parsePropertySubElement
public @Nullable Object parsePropertySubElement(Element ele, @Nullable BeanDefinition bd, @Nullable String defaultValueType) 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 yetbd- the current bean definition (if any)defaultValueType- the default type (class name) for any<value>tag that might be created
-
parseIdRefElement
-
parseValueElement
-
buildTypedStringValue
protected TypedStringValue buildTypedStringValue(String value, @Nullable String targetTypeName) throws ClassNotFoundException Build a typed String value Object for the given raw value.- Throws:
ClassNotFoundException- See Also:
-
parseArrayElement
Parse an array element. -
parseListElement
Parse a list element. -
parseSetElement
Parse a set element. -
parseCollectionElements
protected void parseCollectionElements(NodeList elementNodes, Collection<Object> target, @Nullable BeanDefinition bd, String defaultElementType) -
parseMapElement
-
buildTypedStringValueForMap
-
parseKeyElement
-
parsePropsElement
Parse a props element. -
parseMergeAttribute
Parse the merge attribute of a collection element, if any. -
parseCustomElement
Parse a custom element (outside the default namespace).- Parameters:
ele- the element to parse- Returns:
- the resulting bean definition
-
parseCustomElement
public @Nullable BeanDefinition parseCustomElement(Element ele, @Nullable BeanDefinition containingBd) Parse a custom element (outside the default namespace).- Parameters:
ele- the element to parsecontainingBd- the containing bean definition (if any)- Returns:
- the resulting bean definition
-
decorateBeanDefinitionIfRequired
public BeanDefinitionHolder decorateBeanDefinitionIfRequired(Element ele, BeanDefinitionHolder originalDef) Decorate the given bean definition through a namespace handler, if applicable.- Parameters:
ele- the current elementoriginalDef- the current bean definition- Returns:
- the decorated bean definition
-
decorateBeanDefinitionIfRequired
public BeanDefinitionHolder decorateBeanDefinitionIfRequired(Element ele, BeanDefinitionHolder originalDef, @Nullable BeanDefinition containingBd) Decorate the given bean definition through a namespace handler, if applicable.- Parameters:
ele- the current elementoriginalDef- the current bean definitioncontainingBd- the containing bean definition (if any)- Returns:
- the decorated bean definition
-
decorateIfRequired
public BeanDefinitionHolder decorateIfRequired(Node node, BeanDefinitionHolder originalDef, @Nullable BeanDefinition containingBd) Decorate the given bean definition through a namespace handler, if applicable.- Parameters:
node- the current child nodeoriginalDef- the current bean definitioncontainingBd- the containing bean definition (if any)- Returns:
- the decorated bean definition
-
getNamespaceURI
Get the namespace URI for the supplied node.The default implementation uses
Node.getNamespaceURI(). Subclasses may override the default implementation to provide a different namespace identification mechanism.- Parameters:
node- the node
-
getLocalName
Get the local name for the suppliedNode.The default implementation calls
Node.getLocalName(). Subclasses may override the default implementation to provide a different mechanism for getting the local name.- Parameters:
node- theNode
-
nodeNameEquals
Determine whether the name of the supplied node is equal to the supplied name.The default implementation checks the supplied desired name against both
Node.getNodeName()andNode.getLocalName().Subclasses may override the default implementation to provide a different mechanism for comparing node names.
- Parameters:
node- the node to comparedesiredName- the name to check for
-
isDefaultNamespace
-
isDefaultNamespace
Determine whether the given node indicates the default namespace.
-