You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by li...@apache.org on 2018/11/07 02:06:51 UTC

[incubator-dubbo] branch dev-metadata updated (072b51e -> d85550a)

This is an automated email from the ASF dual-hosted git repository.

liujun pushed a change to branch dev-metadata
in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git.


    from 072b51e  Merge pull request #2744, metadata unit test and generic test, refactor zk store.
     new 220c9da  cherry-pick 4d0a36c435ca59bfcf909c0e76fa2ab024fb7408 from master 重构 ServiceBean 的 isDelay 方法,使其更符合语义
     new 22599b9  Make ReferenceBean depend on ConfigCenterBean, so that ConfigCenterBean can always be initialized before refer.
     new d85550a  Merge branch 'dev-metadata' of https://github.com/apache/incubator-dubbo into dev-metadata

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../apache/dubbo/config/ConfigCenterConfig.java    | 37 +++++++++++++++++++++-
 .../dubbo/config/spring/ConfigCenterBean.java      | 35 +++++++++++++++++++-
 .../apache/dubbo/config/spring/ReferenceBean.java  |  4 +++
 .../apache/dubbo/config/spring/ServiceBean.java    | 13 ++------
 4 files changed, 76 insertions(+), 13 deletions(-)


[incubator-dubbo] 03/03: Merge branch 'dev-metadata' of https://github.com/apache/incubator-dubbo into dev-metadata

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch dev-metadata
in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git

commit d85550a5fdba7c75e666e5395454d93a0c82335e
Merge: 22599b9 072b51e
Author: ken.lj <ke...@gmail.com>
AuthorDate: Wed Nov 7 10:05:13 2018 +0800

    Merge branch 'dev-metadata' of https://github.com/apache/incubator-dubbo into dev-metadata

 dubbo-compatible/pom.xml                           |   7 +-
 .../apache/dubbo/generic/GenericServiceTest.java   | 181 ++++++++++++-
 .../org/apache/dubbo/service/ComplexObject.java    | 282 +++++++++++++++++++++
 .../java/org/apache/dubbo/service/DemoService.java |   8 +-
 .../org/apache/dubbo/service/DemoServiceImpl.java  |  15 +-
 .../dubbo/config/AbstractInterfaceConfig.java      |   2 +-
 .../META-INF/spring/dubbo-demo-consumer.xml        |   3 +-
 .../META-INF/spring/dubbo-demo-provider.xml        |   2 +-
 .../definition/builder/CollectionTypeBuilder.java  |   3 +-
 .../definition/model/FullServiceDefinition.java    |   8 +
 .../definition/model/MethodDefinition.java         |  18 ++
 .../definition/model/ServiceDefinition.java        |  16 ++
 .../metadata/definition/model/TypeDefinition.java  |  18 ++
 .../dubbo/metadata/definition/util/ClassUtils.java |   4 +-
 .../definition/ServiceDefinitionBuildderTest.java  |  81 ++++++
 .../common/ResultWithRawCollections.java           |   2 +-
 .../metadata/definition/service/ComplexObject.java | 280 ++++++++++++++++++++
 .../metadata/definition/service/DemoService.java}  |  18 +-
 .../dubbo-metadata-report-api/pom.xml              |   9 +-
 .../identifier/ConsumerMetadataIdentifier.java     |   4 +-
 .../metadata/identifier/MetadataIdentifier.java    |   5 +-
 .../identifier/ProviderMetadataIdentifier.java     |   2 +-
 .../integration/MetadataReportService.java         |   1 +
 .../dubbo/metadata/metadata/MethodDescriptor.java  |  54 ----
 .../dubbo/metadata/metadata/ServiceDescriptor.java |  55 ----
 .../dubbo/metadata/metadata/TypeDescriptor.java    |  65 -----
 .../metadata/builder/ArrayTypeBuilder.java         |  36 ---
 .../metadata/builder/CollectionTypeBuilder.java    |  59 -----
 .../metadata/builder/DefaultTypeBuilder.java       | 113 ---------
 .../metadata/metadata/builder/EnumTypeBuilder.java |  45 ----
 .../metadata/metadata/builder/MapTypeBuilder.java  |  60 -----
 .../metadata/builder/ServiceDescriptorBuilder.java |  71 ------
 .../metadata/metadata/builder/TypeBuilder.java     |  23 --
 .../metadata/builder/TypeDescriptorBuilder.java    |  63 -----
 .../metadata/support/AbstractMetadataReport.java   |  13 +-
 .../metadata/integration/RetryTestService.java     |   2 +-
 .../metadata/builder/ArrayTypeBuilderTest.java     |  89 -------
 .../builder/CollectionTypeBuilderTest.java         |  90 -------
 .../metadata/metadata/builder/ComplexEnum.java     |  16 --
 .../metadata/metadata/builder/ComplexObject.java   |  37 ---
 .../metadata/builder/DefaultTypeBuilderTest.java   |  64 -----
 .../metadata/builder/EnumTypeBuilderTest.java      |  84 ------
 .../metadata/builder/MapTypeBuilderTest.java       |  89 -------
 .../builder/ServiceDescriptorBuilderTest.java      |  25 --
 .../metadata/metadata/builder/SingleEnum.java      |   8 -
 .../metadata/metadata/builder/TestService.java     |  45 ----
 .../builder/TypeDescriptorBuilderTest.java         | 101 --------
 .../store/test/JTestMetadataReport4Test.java       |   3 +-
 .../support/AbstractMetadataReportFactoryTest.java |   1 -
 .../support/AbstractMetadataReportTest.java        |  11 +-
 .../store/zookeeper/ZookeeperMetadataReport.java   |  10 +-
 .../zookeeper/ZookeeperMetadataReportTest.java     |  32 +--
 .../java/org/apache/dubbo/registry/ZKTools.java    |   4 +-
 .../dubbo/remoting/zookeeper/ZookeeperClient.java  |   4 +
 .../zookeeper/curator/CuratorZookeeperClient.java  |  40 +++
 .../zookeeper/support/AbstractZookeeperClient.java |  28 ++
 .../zookeeper/zkclient/ZkClientWrapper.java        |  15 ++
 .../zkclient/ZkclientZookeeperClient.java          |  25 ++
 .../curator/CuratorZookeeperClientTest.java        |  30 ++-
 .../zkclient/ZkclientZookeeperClientTest.java      |  30 ++-
 .../webservice/WebserviceProtocolTest.java         |   4 +-
 61 files changed, 1144 insertions(+), 1369 deletions(-)


[incubator-dubbo] 02/03: Make ReferenceBean depend on ConfigCenterBean, so that ConfigCenterBean can always be initialized before refer.

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch dev-metadata
in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git

commit 22599b9e9b00997ecdc06ad7719e8fa054944a93
Author: ken.lj <ke...@gmail.com>
AuthorDate: Wed Nov 7 10:04:08 2018 +0800

    Make ReferenceBean depend on ConfigCenterBean, so that ConfigCenterBean can always be initialized before refer.
---
 .../apache/dubbo/config/ConfigCenterConfig.java    | 37 +++++++++++++++++++++-
 .../dubbo/config/spring/ConfigCenterBean.java      | 35 +++++++++++++++++++-
 .../apache/dubbo/config/spring/ReferenceBean.java  |  4 +++
 3 files changed, 74 insertions(+), 2 deletions(-)

diff --git a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ConfigCenterConfig.java b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ConfigCenterConfig.java
index d454caf..50b7699 100644
--- a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ConfigCenterConfig.java
+++ b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ConfigCenterConfig.java
@@ -49,6 +49,9 @@ public class ConfigCenterConfig extends AbstractConfig {
 
     private String appname;
     private String configfile = "dubbo.properties";
+    private String localconfigfile;
+
+    private ApplicationConfig application;
 
     // customized parameters
     private Map<String, String> parameters;
@@ -86,7 +89,11 @@ public class ConfigCenterConfig extends AbstractConfig {
         Environment.getInstance().setDynamicConfiguration(dynamicConfiguration);
         String configContent = dynamicConfiguration.getConfig(configfile, group);
 
-        String appConfigContent = dynamicConfiguration.getConfig(configfile, appname);
+        String appConfigContent = dynamicConfiguration.getConfig
+                (
+                        StringUtils.isNotEmpty(localconfigfile) ? localconfigfile : configfile,
+                        getApplicationName()
+                );
         try {
             Environment.getInstance().setConfigCenterFirst(priority);
             Environment.getInstance().updateExternalConfigurationMap(parseProperties(configContent));
@@ -96,6 +103,17 @@ public class ConfigCenterConfig extends AbstractConfig {
         }
     }
 
+    private String getApplicationName() {
+        if (application != null) {
+            if (!application.isValid()) {
+                throw new IllegalStateException(
+                        "No application config found or it's not a valid config! Please add <dubbo:application name=\"...\" /> to your spring config.");
+            }
+            return application.getName();
+        }
+        return appname;
+    }
+
     private Map<String, String> parseProperties(String content) throws IOException {
         Map<String, String> map = new HashMap<>();
         if (content == null) {
@@ -216,6 +234,15 @@ public class ConfigCenterConfig extends AbstractConfig {
         this.configfile = configfile;
     }
 
+    @Parameter(excluded = true)
+    public String getLocalconfigfile() {
+        return localconfigfile;
+    }
+
+    public void setLocalconfigfile(String localconfigfile) {
+        this.localconfigfile = localconfigfile;
+    }
+
     @Parameter(key = Constants.CONFIG_APPNAME_KEY)
     public String getAppname() {
         return appname;
@@ -233,4 +260,12 @@ public class ConfigCenterConfig extends AbstractConfig {
         checkParameterName(parameters);
         this.parameters = parameters;
     }
+
+    public ApplicationConfig getApplication() {
+        return application;
+    }
+
+    public void setApplication(ApplicationConfig application) {
+        this.application = application;
+    }
 }
diff --git a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/ConfigCenterBean.java b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/ConfigCenterBean.java
index b8754a2..aa88eaf 100644
--- a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/ConfigCenterBean.java
+++ b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/ConfigCenterBean.java
@@ -16,9 +16,16 @@
  */
 package org.apache.dubbo.config.spring;
 
+import org.apache.dubbo.config.ApplicationConfig;
 import org.apache.dubbo.config.ConfigCenterConfig;
+import org.apache.dubbo.config.spring.extension.SpringExtensionFactory;
+import org.springframework.beans.factory.BeanFactoryUtils;
 import org.springframework.beans.factory.DisposableBean;
 import org.springframework.beans.factory.InitializingBean;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+
+import java.util.Map;
 
 /**
  * Since 2.7.0+, export and refer will only be executed when Spring is fully initialized, and each Config bean will get refreshed on the start of the export and refer process.
@@ -26,10 +33,36 @@ import org.springframework.beans.factory.InitializingBean;
  *
  * If use ConfigCenterConfig directly, you should make sure ConfigCenterConfig.init() is called before actually export/refer any Dubbo service.
  */
-public class ConfigCenterBean extends ConfigCenterConfig implements InitializingBean, DisposableBean {
+public class ConfigCenterBean extends ConfigCenterConfig implements InitializingBean, ApplicationContextAware, DisposableBean {
+
+    private transient ApplicationContext applicationContext;
+
+    @Override
+    public void setApplicationContext(ApplicationContext applicationContext) {
+        this.applicationContext = applicationContext;
+        SpringExtensionFactory.addApplicationContext(applicationContext);
+    }
 
     @Override
     public void afterPropertiesSet() throws Exception {
+        if (getApplication() == null) {
+            Map<String, 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()) {
+                        if (applicationConfig != null) {
+                            throw new IllegalStateException("Duplicate application configs: " + applicationConfig + " and " + config);
+                        }
+                        applicationConfig = config;
+                    }
+                }
+                if (applicationConfig != null) {
+                    setApplication(applicationConfig);
+                }
+            }
+        }
+
         this.init();
     }
 
diff --git a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/ReferenceBean.java b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/ReferenceBean.java
index 07b7b2f..565b33f 100644
--- a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/ReferenceBean.java
+++ b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/ReferenceBean.java
@@ -79,6 +79,10 @@ public class ReferenceBean<T> extends ReferenceConfig<T> implements FactoryBean,
     @Override
     @SuppressWarnings({"unchecked"})
     public void afterPropertiesSet() throws Exception {
+        if (applicationContext != null) {
+            BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, ConfigCenterBean.class, false, false);
+        }
+
         if (getConsumer() == null) {
             Map<String, ConsumerConfig> consumerConfigMap = applicationContext == null ? null : BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, ConsumerConfig.class, false, false);
             if (consumerConfigMap != null && consumerConfigMap.size() > 0) {


[incubator-dubbo] 01/03: cherry-pick 4d0a36c435ca59bfcf909c0e76fa2ab024fb7408 from master 重构 ServiceBean 的 isDelay 方法,使其更符合语义

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch dev-metadata
in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git

commit 220c9da452acb0ae9aebc965bc00718989dad3fd
Author: 田小波 <ti...@outlook.com>
AuthorDate: Tue Oct 30 17:12:38 2018 +0800

    cherry-pick 4d0a36c435ca59bfcf909c0e76fa2ab024fb7408 from master
    重构 ServiceBean 的 isDelay 方法,使其更符合语义
---
 .../java/org/apache/dubbo/config/spring/ServiceBean.java    | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/ServiceBean.java b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/ServiceBean.java
index b644d62..e6bc114 100644
--- a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/ServiceBean.java
+++ b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/ServiceBean.java
@@ -108,7 +108,7 @@ public class ServiceBean<T> extends ServiceConfig<T> implements InitializingBean
 
     @Override
     public void onApplicationEvent(ContextRefreshedEvent event) {
-        if (isDelay() && !isExported() && !isUnexported()) {
+        if (!isExported() && !isUnexported()) {
             if (logger.isInfoEnabled()) {
                 logger.info("The service ready on spring started. service: " + getInterface());
             }
@@ -116,15 +116,6 @@ public class ServiceBean<T> extends ServiceConfig<T> implements InitializingBean
         }
     }
 
-    private boolean isDelay() {
-        Integer delay = getDelay();
-        ProviderConfig provider = getProvider();
-        if (delay == null && provider != null) {
-            delay = provider.getDelay();
-        }
-        return supportedApplicationListener && (delay == null || delay == -1);
-    }
-
     @Override
     @SuppressWarnings({"unchecked", "deprecation"})
     public void afterPropertiesSet() throws Exception {
@@ -264,7 +255,7 @@ public class ServiceBean<T> extends ServiceConfig<T> implements InitializingBean
 
         checkAndUpdateSubConfigs();
 
-        if (!isDelay()) {
+        if (!supportedApplicationListener) {
             export();
         }
     }