dubbox -- 服务的启动与初始化

 

步骤 调用顺序 备注
容器启动

com.alibaba.dubbo.container.Main.main(args);

dubbo.properties->dubbo.container->container.start()

container->spring, log4j, jetty...

SpringContainer.java->classpath*:META-INF/spring/*.xml->dubbo.xsd

 
bean初始化

等自定义标签->[dubbo-config-spring]

DubboNamespaceHandler.java

->new DubboBeanDefinitionParser(ServiceBean.class,true)

spring对bean的初始化操作

[dubbo-config-spring]ServiceBean.java->afterPropertiesSet()->setProvicer(),

setApplication(), setModule(), setRegistries, etMonitor(), setProtocols, setPath() -> export()

自定义标签

的解析和

初始化

连接注册中心

ServiceBean.export()->ServiceConfig.java->doExportUrlsFor1Protocol()->暴露协议protocol.export()

protocol=ExtensionLoader.getExtensionLoader(Protocol.class)..getAdaptiveExtension()--Protocol$Adaptive.java->ExtensionLoader.loadExtensionClasses()->loadFile()->META-INF/dubbo/internal, META-INF/dubbo/, META-INF/services/

->filter, listener, mock->各类的export()

protocol.export()调用链->RegistryProtocol.export()->getRegistry()->扩展的ZookeeperClient()->

registry.subscribe()加入监听列表

注册到注册中心, 并加入监听列表监听注册中心的消息通知
启动协议服务器 protocol.export()调用链->RestProtocol.export()->doExport()->server.start(), server.deploy 根据相就协议启动相应服务器

 

 

 

 

步骤 调用顺序 备注
容器启动 参考提供方  
bean初始化 等自定义标签->[dubbo-config-spring]
DubboNamespaceHandler.java
->new DubboBeanDefinitionParser(ReferenceBean.class,false)
 
连接注册中心 ReferenceBean.java->afterPropertiesSet()->ReferenceConfig.init()->createProxy()->refProtocol.refer()

refProtocol=ExtensionLoader.getExtensionLoader(Protocol.class).getAdaptiveExtension()
--Protocol$Adaptive.java
->ExtensionLoader.loadExtensionClasses()->loadFile()->META-INF/dubbo/internal/, META-INF/dubbo/, META-INF/services/ ->filter, listener, mock->各类的refer()
 
服务接口初始化 ReferenceConfig.init()->createProxy()->AbstractProxyFactory.getProxy()->JavasistProxyFactory.getProxy()
service接口在实际运行时是com.alibaba.dubbo.common.bytecode.Proxy类的实例
 

 

 

 

 

 

最后欢迎大家访问我的个人网站:1024s

 

 

你可能感兴趣的:(软件架构,秒扒Dubbo)