public abstract class NamespaceHandlerSupport extends java.lang.Object implements NamespaceHandler
NamespaceHandlers
.
Parsing and decorating of individual <code>Nodes</code> is done via BeanDefinitionParser
and BeanDefinitionDecorator
strategy interfaces, respectively.
Provides the registerBeanDefinitionParser(java.lang.String, org.springframework.beans.factory.xml.BeanDefinitionParser)
and registerBeanDefinitionDecorator(java.lang.String, org.springframework.beans.factory.xml.BeanDefinitionDecorator)
methods for registering a BeanDefinitionParser
or BeanDefinitionDecorator
to handle a specific element.
registerBeanDefinitionParser(String, BeanDefinitionParser)
,
registerBeanDefinitionDecorator(String, BeanDefinitionDecorator)
Modifier and Type | Field and Description |
---|---|
private java.util.Map<java.lang.String,BeanDefinitionDecorator> |
attributeDecorators
Stores the
BeanDefinitionDecorator implementations keyed by the local
name of the <code>Attrs</code> they handle. |
private java.util.Map<java.lang.String,BeanDefinitionDecorator> |
decorators
Stores the
BeanDefinitionDecorator implementations keyed by the
local name of the <code>Elements</code> they handle. |
private java.util.Map<java.lang.String,BeanDefinitionParser> |
parsers
Stores the
BeanDefinitionParser implementations keyed by the
local name of the <code>Elements</code> they handle. |
Constructor and Description |
---|
NamespaceHandlerSupport() |
Modifier and Type | Method and Description |
---|---|
BeanDefinitionHolder |
decorate(org.w3c.dom.Node node,
BeanDefinitionHolder definition,
ParserContext parserContext)
Decorates the supplied <code>Node</code> by delegating to the
BeanDefinitionDecorator that
is registered to handle that <code>Node</code>. |
private BeanDefinitionDecorator |
findDecoratorForNode(org.w3c.dom.Node node,
ParserContext parserContext)
Locates the
BeanDefinitionParser from the register implementations using
the local name of the supplied <code>Node</code>. |
private BeanDefinitionParser |
findParserForElement(org.w3c.dom.Element element,
ParserContext parserContext)
Locates the
BeanDefinitionParser from the register implementations using
the local name of the supplied <code>Element</code>. |
BeanDefinition |
parse(org.w3c.dom.Element element,
ParserContext parserContext)
Parses the supplied <code>Element</code> by delegating to the
BeanDefinitionParser that is
registered for that <code>Element</code>. |
protected void |
registerBeanDefinitionDecorator(java.lang.String elementName,
BeanDefinitionDecorator dec)
Subclasses can call this to register the supplied
BeanDefinitionDecorator to
handle the specified element. |
protected void |
registerBeanDefinitionDecoratorForAttribute(java.lang.String attrName,
BeanDefinitionDecorator dec)
Subclasses can call this to register the supplied
BeanDefinitionDecorator to
handle the specified attribute. |
protected void |
registerBeanDefinitionParser(java.lang.String elementName,
BeanDefinitionParser parser)
Subclasses can call this to register the supplied
BeanDefinitionParser to
handle the specified element. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
init
private final java.util.Map<java.lang.String,BeanDefinitionParser> parsers
BeanDefinitionParser
implementations keyed by the
local name of the <code>Elements</code> they handle.private final java.util.Map<java.lang.String,BeanDefinitionDecorator> decorators
BeanDefinitionDecorator
implementations keyed by the
local name of the <code>Elements</code> they handle.private final java.util.Map<java.lang.String,BeanDefinitionDecorator> attributeDecorators
BeanDefinitionDecorator
implementations keyed by the local
name of the <code>Attrs</code> they handle.public BeanDefinition parse(org.w3c.dom.Element element, ParserContext parserContext)
BeanDefinitionParser
that is
registered for that <code>Element</code>.parse
in interface NamespaceHandler
element
- the element that is to be parsed into one or more BeanDefinitions
parserContext
- the object encapsulating the current state of the parsing processBeanDefinition
(can be null
as explained above)private BeanDefinitionParser findParserForElement(org.w3c.dom.Element element, ParserContext parserContext)
BeanDefinitionParser
from the register implementations using
the local name of the supplied <code>Element</code>.public BeanDefinitionHolder decorate(org.w3c.dom.Node node, BeanDefinitionHolder definition, ParserContext parserContext)
BeanDefinitionDecorator
that
is registered to handle that <code>Node</code>.decorate
in interface NamespaceHandler
node
- the source element or attribute that is to be parseddefinition
- the current bean definitionparserContext
- the object encapsulating the current state of the parsing processnull
value is strictly speaking invalid, but will be leniently
treated like the case where the original bean definition gets returned.private BeanDefinitionDecorator findDecoratorForNode(org.w3c.dom.Node node, ParserContext parserContext)
BeanDefinitionParser
from the register implementations using
the local name of the supplied <code>Node</code>. Supports both <code>Elements</code>
and <code>Attrs</code>.protected final void registerBeanDefinitionParser(java.lang.String elementName, BeanDefinitionParser parser)
BeanDefinitionParser
to
handle the specified element. The element name is the local (non-namespace qualified)
name.protected final void registerBeanDefinitionDecorator(java.lang.String elementName, BeanDefinitionDecorator dec)
BeanDefinitionDecorator
to
handle the specified element. The element name is the local (non-namespace qualified)
name.protected final void registerBeanDefinitionDecoratorForAttribute(java.lang.String attrName, BeanDefinitionDecorator dec)
BeanDefinitionDecorator
to
handle the specified attribute. The attribute name is the local (non-namespace qualified)
name.