解析BeanDefinition之解析子元素meta.

来源:互联网 发布:在淘宝购买网店 编辑:程序博客网 时间:2024/05/16 12:09

// 解析元数据

parseMetaElements(ele, bd);


在开始解析元数据的分析前,我们先回顾下元数据meta属性的使用。

<bean id ="MyTestBean" class ="">

  <meta key="testStr" value= "test" />

</bean>

这段代码并不会体现在MyTestBean的属性当中,而是一个额外的声明,当需要使用里面的信息的时候可以通过BeanDefinition的getAttribute(key)方法进行获取。


parseMethodElements(Element ele, BeanMetadataAttributeAccessor attributeAccessor);

// 获取当前节点的所有子元素,进行遍历。

// 提取meta

if(isCandidateElement(node) && nodeNameEquals(node, META_ELEMENT)) {

NodeList nl = ele.getChildNodes();

 Element metaElement = (Element) node;

 String key = metaElement.getAttribute(KEY_ATTRIBUTE);

 String value = metaElement.getAttribute(VALUE_ATTRIBUTE);

// 使用key、value构造BeanMetadataAttribute

BeanMetadataAttribute attribute = new BeanMetadataAttrabute(key, value);

attribute.setSource(extractSource(metaElement));

// 记录信息

attributeAccessor.addMetadataAttribute(attribute);

}

阅读全文
0 0
原创粉丝点击