Talking about the triggering process of Spring's BeanDefinitionParser

First of all, you need to understand the implementation of Spring's custom tags. Register the parser by inheriting NamespaceHandlerSupport. The following briefly talks about the triggering process.

In the refresh method of ApplicationContext



The first is to initialize and create beanFactory through obtainFreshBeanFactory, which will read xml for parsing


refreshBeanFactory is the right thing to do. .


Get beanDefinitionReader ready to start parsing


The loadBeanDefinitions here will go round and round, and the loadBeanDefinitions of XmlBeanDefinitionReader will be called in the end.


Do the right thing as always




Here we will first get the root from the document and then start parsing




This will determine whether it is a default label such as a bean. . If it is enhanced or customized, go to parseCustomElement


Here we will get the url and decide which NamespaceHandler it is, and then call his parse method, for example: mvc that is MVCNamespaceHandler


Get the corresponding parserForElement and then call parse, for example: interceptors so the corresponding parse is naturally InterceptorsBeanDefinitionParser


end

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325926920&siteId=291194637