类 SimplePropertyNamespaceHandler
- java.lang.Object
- org.springframework.beans.factory.xml.SimplePropertyNamespaceHandler
- 所有已实现的接口:
NamespaceHandler
public class SimplePropertyNamespaceHandler extends Object implements NamespaceHandler
SimpleNamespaceHandlerimplementation that maps custom attributes directly through to bean properties. An important point to note is that thisNamespaceHandlerdoes 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
NamespaceHandleris 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 contains the name of the bean that will be injected into that property.- 从以下版本开始:
- 2.0
- 作者:
- Rob Harrop, Juergen Hoeller
构造器概要
构造器 构造器 说明 SimplePropertyNamespaceHandler()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 BeanDefinitionHolderdecorate(Node node, BeanDefinitionHolder definition, ParserContext parserContext)Parse the specifiedNodeand decorate the suppliedBeanDefinitionHolder, returning the decorated definition.voidinit()Invoked by theDefaultBeanDefinitionDocumentReaderafter construction but before any custom elements are parsed.BeanDefinitionparse(Element element, ParserContext parserContext)Parse the specifiedElementand register any resultingBeanDefinitionswith theBeanDefinitionRegistrythat is embedded in the suppliedParserContext.
构造器详细资料
SimplePropertyNamespaceHandler
public SimplePropertyNamespaceHandler()
方法详细资料
init
public void init()
从接口复制的说明:NamespaceHandlerInvoked by theDefaultBeanDefinitionDocumentReaderafter construction but before any custom elements are parsed.
parse
public BeanDefinition parse(Element element, ParserContext parserContext)
从接口复制的说明:NamespaceHandlerParse the specifiedElementand register any resultingBeanDefinitionswith theBeanDefinitionRegistrythat is embedded in the suppliedParserContext.Implementations should return the primary
BeanDefinitionthat results from the parse phase if they wish to be used nested inside (for example) a<property>tag.Implementations may return
nullif they will not be used in a nested scenario.- 指定者:
parse在接口中NamespaceHandler- 参数:
element- the element that is to be parsed into one or moreBeanDefinitionsparserContext- the object encapsulating the current state of the parsing process- 返回:
- the primary
BeanDefinition(can benullas explained above)
decorate
public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definition, ParserContext parserContext)
从接口复制的说明:NamespaceHandlerParse the specifiedNodeand decorate the suppliedBeanDefinitionHolder, returning the decorated definition.The
Nodemay be either anAttror anElement, depending on whether a custom attribute or element is being parsed.Implementations may choose to return a completely new definition, which will replace the original definition in the resulting
BeanFactory.The supplied
ParserContextcan be used to register any additional beans needed to support the main definition.- 指定者:
decorate在接口中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 process- 返回:
- 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.