spring 源码 窥视二

前几天一直在运行 org.springframework.beans-3.0.4.RELEASE 自带的Test Projects. 运行很失望,因为很多都运行不起来 :oops: 所以在想是粗粗的把源码读一遍呢还是锱铢必较,把每个小点都搞清楚。我选择了后者 :lol:
今天终于小有收获。

成功的运行了 SimplePropertyNamespaceHandlerTests.java
50%明白了spring如何解析spring配置文件的,这50是spring如何验证配置的正确性。
看里面component-config.xml的例子

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:foo="http://www.foo.com/schema/component"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.foo.com/schema/component http://www.foo.com/schema/component/component.xsd">

<foo:component id="bionic-family" name="Bionic-1">
<foo:component name="Mother-1">
<foo:component name="Karate-1"/>
<foo:component name="Sport-1"/>
</foo:component>
<foo:component name="Rock-1"/>
</foo:component>

</beans>

整个过程应该是这样,查看schema中的 "xsi:schemaLocation" 前面是域名,后面是具体文件名。然后PluggableSchemaResolver会根据"META-INF/spring.schemas"里面的值。通过前面的文件名对应properties的值找到具体本地的xsd文件,然后进行resolve

通过这三个类
PluggableSchemaResolver 继承 EntityResolver 通过一个properties文件把url映射为本地文件
DelegatingEntityResolver 继承 EntityResolver
ResourceEntityResolver 继承 DelegatingEntityResolver
原来是有一个xsd文件,(恕我小白,一直被蒙在鼓里)。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值