Logo



dubbo2.7.8源码编译(dubbo30 github)

本文目录一览:

dubbo-container源码怎么打包

Dubbo的服务的过程,也需要一个像reference的对象来维护service关联的所有对象及其属性,这里的reference就是provider。由于ServiceBean实现了

InitializingBean接口,所有在Spring实例化这个bean后会调用接口方法afterPropertiesSet:

[java] view plain copy

public void afterPropertiesSet() throws Exception {

//如果没有配置provider

if (getProvider() == null) {

//获取IOC容器里的所有provider

MapString, ProviderConfig providerConfigMap = applicationContext == null ? null : BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, ProviderConfig.class, false, false);

if (providerConfigMap != null providerConfigMap.size() 0) {

MapString, ProtocolConfig protocolConfigMap = applicationContext == null ? null : BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, ProtocolConfig.class, false, false);

if ((protocolConfigMap == null || protocolConfigMap.size() == 0)

providerConfigMap.size() 1) { // 兼容旧版本

ListProviderConfig providerConfigs = new ArrayListProviderConfig();

for (ProviderConfig config : providerConfigMap.values()) {

if (config.isDefault() != null config.isDefault().booleanValue()) {

providerConfigs.add(config);

//关联所有providers

if (providerConfigs.size() 0) {

setProviders(providerConfigs);

} else {

ProviderConfig providerConfig = null;

for (ProviderConfig config : providerConfigMap.values()) {

if (config.isDefault() == null || config.isDefault().booleanValue()) {

if (providerConfig != null) {

throw new IllegalStateException("Duplicate provider configs: " + providerConfig + " and " + config);

providerConfig = config;

if (providerConfig != null) {

setProvider(providerConfig);

//如果没有配置application,且没有配置provider

if (getApplication() == null

(getProvider() == null || getProvider().getApplication() == null)) {

//获取所有applications

MapString, ApplicationConfig applicationConfigMap = applicationContext == null ? null : BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, ApplicationConfig.class, false, false);

if (applicationConfigMap != null applicationConfigMap.size() 0) {

ApplicationConfig applicationConfig = null;

for (ApplicationConfig config : applicationConfigMap.values()) {

if (config.isDefault() == null || config.isDefault().booleanValue()) {

if (applicationConfig != null) {

throw new IllegalStateException("Duplicate application configs: " + applicationConfig + " and " + config);

applicationConfig = config;

//关联application

if (applicationConfig != null) {

setApplication(applicationConfig);

//如果没有配置module,且没有配置provider

if (getModule() == null

(getProvider() == null || getProvider().getModule() == null)) {

MapString, ModuleConfig moduleConfigMap = applicationContext == null ? null : BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, ModuleConfig.class, false, false);

if (moduleConfigMap != null moduleConfigMap.size() 0) {

ModuleConfig moduleConfig = null;

for (ModuleConfig config : moduleConfigMap.values()) {

if (config.isDefault() == null || config.isDefault().booleanValue()) {

if (moduleConfig != null) {

throw new IllegalStateException("Duplicate module configs: " + moduleConfig + " and " + config);

moduleConfig = config;

//关联module

if (moduleConfig != null) {

setModule(moduleConfig);

//如果没有配置registries,且没有配置provider

if ((getRegistries() == null || getRegistries().size() == 0)

(getProvider() == null || getProvider().getRegistries() == null || getProvider().getRegistries().size() == 0)

(getApplication() == null || getApplication().getRegistries() == null || getApplication().getRegistries().size() == 0)) {

MapString, RegistryConfig registryConfigMap = applicationContext == null ? null : BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, RegistryConfig.class, false, false);

if (registryConfigMap != null registryConfigMap.size() 0) {

ListRegistryConfig registryConfigs = new ArrayListRegistryConfig();

for (RegistryConfig config : registryConfigMap.values()) {

if (config.isDefault() == null || config.isDefault().booleanValue()) {

registryConfigs.add(config);

//关联registries

if (registryConfigs != null registryConfigs.size() 0) {

super.setRegistries(registryConfigs);

//如果没有配置monitor,且没有配置provider

if (getMonitor() == null

(getProvider() == null || getProvider().getMonitor() == null)

(getApplication() == null || getApplication().getMonitor() == null)) {

MapString, MonitorConfig monitorConfigMap = applicationContext == null ? null : BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, MonitorConfig.class, false, false);

if (monitorConfigMap != null monitorConfigMap.size() 0) {

MonitorConfig monitorConfig = null;

for (MonitorConfig config : monitorConfigMap.values()) {

if (config.isDefault() == null || config.isDefault().booleanValue()) {

if (monitorConfig != null) {

throw new IllegalStateException("Duplicate monitor configs: " + monitorConfig + " and " + config);

monitorConfig = config;

//关联monitor

if (monitorConfig != null) {

setMonitor(monitorConfig);

//如果没有配置protocol,且没有配置provider

if ((getProtocols() == null || getProtocols().size() == 0)

(getProvider() == null || getProvider().getProtocols() == null || getProvider().getProtocols().size() == 0)) {

MapString, ProtocolConfig protocolConfigMap = applicationContext == null ? null : BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, ProtocolConfig.class, false, false);

if (protocolConfigMap != null protocolConfigMap.size() 0) {

ListProtocolConfig protocolConfigs = new ArrayListProtocolConfig();

for (ProtocolConfig config : protocolConfigMap.values()) {

if (config.isDefault() == null || config.isDefault().booleanValue()) {

protocolConfigs.add(config);

//关联protocol

if (protocolConfigs != null protocolConfigs.size() 0) {

super.setProtocols(protocolConfigs);

//如果没有配置path

if (getPath() == null || getPath().length() == 0) {

if (beanName != null beanName.length() 0

getInterface() != null getInterface().length() 0

beanName.startsWith(getInterface())) {

setPath(beanName);

//暴露provider

if (! isDelay()) {

export();

我从github上下载了dubbo的最新的源代码,可是import到myeclipse中有错误,找不到dubbo的jar包

这是个maven管理的吧,导入要用maven的方式去倒入,会互相依赖的。

dubbo java环境下出现这种错误怎么解决?

往service里注入失败了。

改成:ref="CarServiceImpl"

Dubbo分布式服务框架 服务注册不上:

(1) 检查dubbo的jar包有没有在classpath中,以及有没有重复的jar包

(2) 检查有没有重复的dubbo.properties配置文件

(3) 检查暴露服务的spring配置有没有加载

(4) 检查beanId或beanName有没有重复

(5) 查看有没有错误日志:

cat ~/output/logs/webx.log

(6) 在服务提供者机器上测试与注册中心的网络是否通:

telnet 172.22.3.94 9090

(7) 检查与注册中心的连接是否存在:

netstat -anp | grep 172.22.3.94

(8) 如果是预发布机,检查hosts文件有没有正确绑定:

cat /etc/hosts

(9) 实在不行,开启远程调试:

– (a) 在服务器JVM参数中加入:-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=7001,server=y,suspend=y

注意线上只有7001和8080可以被线下访问,调试端口需用这两个之一,因注册是启动时行为,启动时必需挂起suspend=y

– (b) 在dubbo源码的DefaultRegistryService的registerService()方法中设置断点。

– (c) 在Eclipse的Debug按钮下拉菜单Debug Configurations中的Remote Java Applications中新增远程调试,并设置IP和端口,以及增加dubbo的源码,进行远程Debug调试。

  dubbo2.7.8源码编译 


评论


最新评论