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

public abstract Class NamespaceHandlerSupport

extends Object
implements NamespaceHandler
Class Inheritance
All Implemented Interfaces
org.springframework.beans.factory.xml.NamespaceHandler
Known Direct Subclasses
org.springframework.beans.factory.xml.UtilNamespaceHandler
Imports
java.util.HashMap, .Map, org.w3c.dom.Attr, .Element, .Node, org.springframework.beans.factory.config.BeanDefinition, .BeanDefinitionHolder, org.springframework.lang.Nullable

Support class for implementing custom NamespaceHandlers. Parsing and decorating of individual Nodes is done via BeanDefinitionParser and BeanDefinitionDecorator strategy interfaces, respectively.

Provides the registerBeanDefinitionParser and registerBeanDefinitionDecorator methods for registering a BeanDefinitionParser or BeanDefinitionDecorator to handle a specific element.

Authors
Rob Harrop, Juergen Hoeller
Since
2.0
See Also
registerBeanDefinitionParser(String, BeanDefinitionParser), registerBeanDefinitionDecorator(String, BeanDefinitionDecorator)

Field Summary

Modifier and TypeField and Description
private final Map<String, BeanDefinitionDecorator>
attributeDecorators

Stores the BeanDefinitionDecorator implementations keyed by the local name of the Attrs they handle.

private final Map<String, BeanDefinitionDecorator>
decorators

Stores the BeanDefinitionDecorator implementations keyed by the local name of the Elements they handle.

private final Map<String, BeanDefinitionParser>
parsers

Stores the BeanDefinitionParser implementations keyed by the local name of the Elements they handle.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public BeanDefinitionHolder
decorate(Node
the source element or attribute that is to be parsed
node
,
BeanDefinitionHolder
the current bean definition
definition
,
ParserContext
the object encapsulating the current state of the parsing process
parserContext
)

Implements org.springframework.beans.factory.xml.NamespaceHandler.decorate.

Decorates the supplied Node by delegating to the BeanDefinitionDecorator that is registered to handle that Node.
private BeanDefinitionDecorator
findDecoratorForNode(Node node, ParserContext parserContext)

Locates the BeanDefinitionParser from the register implementations using the local name of the supplied Node.

private BeanDefinitionParser
findParserForElement(Element element, ParserContext parserContext)

Locates the BeanDefinitionParser from the register implementations using the local name of the supplied Element.

public BeanDefinition
parse(Element
the element that is to be parsed into one or more BeanDefinitions
element
,
ParserContext
the object encapsulating the current state of the parsing process
parserContext
)

Implements org.springframework.beans.factory.xml.NamespaceHandler.parse.

Parses the supplied Element by delegating to the BeanDefinitionParser that is registered for that Element.
protected final void
registerBeanDefinitionDecorator(String elementName, BeanDefinitionDecorator dec)

Subclasses can call this to register the supplied BeanDefinitionDecorator to handle the specified element.

protected final void
registerBeanDefinitionDecoratorForAttribute(String attrName, BeanDefinitionDecorator dec)

Subclasses can call this to register the supplied BeanDefinitionDecorator to handle the specified attribute.

protected final void
registerBeanDefinitionParser(String elementName, BeanDefinitionParser parser)

Subclasses can call this to register the supplied BeanDefinitionParser to handle the specified element.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

attributeDecoratorsback to summary
private final Map<String, BeanDefinitionDecorator> attributeDecorators

Stores the BeanDefinitionDecorator implementations keyed by the local name of the Attrs they handle.

decoratorsback to summary
private final Map<String, BeanDefinitionDecorator> decorators

Stores the BeanDefinitionDecorator implementations keyed by the local name of the Elements they handle.

parsersback to summary
private final Map<String, BeanDefinitionParser> parsers

Stores the BeanDefinitionParser implementations keyed by the local name of the Elements they handle.

Constructor Detail

NamespaceHandlerSupportback to summary
public NamespaceHandlerSupport()

Method Detail

decorateback to summary
public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definition, ParserContext parserContext)

Implements org.springframework.beans.factory.xml.NamespaceHandler.decorate.

Decorates the supplied Node by delegating to the BeanDefinitionDecorator that is registered to handle that Node.

Parameters
node:Node

Doc from org.springframework.beans.factory.xml.NamespaceHandler.decorate.

the source element or attribute that is to be parsed

definition:BeanDefinitionHolder

Doc from org.springframework.beans.factory.xml.NamespaceHandler.decorate.

the current bean definition

parserContext:ParserContext

Doc from org.springframework.beans.factory.xml.NamespaceHandler.decorate.

the object encapsulating the current state of the parsing process

Returns:BeanDefinitionHolder

Doc from org.springframework.beans.factory.xml.NamespaceHandler.decorate.

the decorated definition (to be registered in the BeanFactory), or simply the original bean definition if no decoration is required. A null value is strictly speaking invalid, but will be leniently treated like the case where the original bean definition gets returned.

Annotations
@Override
@Nullable
findDecoratorForNodeback to summary
private BeanDefinitionDecorator findDecoratorForNode(Node node, ParserContext parserContext)

Locates the BeanDefinitionParser from the register implementations using the local name of the supplied Node. Supports both Elements and Attrs.

Annotations
@Nullable
findParserForElementback to summary
private BeanDefinitionParser findParserForElement(Element element, ParserContext parserContext)

Locates the BeanDefinitionParser from the register implementations using the local name of the supplied Element.

Annotations
@Nullable
parseback to summary
public BeanDefinition parse(Element element, ParserContext parserContext)

Implements org.springframework.beans.factory.xml.NamespaceHandler.parse.

Parses the supplied Element by delegating to the BeanDefinitionParser that is registered for that Element.

Parameters
element:Element

Doc from org.springframework.beans.factory.xml.NamespaceHandler.parse.

the element that is to be parsed into one or more BeanDefinitions

parserContext:ParserContext

Doc from org.springframework.beans.factory.xml.NamespaceHandler.parse.

the object encapsulating the current state of the parsing process

Returns:BeanDefinition

Doc from org.springframework.beans.factory.xml.NamespaceHandler.parse.

the primary BeanDefinition (can be null as explained above)

Annotations
@Override
@Nullable
registerBeanDefinitionDecoratorback to summary
protected final void registerBeanDefinitionDecorator(String elementName, BeanDefinitionDecorator dec)

Subclasses can call this to register the supplied BeanDefinitionDecorator to handle the specified element. The element name is the local (non-namespace qualified) name.

registerBeanDefinitionDecoratorForAttributeback to summary
protected final void registerBeanDefinitionDecoratorForAttribute(String attrName, BeanDefinitionDecorator dec)

Subclasses can call this to register the supplied BeanDefinitionDecorator to handle the specified attribute. The attribute name is the local (non-namespace qualified) name.

registerBeanDefinitionParserback to summary
protected final void registerBeanDefinitionParser(String elementName, BeanDefinitionParser parser)

Subclasses can call this to register the supplied BeanDefinitionParser to handle the specified element. The element name is the local (non-namespace qualified) name.