Top Description Fields Constructors Methods
org.springframework.beans.factory.xml

public abstract Class AbstractSingleBeanDefinitionParser

extends AbstractBeanDefinitionParser
Class Inheritance
Known Direct Subclasses
org.springframework.beans.factory.xml.UtilNamespaceHandler.PropertyPathBeanDefinitionParser, org.springframework.beans.factory.xml.UtilNamespaceHandler.ListBeanDefinitionParser, org.springframework.beans.factory.xml.UtilNamespaceHandler.SetBeanDefinitionParser, org.springframework.beans.factory.xml.UtilNamespaceHandler.MapBeanDefinitionParser, org.springframework.beans.factory.xml.UtilNamespaceHandler.PropertiesBeanDefinitionParser, org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser
Imports
org.w3c.dom.Element, org.springframework.beans.factory.config.BeanDefinition, org.springframework.beans.factory.support.AbstractBeanDefinition, .BeanDefinitionBuilder, org.springframework.lang.Nullable

Base class for those BeanDefinitionParser implementations that need to parse and define just a single BeanDefinition.

Extend this parser class when you want to create a single bean definition from an arbitrarily complex XML element. You may wish to consider extending the AbstractSimpleBeanDefinitionParser when you want to create a single bean definition from a relatively simple custom XML element.

The resulting BeanDefinition will be automatically registered with the org.springframework.beans.factory.support.BeanDefinitionRegistry. Your job simply is to parse the custom XML Element into a single BeanDefinition.

Authors
Rob Harrop, Juergen Hoeller, Rick Evans
Since
2.0
See Also
getBeanClass, getBeanClassName, doParse

Field Summary

Inherited from org.springframework.beans.factory.xml.AbstractBeanDefinitionParser:
ID_ATTRIBUTENAME_ATTRIBUTE

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
doParse(Element
the XML element being parsed
element
,
ParserContext
the object encapsulating the current state of the parsing process
parserContext
,
BeanDefinitionBuilder
used to define the BeanDefinition
builder
)

Parse the supplied Element and populate the supplied BeanDefinitionBuilder as required.

protected void
doParse(Element
the XML element being parsed
element
,
BeanDefinitionBuilder
used to define the BeanDefinition
builder
)

Parse the supplied Element and populate the supplied BeanDefinitionBuilder as required.

protected Class<?>

Returns:

the Class of the bean that is being defined via parsing the supplied Element, or null if none
getBeanClass
(Element
the Element that is being parsed
element
)

Determine the bean class corresponding to the supplied Element.

protected String

Returns:

the class name of the bean that is being defined via parsing the supplied Element, or null if none
getBeanClassName
(Element
the Element that is being parsed
element
)

Determine the bean class name corresponding to the supplied Element.

protected String

Returns:

the name of the parent bean for the currently parsed bean, or null if none
getParentName
(Element
the Element that is being parsed
element
)

Determine the name for the parent of the currently parsed bean, in case of the current bean being defined as a child bean.

protected final AbstractBeanDefinition

Returns:

the BeanDefinition resulting from the parsing of the supplied Element
parseInternal
(Element
the element that is to be parsed into a single BeanDefinition
element
,
ParserContext
the object encapsulating the current state of the parsing process
parserContext
)

Implements abstract org.springframework.beans.factory.xml.AbstractBeanDefinitionParser.parseInternal.

Creates a BeanDefinitionBuilder instance for the bean Class and passes it to the doParse strategy method.

Inherited from org.springframework.beans.factory.xml.AbstractBeanDefinitionParser:
parsepostProcessComponentDefinitionregisterBeanDefinitionresolveIdshouldFireEventsshouldGenerateIdshouldGenerateIdAsFallbackshouldParseNameAsAliases

Constructor Detail

AbstractSingleBeanDefinitionParserback to summary
public AbstractSingleBeanDefinitionParser()

Method Detail

doParseback to summary
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder)

Parse the supplied Element and populate the supplied BeanDefinitionBuilder as required.

The default implementation delegates to the doParse version without ParserContext argument.

Parameters
element:Element

the XML element being parsed

parserContext:ParserContext

the object encapsulating the current state of the parsing process

builder:BeanDefinitionBuilder

used to define the BeanDefinition

See Also
doParse(Element, BeanDefinitionBuilder)
doParseback to summary
protected void doParse(Element element, BeanDefinitionBuilder builder)

Parse the supplied Element and populate the supplied BeanDefinitionBuilder as required.

The default implementation does nothing.

Parameters
element:Element

the XML element being parsed

builder:BeanDefinitionBuilder

used to define the BeanDefinition

getBeanClassback to summary
protected Class<?> getBeanClass(Element element)

Determine the bean class corresponding to the supplied Element.

Note that, for application classes, it is generally preferable to override getBeanClassName instead, in order to avoid a direct dependence on the bean implementation class. The BeanDefinitionParser and its NamespaceHandler can be used within an IDE plugin then, even if the application classes are not available on the plugin's classpath.

Parameters
element:Element

the Element that is being parsed

Returns:Class<?>

the Class of the bean that is being defined via parsing the supplied Element, or null if none

Annotations
@Nullable
See Also
getBeanClassName
getBeanClassNameback to summary
protected String getBeanClassName(Element element)

Determine the bean class name corresponding to the supplied Element.

Parameters
element:Element

the Element that is being parsed

Returns:String

the class name of the bean that is being defined via parsing the supplied Element, or null if none

Annotations
@Nullable
See Also
getBeanClass
getParentNameback to summary
protected String getParentName(Element element)

Determine the name for the parent of the currently parsed bean, in case of the current bean being defined as a child bean.

The default implementation returns null, indicating a root bean definition.

Parameters
element:Element

the Element that is being parsed

Returns:String

the name of the parent bean for the currently parsed bean, or null if none

Annotations
@Nullable
parseInternalback to summary
protected final AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext)

Implements abstract org.springframework.beans.factory.xml.AbstractBeanDefinitionParser.parseInternal.

Creates a BeanDefinitionBuilder instance for the bean Class and passes it to the doParse strategy method.

Parameters
element:Element

the element that is to be parsed into a single BeanDefinition

parserContext:ParserContext

the object encapsulating the current state of the parsing process

Returns:AbstractBeanDefinition

the BeanDefinition resulting from the parsing of the supplied Element

Annotations
@Override
Exceptions
IllegalStateException:
if the bean Class returned from getBeanClass(org.w3c.dom.Element) is null
See Also
doParse