dubbo-启动初始化
分析入口
//获取属性过程基本会调用到此方法
org.apache.dubbo.common.config.AbstractPrefixConfiguration#getProperty(String key, Object defaultValue){
getInternalProperty(prefix + key)
}
//初始化与获取配置
org.apache.dubbo.common.utils.ConfigUtils#getProperties
//
org.apache.dubbo.config.spring.context.DubboLifecycleComponentApplicationListener#onApplicationContextEvent
org.apache.dubbo.config.spring.context.DubboBootstrapApplicationListener#onApplicationContextEvent{
//order=LOWEST_PRECEDENCE
>>>DubboBootstrap.getInstance().start()
}
//spring.handlers
//http\://dubbo.apache.org/schema/dubbo=org.apache.dubbo.config.spring.schema.DubboNamespaceHandler
org.apache.dubbo.config.spring.schema.DubboNamespaceHandler
springboot注入dubbo
@EnableDubbo{
@EnableDubboConfig{
@Import(DubboConfigConfigurationRegistrar.class)
}
@DubboComponentScan{
@Import(DubboComponentScanRegistrar.class)
}
@EnableDubboLifecycle{
@Import(DubboLifecycleComponentRegistrar.class)>>{
//注册事件监听 >>>DubboBootstrap.getInstance().start()
registerBeans(registry, DubboLifecycleComponentApplicationListener.class);
registerBeans(registry, DubboBootstrapApplicationListener.class);
}
}
}
注册中心上的注册信息
dubbo://169.254.67.187:20880/com.shareyun.dubbo.demo.DemoService?anyhost=true&application=hello-world-app&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&interface=com.shareyun.dubbo.demo.DemoService&methods=sayHello&pid=10972&release=2.7.5&side=provider×tamp=1583457571139
consumer://169.254.67.187/com.shareyun.dubbo.demo.DemoService?application=hello-world&category=consumers&check=false&dubbo=2.0.2&init=false&interface=com.shareyun.dubbo.demo.DemoService&methods=sayHello&pid=2756&release=2.7.5&side=consumer&sticky=false×tamp=1583457718484
org.apache.dubbo.config.spring.schema.DubboNamespaceHandler#parse
org.apache.dubbo.config.spring.schema.DubboNamespaceHandler#registerApplicationListeners(BeanDefinitionRegistry registry){
registerBeans(registry, DubboLifecycleComponentApplicationListener.class);
registerBeans(registry, DubboBootstrapApplicationListener.class);
}
spring命名空间解释
org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver#resolve(String namespaceUri){
NamespaceHandler namespaceHandler = (NamespaceHandler) BeanUtils.instantiateClass(handlerClass);
namespaceHandler.init();
}
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory#resolveBeforeInstantiation{
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory#applyBeanPostProcessorsBeforeInstantiation
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory#applyBeanPostProcessorsAfterInitialization
}
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory#determineConstructorsFromBeanPostProcessors
org.springframework.beans.factory.support.SimpleInstantiationStrategy#instantiate(org.springframework.beans.factory.support.RootBeanDefinition, java.lang.String, org.springframework.beans.factory.BeanFactory)
//mbd设置初始化方法
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory#applyMergedBeanDefinitionPostProcessors{
for (BeanPostProcessor bp : getBeanPostProcessors()) {
if (bp instanceof MergedBeanDefinitionPostProcessor) {
MergedBeanDefinitionPostProcessor bdp = (MergedBeanDefinitionPostProcessor) bp;
bdp.postProcessMergedBeanDefinition(mbd, beanType, beanName);
//>>>org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor#buildLifecycleMetadata
}
}
}
本站文章除注明转载/出处外,均为本站原创或翻译,转载前请务必署名,转载请标明出处
最后编辑时间为:
2022/12/15 05:36