类 AbstractRefreshableApplicationContext
//工厂刷新 obtainFreshBeanFactory>refreshBeanFactory>loadBeanDefinitions
类 AbstractXmlApplicationContext
XmlBeanDefinitionReader从xml读取beandefinition loadBeanDefinitions 加载bean定义
//加载bean定义
public int loadBeanDefinitions(String... locations) throws BeanDefinitionStoreException {
Assert.notNull(locations, "Location array must not be null");
int counter = 0;
for (String location : locations) {
counter += loadBeanDefinitions(location);
}
return counter;
}
BeanDefinitionParserDelegate#bean定义的解析器
//格式化非默认的元素
public BeanDefinition parseCustomElement(Element ele, BeanDefinition containingBd) {
String namespaceUri = getNamespaceURI(ele);
//spring.handler读取该element的解析器
NamespaceHandler handler =
this.readerContext.getNamespaceHandlerResolver().resolve(namespaceUri);
if (handler == null) {
error("Unable to locate Spring NamespaceHandler for XML schema namespace [" + namespaceUri + "]", ele);
return null;
}
return handler.parse(ele, new ParserContext(this.readerContext, this, containingBd));
}
META-INFO下的spring.handler
NamespaceHandlerResolver using mappings {http://www.w3.org/ns/ws-policy=org.apache.cxf.ws.policy.spring.PolicyNamespaceHandler, http://www.springframework