代码拉取完成,页面将自动刷新
同步操作将从 huifer/Code-Analysis 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
org.springframework.beans.factory.xml.SimplePropertyNamespaceHandler
SimplePropertyNamespaceHandler
的主要作用是给 beanDefinition 的属性映射表添加属性. 主要由decorate
方法进行. 下面开始进行方法分析方法签名: org.springframework.beans.factory.xml.SimplePropertyNamespaceHandler.decorate
方法作用: 补充 BeanDefinition 的 属性映射表信息
执行流程
-ref
放入容器时会对 value进行转换, 即创建RuntimeBeanReference
对象
3. 直接将属性进行设置更多信息请阅读下面代码
@Override
public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definition, ParserContext parserContext) {
// node 是否是 attr
if (node instanceof Attr) {
// 将 attr 转换成 属性名称 属性值
Attr attr = (Attr) node;
// 属性名称
String propertyName = parserContext.getDelegate().getLocalName(attr);
// 属性值
String propertyValue = attr.getValue();
// bean 定义中的属性映射表
MutablePropertyValues pvs = definition.getBeanDefinition().getPropertyValues();
// 如果属性映射吧已经存在当前的 属性名称 抛出异常
if (pvs.contains(propertyName)) {
parserContext.getReaderContext().error("Property '" + propertyName + "' is already defined using " +
"both <property> and inline syntax. Only one approach may be used per property.", attr);
}
// 如果属性名称 结尾是-ref
if (propertyName.endsWith(REF_SUFFIX)) {
// 切分字符串得到 -ref 之前的内容
propertyName = propertyName.substring(0, propertyName.length() - REF_SUFFIX.length());
// 设置属性映射表中
// key: 属性名称
// value: RuntimeBeanReference
pvs.add(Conventions.attributeNameToPropertyName(propertyName), new RuntimeBeanReference(propertyValue));
}
else {
// 直接设置
// key: 属性名称
// value: 属性值
pvs.add(Conventions.attributeNameToPropertyName(propertyName), propertyValue);
}
}
return definition;
}
org.springframework.beans.factory.xml.SimplePropertyNamespaceHandler.init
@Override
public void init() {
}
org.springframework.beans.factory.xml.SimplePropertyNamespaceHandler.parse
@Override
@Nullable
public BeanDefinition parse(Element element, ParserContext parserContext) {
// 直接抛出异常
parserContext.getReaderContext().error(
"Class [" + getClass().getName() + "] does not support custom elements.", element);
return null;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。