Refer to the website :
https://blog.csdn.net/peace_hehe/article/details/79288053
https://blog.csdn.net/aoomiao/article/details/83503223
springboot combination dubbo If you want to expose the service in, you must first parse the provider's xml To configure , as for springboot The project specifies read resolution at startup xml Beyond the scope of this article
stay com.alibaba.dubbo.config.spring.schema.DubboNamespaceHandler The parser is specified in , In the analysis to dubbo Tag, the parser will be called to assemble the configuration of each exposed service into bean object
The specific analytic process method is in , Bring in the tags element In the properties of the ( Such as id、interface、class etc. ) Set to beanDefinition , according to beanClass(ServiceBean) obtain set Method put in beanDefinition Record
com.alibaba.dubbo.config.spring.schema.DubboBeanDefinitionParser#parse()
here beanDefinition The definition of is to record the need to instantiate bean All kinds of information , Equivalent to mold , With a mold, you can instantiate the corresponding bean come out , Back to beanDefinition It's going to end up in spring One beanDefinitionMap<String, BeanDefinition> in , among key by xml Defined id
stay
org.springframework.beans.factory.support.DefaultListableBeanFactory
in , When the container's getBean(beanName) You'll pass beanDefinitionMap obtain BeanDefinition To instantiate bean, Here we will instantiate ServiceBean example , and ServiceBean Class as a listener implements
ApplicationListener<ContextRefreshedEvent> Interface , The trigger event is started in the container to call the execution method of the listener . because ServiceBean Also inherited ServiceConfig, The exposed function of the parent class is called , Save information about the service in a specific object and send it to the registry .