前几天一直在运行 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文件,(恕我小白,一直被蒙在鼓里)。
今天终于小有收获。
成功的运行了 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文件,(恕我小白,一直被蒙在鼓里)。