Class NamespaceHandlerSupport
- java.lang.Object
- org.springframework.beans.factory.xml.NamespaceHandlerSupport
- All Implemented Interfaces:
NamespaceHandler
- Direct Known Subclasses:
AopNamespaceHandler,CacheNamespaceHandler,ContextNamespaceHandler,JdbcNamespaceHandler,JeeNamespaceHandler,JmsNamespaceHandler,LangNamespaceHandler,MvcNamespaceHandler,OxmNamespaceHandler,TaskNamespaceHandler,TxNamespaceHandler,UtilNamespaceHandler,WebSocketNamespaceHandler
public abstract class NamespaceHandlerSupport extends Object implements NamespaceHandler
Support class for implementing customNamespaceHandlers. Parsing and decorating of individualNodesis done viaBeanDefinitionParserandBeanDefinitionDecoratorstrategy interfaces, respectively.Provides the
registerBeanDefinitionParser(java.lang.String, org.springframework.beans.factory.xml.BeanDefinitionParser)andregisterBeanDefinitionDecorator(java.lang.String, org.springframework.beans.factory.xml.BeanDefinitionDecorator)methods for registering aBeanDefinitionParserorBeanDefinitionDecoratorto handle a specific element.- Since:
- 2.0
- Author:
- Rob Harrop, Juergen Hoeller
- See Also:
registerBeanDefinitionParser(String, BeanDefinitionParser),registerBeanDefinitionDecorator(String, BeanDefinitionDecorator)
Constructor Summary
Constructors Constructor Description NamespaceHandlerSupport()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BeanDefinitionHolderdecorate(Node node, BeanDefinitionHolder definition, ParserContext parserContext)Decorates the suppliedNodeby delegating to theBeanDefinitionDecoratorthat is registered to handle thatNode.BeanDefinitionparse(Element element, ParserContext parserContext)Parses the suppliedElementby delegating to theBeanDefinitionParserthat is registered for thatElement.protected voidregisterBeanDefinitionDecorator(String elementName, BeanDefinitionDecorator dec)Subclasses can call this to register the suppliedBeanDefinitionDecoratorto handle the specified element.protected voidregisterBeanDefinitionDecoratorForAttribute(String attrName, BeanDefinitionDecorator dec)Subclasses can call this to register the suppliedBeanDefinitionDecoratorto handle the specified attribute.protected voidregisterBeanDefinitionParser(String elementName, BeanDefinitionParser parser)Subclasses can call this to register the suppliedBeanDefinitionParserto handle the specified element.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.beans.factory.xml.NamespaceHandler
init
Constructor Detail
NamespaceHandlerSupport
public NamespaceHandlerSupport()
Method Detail
parse
public BeanDefinition parse(Element element, ParserContext parserContext)
Parses the suppliedElementby delegating to theBeanDefinitionParserthat is registered for thatElement.- Specified by:
parsein interfaceNamespaceHandler- Parameters:
element- the element that is to be parsed into one or moreBeanDefinitionsparserContext- the object encapsulating the current state of the parsing process- Returns:
- the primary
BeanDefinition(can benullas explained above)
decorate
public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definition, ParserContext parserContext)
Decorates the suppliedNodeby delegating to theBeanDefinitionDecoratorthat is registered to handle thatNode.- Specified by:
decoratein interfaceNamespaceHandler- Parameters:
node- the source element or attribute that is to be parseddefinition- the current bean definitionparserContext- the object encapsulating the current state of the parsing process- Returns:
- the decorated definition (to be registered in the BeanFactory), or simply the original bean definition if no decoration is required. A
nullvalue is strictly speaking invalid, but will be leniently treated like the case where the original bean definition gets returned.
registerBeanDefinitionParser
protected final void registerBeanDefinitionParser(String elementName, BeanDefinitionParser parser)
Subclasses can call this to register the suppliedBeanDefinitionParserto handle the specified element. The element name is the local (non-namespace qualified) name.
registerBeanDefinitionDecorator
protected final void registerBeanDefinitionDecorator(String elementName, BeanDefinitionDecorator dec)
Subclasses can call this to register the suppliedBeanDefinitionDecoratorto handle the specified element. The element name is the local (non-namespace qualified) name.
registerBeanDefinitionDecoratorForAttribute
protected final void registerBeanDefinitionDecoratorForAttribute(String attrName, BeanDefinitionDecorator dec)
Subclasses can call this to register the suppliedBeanDefinitionDecoratorto handle the specified attribute. The attribute name is the local (non-namespace qualified) name.