The Spring Framework

org.springframework.beans.factory.xml
Class SimplePropertyNamespaceHandler

java.lang.Object
  extended by org.springframework.beans.factory.xml.SimplePropertyNamespaceHandler
All Implemented Interfaces:
NamespaceHandler

public class SimplePropertyNamespaceHandler
extends Object
implements NamespaceHandler

Simple NamespaceHandler implementation that maps custom attributes directly through to bean properties. An important point to note is that this NamespaceHandler does not have a corresponding schema since there is no way to know in advance all possible attribute names.

An example of the usage of this NamespaceHandler is shown below:

 <bean id="rob" class="..TestBean" p:name="Rob Harrop" p:spouse-ref="sally"/>
 
Here the 'p:name' corresponds directly to the 'name' property on class 'TestBean'. The 'p:spouse-ref' attributes corresponds to the 'spouse' property and rather than being the concrete value it conatins the name of the bean that will be injected into that property.

Since:
2.0
Author:
Rob Harrop

Constructor Summary
SimplePropertyNamespaceHandler()
           
 
Method Summary
 BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definition, ParserContext parserContext)
          Parse the specified Node and decorate the supplied BeanDefinition, returning the decorated definition.
 void init()
          Invoked by the DefaultBeanDefinitionDocumentReader after construction but before any custom elements are parsed.
 BeanDefinition parse(Element element, ParserContext parserContext)
          Parse the specified Element and register resulting BeanDefinitions with the BeanDefinitionRegistry embedded in the supplied ParserContext.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimplePropertyNamespaceHandler

public SimplePropertyNamespaceHandler()
Method Detail

init

public void init()
Description copied from interface: NamespaceHandler
Invoked by the DefaultBeanDefinitionDocumentReader after construction but before any custom elements are parsed.

Specified by:
init in interface NamespaceHandler

parse

public BeanDefinition parse(Element element,
                            ParserContext parserContext)
Description copied from interface: NamespaceHandler
Parse the specified Element and register resulting BeanDefinitions with the BeanDefinitionRegistry embedded in the supplied ParserContext.

Implementations should return the primary BeanDefinition that results from the parse phase if they which to be used nested inside <property> tag. Implementations may return null if they will not be used in a nested scenario.

Specified by:
parse in interface NamespaceHandler
Returns:
the primary BeanDefinition

decorate

public BeanDefinitionHolder decorate(Node node,
                                     BeanDefinitionHolder definition,
                                     ParserContext parserContext)
Description copied from interface: NamespaceHandler
Parse the specified Node and decorate the supplied BeanDefinition, returning the decorated definition. The Node may be either an Attr or an Element.

Implementations may choose to return a completely new definition, which will replace the original definition in the resulting BeanFactory.

The supplied ParserContext can be used to register any additional beans needed to support the main definition.

Specified by:
decorate in interface NamespaceHandler

The Spring Framework

Copyright © 2002-2006 The Spring Framework.