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 2019/08/21 07:10:37 UTC

[dubbo] 05/07: service discovery demos

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

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

commit 1d554d326f2c6670141dcbbd98861ca6bb86b0c0
Author: ken.lj <ke...@gmail.com>
AuthorDate: Wed Aug 21 12:54:38 2019 +0800

    service discovery demos
---
 .../org/apache/dubbo/bootstrap/DubboBootstrap.java | 53 +++---------
 .../bootstrap/DubboServiceConsumerBootstrap.java   |  1 -
 .../bootstrap/DubboServiceProviderBootstrap.java   |  2 +-
 .../EtcdDubboServiceConsumerBootstrap.java         |  2 -
 .../EtcdDubboServiceProviderBootstrap.java         |  3 +-
 .../NacosDubboServiceConsumerBootstrap.java        |  1 -
 .../NacosDubboServiceProviderBootstrap.java        |  1 -
 .../DubboInterfaceConsumerBootstrap.java           |  1 -
 .../org/apache/dubbo/config/ApplicationConfig.java | 20 +++--
 .../org/apache/dubbo/config/ReferenceConfig.java   |  2 +-
 .../org/apache/dubbo/config/RegistryConfig.java    | 23 +++++
 .../dubbo/config/builders/ApplicationBuilder.java  |  2 +-
 .../apache/dubbo/config/context/ConfigManager.java |  4 +
 .../dubbo/config/spring/ApplicationBean.java       | 89 -------------------
 .../apache/dubbo/config/spring/ReferenceBean.java  |  1 +
 .../apache/dubbo/config/spring/ServiceBean.java    | 22 +----
 .../src/main/resources/META-INF/compat/dubbo.xsd   | 18 +++-
 .../src/main/resources/META-INF/dubbo.xsd          | 18 +++-
 .../org/apache/dubbo/demo/GreetingService.java     | 24 ++++++
 dubbo-demo/dubbo-demo-servicediscovery-xml/pom.xml | 61 +++++++++++++
 .../servicediscovery-consumer/pom.xml              | 84 ++++++++++++++++++
 .../apache/dubbo/demo/consumer/Application.java    | 31 +++++++
 .../src/main/resources/dubbo.properties            |  1 +
 .../src/main/resources/log4j.properties            |  7 ++
 .../src/main/resources/spring/dubbo-consumer.xml   | 30 +++++++
 .../servicediscovery-provider/pom.xml              | 99 ++++++++++++++++++++++
 .../apache/dubbo/demo/provider/Application.java    | 27 ++++++
 .../dubbo/demo/provider/DemoServiceImpl.java       | 34 ++++++++
 .../src/main/resources/dubbo.properties            |  1 +
 .../src/main/resources/log4j.properties            |  7 ++
 .../src/main/resources/spring/dubbo-provider.xml   | 34 ++++++++
 dubbo-demo/pom.xml                                 |  4 +
 .../dubbo/demo/provider/GreetingServiceImpl.java   | 31 +++++++
 .../servicediscovery-consumer/pom.xml              | 84 ++++++++++++++++++
 .../apache/dubbo/demo/consumer/Application.java    | 31 +++++++
 .../src/main/resources/dubbo.properties            |  1 +
 .../src/main/resources/log4j.properties            |  7 ++
 .../src/main/resources/spring/dubbo-consumer.xml   | 30 +++++++
 .../dubbo/metadata/WritableMetadataService.java    | 14 ---
 .../metadata/ServiceInstanceMetadataUtils.java     |  8 +-
 40 files changed, 728 insertions(+), 185 deletions(-)

diff --git a/dubbo-bootstrap/src/main/java/org/apache/dubbo/bootstrap/DubboBootstrap.java b/dubbo-bootstrap/src/main/java/org/apache/dubbo/bootstrap/DubboBootstrap.java
index 0c864c4..21fb318 100644
--- a/dubbo-bootstrap/src/main/java/org/apache/dubbo/bootstrap/DubboBootstrap.java
+++ b/dubbo-bootstrap/src/main/java/org/apache/dubbo/bootstrap/DubboBootstrap.java
@@ -84,7 +84,6 @@ import static org.apache.dubbo.common.function.ThrowableAction.execute;
 import static org.apache.dubbo.common.utils.StringUtils.isNotEmpty;
 import static org.apache.dubbo.config.context.ConfigManager.getInstance;
 import static org.apache.dubbo.metadata.WritableMetadataService.getExtension;
-import static org.apache.dubbo.metadata.WritableMetadataService.getMetadataStorageType;
 import static org.apache.dubbo.registry.client.metadata.ServiceInstanceMetadataUtils.setMetadataStorageType;
 import static org.apache.dubbo.remoting.Constants.CLIENT_KEY;
 
@@ -129,13 +128,6 @@ public class DubboBootstrap extends GenericEventListener implements Lifecycle {
 
     private volatile boolean started = false;
 
-    /**
-     * Only Provider Register
-     */
-    private volatile boolean onlyRegisterProvider = false;
-
-    private volatile boolean defaultMetadataStorageType = true;
-
     private volatile ServiceInstance serviceInstance;
 
     private volatile MetadataService metadataService;
@@ -161,28 +153,13 @@ public class DubboBootstrap extends GenericEventListener implements Lifecycle {
         });
     }
 
-    /**
-     * Set only register provider or not
-     *
-     * @param onlyRegisterProvider if <code>true</code>, only register the provider and reduce the registries' load.
-     * @return {@link DubboBootstrap}
-     */
-    public DubboBootstrap onlyRegisterProvider(boolean onlyRegisterProvider) {
-        this.onlyRegisterProvider = onlyRegisterProvider;
-        return this;
+    private boolean isOnlyRegisterProvider() {
+        Boolean registerConsumer = configManager.getApplicationOrElseThrow().getRegisterConsumer();
+        return registerConsumer == null || !registerConsumer;
     }
 
-    public boolean isOnlyRegisterProvider() {
-        return onlyRegisterProvider;
-    }
-
-    public boolean isDefaultMetadataStorageType() {
-        return defaultMetadataStorageType;
-    }
-
-    public DubboBootstrap defaultMetadataStorageType(boolean defaultMetadataStorageType) {
-        this.defaultMetadataStorageType = defaultMetadataStorageType;
-        return this;
+    private String getMetadataType() {
+        return configManager.getApplicationOrElseThrow().getMetadataType();
     }
 
     public DubboBootstrap metadataReport(MetadataReportConfig metadataReportConfig) {
@@ -456,8 +433,6 @@ public class DubboBootstrap extends GenericEventListener implements Lifecycle {
 
             useRegistryAsConfigCenterIfNecessary();
 
-            initApplicationMetadata();
-
             initMetadataService();
 
             initMetadataServiceExporter();
@@ -475,11 +450,6 @@ public class DubboBootstrap extends GenericEventListener implements Lifecycle {
         return this;
     }
 
-    private void initApplicationMetadata() {
-        String metadataStorageType = getMetadataStorageType(isDefaultMetadataStorageType());
-        getApplication().setMetadataStorageType(metadataStorageType);
-    }
-
     private void startConfigCenter() {
         Collection<ConfigCenterConfig> configCenters = configManager.getConfigCenters();
 
@@ -499,7 +469,7 @@ public class DubboBootstrap extends GenericEventListener implements Lifecycle {
                 () -> new IllegalStateException("There's no ApplicationConfig specified.")
         );
 
-        String metadataType = applicationConfig.getMetadataStorageType();
+        String metadataType = applicationConfig.getMetadataType();
         // FIXME, multiple metadata config support.
         Collection<MetadataReportConfig> metadataReportConfigs = configManager.getMetadataConfigs();
         if (CollectionUtils.isEmpty(metadataReportConfigs)) {
@@ -589,7 +559,7 @@ public class DubboBootstrap extends GenericEventListener implements Lifecycle {
      * Initialize {@link MetadataService} from {@link WritableMetadataService}'s extension
      */
     private void initMetadataService() {
-        this.metadataService = getExtension(isDefaultMetadataStorageType());
+        this.metadataService = getExtension(getMetadataType());
     }
 
     /**
@@ -794,7 +764,12 @@ public class DubboBootstrap extends GenericEventListener implements Lifecycle {
         if (cache == null) {
             cache = ReferenceConfigCache.getCache();
         }
-        configManager.getReferences().forEach(cache::get);
+        configManager.getReferences().forEach((rc) -> {
+            // check eager init or not.
+            if (rc.shouldInit()) {
+                cache.get(rc);
+            }
+        });
     }
 
     private void registerServiceInstance() {
@@ -843,7 +818,7 @@ public class DubboBootstrap extends GenericEventListener implements Lifecycle {
 
     private ServiceInstance createServiceInstance(String serviceName, String host, int port) {
         this.serviceInstance = new DefaultServiceInstance(serviceName, host, port);
-        setMetadataStorageType(serviceInstance, isDefaultMetadataStorageType());
+        setMetadataStorageType(serviceInstance, getMetadataType());
         return this.serviceInstance;
     }
 
diff --git a/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/DubboServiceConsumerBootstrap.java b/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/DubboServiceConsumerBootstrap.java
index e765643..c590653 100644
--- a/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/DubboServiceConsumerBootstrap.java
+++ b/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/DubboServiceConsumerBootstrap.java
@@ -40,7 +40,6 @@ public class DubboServiceConsumerBootstrap {
 //                .registry("consul", builder -> builder.address("consul://127.0.0.1:8500?registry.type=service&subscribed.services=dubbo-provider-demo").group("namespace1"))
                 .reference("echo", builder -> builder.interfaceClass(EchoService.class).protocol("dubbo"))
                 .reference("user", builder -> builder.interfaceClass(UserService.class).protocol("rest"))
-                .onlyRegisterProvider(true)
                 .start()
                 .await();
 
diff --git a/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/DubboServiceProviderBootstrap.java b/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/DubboServiceProviderBootstrap.java
index 8dabb16..15abaa5 100644
--- a/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/DubboServiceProviderBootstrap.java
+++ b/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/DubboServiceProviderBootstrap.java
@@ -63,7 +63,7 @@ public class DubboServiceProviderBootstrap {
 //        userService.setRegistries(Arrays.asList(interfaceRegistry, serviceRegistry));
 
         ApplicationConfig applicationConfig = new ApplicationConfig("dubbo-provider-demo");
-        applicationConfig.setMetadataStorageType("remote");
+        applicationConfig.setMetadataType("remote");
         new DubboBootstrap()
                 .application(applicationConfig)
                 // Zookeeper in service registry type
diff --git a/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/EtcdDubboServiceConsumerBootstrap.java b/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/EtcdDubboServiceConsumerBootstrap.java
index 01302f3..b1cc6d3 100644
--- a/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/EtcdDubboServiceConsumerBootstrap.java
+++ b/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/EtcdDubboServiceConsumerBootstrap.java
@@ -32,7 +32,6 @@ public class EtcdDubboServiceConsumerBootstrap {
 
         new DubboBootstrap()
                 .application("dubbo-consumer-demo")
-                .defaultMetadataStorageType(true)
                 // Zookeeper
                 .protocol(builder -> builder.port(20887).name("dubbo"))
                 .registry("zookeeper", builder -> builder.address("etcd3://127.0.0.1:2379?registry.type=service&subscribed.services=dubbo-provider-demo"))
@@ -41,7 +40,6 @@ public class EtcdDubboServiceConsumerBootstrap {
 //                .registry("consul", builder -> builder.address("consul://127.0.0.1:8500?registry.type=service&subscribed.services=dubbo-provider-demo").group("namespace1"))
                 .reference("echo", builder -> builder.interfaceClass(EchoService.class).protocol("dubbo"))
                 .reference("user", builder -> builder.interfaceClass(UserService.class).protocol("rest"))
-                .onlyRegisterProvider(true)
                 .start()
                 .await();
 
diff --git a/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/EtcdDubboServiceProviderBootstrap.java b/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/EtcdDubboServiceProviderBootstrap.java
index 013c0d8..9a59273 100644
--- a/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/EtcdDubboServiceProviderBootstrap.java
+++ b/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/EtcdDubboServiceProviderBootstrap.java
@@ -63,10 +63,9 @@ public class EtcdDubboServiceProviderBootstrap {
 //        userService.setRegistries(Arrays.asList(interfaceRegistry, serviceRegistry));
 
         ApplicationConfig applicationConfig = new ApplicationConfig("dubbo-provider-demo");
-        applicationConfig.setMetadataStorageType("remote");
+        applicationConfig.setMetadataType("remote");
         new DubboBootstrap()
                 .application(applicationConfig)
-                .defaultMetadataStorageType(true)
                 // Zookeeper in service registry type
 //                .registry("zookeeper", builder -> builder.address("zookeeper://127.0.0.1:2181?registry.type=service"))
                 // Nacos
diff --git a/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/NacosDubboServiceConsumerBootstrap.java b/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/NacosDubboServiceConsumerBootstrap.java
index 3f57736..873457e 100644
--- a/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/NacosDubboServiceConsumerBootstrap.java
+++ b/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/NacosDubboServiceConsumerBootstrap.java
@@ -39,7 +39,6 @@ public class NacosDubboServiceConsumerBootstrap {
 //                .registry("consul", builder -> builder.address("consul://127.0.0.1:8500?registry.type=service&subscribed.services=dubbo-provider-demo").group("namespace1"))
                 .reference("echo", builder -> builder.interfaceClass(EchoService.class).protocol("dubbo"))
                 .reference("user", builder -> builder.interfaceClass(UserService.class).protocol("rest"))
-                .onlyRegisterProvider(true)
                 .start()
                 .await();
 
diff --git a/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/NacosDubboServiceProviderBootstrap.java b/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/NacosDubboServiceProviderBootstrap.java
index 2fd8ecb..4e0297c 100644
--- a/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/NacosDubboServiceProviderBootstrap.java
+++ b/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/NacosDubboServiceProviderBootstrap.java
@@ -29,7 +29,6 @@ public class NacosDubboServiceProviderBootstrap {
 
     public static void main(String[] args) {
         new DubboBootstrap()
-                .defaultMetadataStorageType(false)
                 .application("dubbo-provider-demo")
                 // Zookeeper in service registry type
                 .registry("zookeeper", builder -> builder.address("zookeeper://127.0.0.1:2181?registry.type=service"))
diff --git a/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/compatible/DubboInterfaceConsumerBootstrap.java b/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/compatible/DubboInterfaceConsumerBootstrap.java
index 79a0030..aa1e74d 100644
--- a/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/compatible/DubboInterfaceConsumerBootstrap.java
+++ b/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/compatible/DubboInterfaceConsumerBootstrap.java
@@ -43,7 +43,6 @@ public class DubboInterfaceConsumerBootstrap {
 //                .registry("consul", builder -> builder.address("consul://127.0.0.1:8500?registry.type=service&subscribed.services=dubbo-provider-demo"))
                 .reference("echo", builder -> builder.interfaceClass(EchoService.class).protocol("dubbo"))
                 .reference("user", builder -> builder.interfaceClass(UserService.class).protocol("rest"))
-                .onlyRegisterProvider(true)
                 .start()
                 .await();
 
diff --git a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ApplicationConfig.java b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ApplicationConfig.java
index 9880c23..57b006f 100644
--- a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ApplicationConfig.java
+++ b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ApplicationConfig.java
@@ -150,7 +150,9 @@ public class ApplicationConfig extends AbstractConfig {
     /**
      * Metadata type, local or remote, if choose remote, you need to further specify metadata center.
      */
-    private String metadataStorageType;
+    private String metadataType;
+
+    private Boolean registerConsumer;
 
     public ApplicationConfig() {
     }
@@ -388,12 +390,20 @@ public class ApplicationConfig extends AbstractConfig {
         return !StringUtils.isEmpty(name);
     }
 
-    public String getMetadataStorageType() {
-        return metadataStorageType;
+    public String getMetadataType() {
+        return metadataType;
+    }
+
+    public void setMetadataType(String metadataType) {
+        this.metadataType = metadataType;
+    }
+
+    public Boolean getRegisterConsumer() {
+        return registerConsumer;
     }
 
-    public void setMetadataStorageType(String metadataStorageType) {
-        this.metadataStorageType = metadataStorageType;
+    public void setRegisterConsumer(Boolean registerConsumer) {
+        this.registerConsumer = registerConsumer;
     }
 
     @Override
diff --git a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ReferenceConfig.java b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ReferenceConfig.java
index 9d01682..3169aa8 100644
--- a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ReferenceConfig.java
+++ b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ReferenceConfig.java
@@ -490,7 +490,7 @@ public class ReferenceConfig<T> extends AbstractReferenceConfig {
         return shouldCheck;
     }
 
-    protected boolean shouldInit() {
+    public boolean shouldInit() {
         Boolean shouldInit = isInit();
         if (shouldInit == null && getConsumer() != null) {
             shouldInit = getConsumer().isInit();
diff --git a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/RegistryConfig.java b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/RegistryConfig.java
index f8f5643..cd81def 100644
--- a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/RegistryConfig.java
+++ b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/RegistryConfig.java
@@ -160,6 +160,13 @@ public class RegistryConfig extends AbstractConfig {
      */
     private Boolean useAsMetadataCenter;
 
+    /**
+     * list of rpc protocols accepted by this registry, for example, "dubbo,rest"
+     */
+    private String accepts;
+
+    private Boolean preferred;
+
     public RegistryConfig() {
     }
 
@@ -454,6 +461,22 @@ public class RegistryConfig extends AbstractConfig {
         this.useAsMetadataCenter = useAsMetadataCenter;
     }
 
+    public String getAccepts() {
+        return accepts;
+    }
+
+    public void setAccepts(String accepts) {
+        this.accepts = accepts;
+    }
+
+    public Boolean getPreferred() {
+        return preferred;
+    }
+
+    public void setPreferred(Boolean preferred) {
+        this.preferred = preferred;
+    }
+
     @Override
     public void refresh() {
         super.refresh();
diff --git a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/builders/ApplicationBuilder.java b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/builders/ApplicationBuilder.java
index 5f6f999..b1bb37b 100644
--- a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/builders/ApplicationBuilder.java
+++ b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/builders/ApplicationBuilder.java
@@ -177,7 +177,7 @@ public class ApplicationBuilder extends AbstractBuilder<ApplicationConfig, Appli
         super.build(config);
 
         config.setName(name);
-        config.setMetadataStorageType(metadata);
+        config.setMetadataType(metadata);
         config.setVersion(this.version);
         config.setOwner(this.owner);
         config.setOrganization(this.organization);
diff --git a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/context/ConfigManager.java b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/context/ConfigManager.java
index 6996740..abb0b0c 100644
--- a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/context/ConfigManager.java
+++ b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/context/ConfigManager.java
@@ -117,6 +117,10 @@ public class ConfigManager {
         return ofNullable(getConfig(ApplicationConfig.class));
     }
 
+    public ApplicationConfig getApplicationOrElseThrow() {
+        return getApplication().orElseThrow(() -> new IllegalStateException("There's no ApplicationConfig specified."));
+    }
+
     // MonitorConfig correlative methods
 
     public void setMonitor(MonitorConfig monitor) {
diff --git a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/ApplicationBean.java b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/ApplicationBean.java
deleted file mode 100644
index c1d0882..0000000
--- a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/ApplicationBean.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.dubbo.config.spring;
-
-
-import org.apache.dubbo.bootstrap.DubboBootstrap;
-import org.apache.dubbo.common.utils.CollectionUtils;
-import org.apache.dubbo.config.ApplicationConfig;
-import org.apache.dubbo.config.ConfigCenterConfig;
-import org.apache.dubbo.config.ConsumerConfig;
-import org.apache.dubbo.config.MetadataReportConfig;
-import org.apache.dubbo.config.MetricsConfig;
-import org.apache.dubbo.config.ModuleConfig;
-import org.apache.dubbo.config.MonitorConfig;
-import org.apache.dubbo.config.ProtocolConfig;
-import org.apache.dubbo.config.ProviderConfig;
-import org.apache.dubbo.config.ReferenceConfig;
-import org.apache.dubbo.config.RegistryConfig;
-import org.apache.dubbo.config.ServiceConfig;
-import org.apache.dubbo.config.spring.util.BeanFactoryUtils;
-
-import org.springframework.beans.BeansException;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-import org.springframework.context.ApplicationEvent;
-import org.springframework.context.ApplicationListener;
-import org.springframework.context.event.ContextRefreshedEvent;
-
-import java.util.List;
-
-public class ApplicationBean extends ApplicationConfig implements ApplicationListener<ApplicationEvent>, ApplicationContextAware {
-
-    private ApplicationContext applicationContext;
-
-    @Override
-    public void onApplicationEvent(ApplicationEvent event) {
-        if (event instanceof ContextRefreshedEvent) {
-            List<RegistryConfig> registries = getBeans(RegistryConfig.class);
-            List<ProtocolConfig> protocols = getBeans(ProtocolConfig.class);
-            List<ConfigCenterConfig> configs = getBeans(ConfigCenterConfig.class);
-            List<MetadataReportConfig> metadatas = getBeans(MetadataReportConfig.class);
-            List<MonitorConfig> monitors = getBeans(MonitorConfig.class);
-            List<ProviderConfig> providers = getBeans(ProviderConfig.class);
-            List<ConsumerConfig> consumers = getBeans(ConsumerConfig.class);
-            List<ModuleConfig> modules = getBeans(ModuleConfig.class);
-            List<MetricsConfig> metrics = getBeans(MetricsConfig.class);
-            List<ServiceConfig> services = getBeans(ServiceConfig.class);
-            List<ReferenceConfig> references = getBeans(ReferenceConfig.class);
-
-            DubboBootstrap bootstrap = new DubboBootstrap();
-            bootstrap.application(this)
-                    .monitor(CollectionUtils.isNotEmpty(monitors) ? monitors.get(0) : null)
-                    .module(CollectionUtils.isNotEmpty(modules) ? modules.get(0) : null)
-                    .metrics(CollectionUtils.isNotEmpty(metrics) ? metrics.get(0) : null)
-                    .registries(registries)
-                    .protocols(protocols)
-                    .configCenters(configs)
-                    .metadataReports(metadatas)
-                    .providers(providers)
-                    .consumers(consumers)
-                    .services(services)
-                    .references(references)
-                    .start();
-        }
-    }
-
-    @Override
-    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
-        this.applicationContext = applicationContext;
-    }
-
-    private <T> List<T> getBeans(Class<T> clazz) {
-        return BeanFactoryUtils.getBeans(applicationContext, new String[]{""}, clazz);
-    }
-}
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 586cb22..74edfe8 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
@@ -75,6 +75,7 @@ public class ReferenceBean<T> extends ReferenceConfig<T> implements FactoryBean,
             BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, ConfigCenterBean.class, false, false);
         }
 
+        // eager init if necessary.
         if (shouldInit()) {
             getObject();
         }
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 5e54c25..0ae5f62 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
@@ -30,10 +30,6 @@ import org.springframework.context.ApplicationContext;
 import org.springframework.context.ApplicationContextAware;
 import org.springframework.context.ApplicationEventPublisher;
 import org.springframework.context.ApplicationEventPublisherAware;
-import org.springframework.context.ApplicationListener;
-import org.springframework.context.event.ContextRefreshedEvent;
-
-import static org.apache.dubbo.config.spring.util.BeanFactoryUtils.addApplicationListener;
 
 /**
  * ServiceFactoryBean
@@ -41,7 +37,7 @@ import static org.apache.dubbo.config.spring.util.BeanFactoryUtils.addApplicatio
  * @export
  */
 public class ServiceBean<T> extends ServiceConfig<T> implements InitializingBean, DisposableBean,
-        ApplicationContextAware, ApplicationListener<ContextRefreshedEvent>, BeanNameAware,
+        ApplicationContextAware, BeanNameAware,
         ApplicationEventPublisherAware {
 
 
@@ -53,8 +49,6 @@ public class ServiceBean<T> extends ServiceConfig<T> implements InitializingBean
 
     private transient String beanName;
 
-    private transient boolean supportedApplicationListener;
-
     private ApplicationEventPublisher applicationEventPublisher;
 
     public ServiceBean() {
@@ -71,7 +65,6 @@ public class ServiceBean<T> extends ServiceConfig<T> implements InitializingBean
     public void setApplicationContext(ApplicationContext applicationContext) {
         this.applicationContext = applicationContext;
         SpringExtensionFactory.addApplicationContext(applicationContext);
-        supportedApplicationListener = addApplicationListener(applicationContext, this);
     }
 
     @Override
@@ -89,16 +82,6 @@ public class ServiceBean<T> extends ServiceConfig<T> implements InitializingBean
     }
 
     @Override
-    public void onApplicationEvent(ContextRefreshedEvent event) {
-        if (!isExported() && !isUnexported()) {
-            if (logger.isInfoEnabled()) {
-                logger.info("The service ready on spring started. service: " + getInterface());
-            }
-            export();
-        }
-    }
-
-    @Override
     public void afterPropertiesSet() throws Exception {
         if (StringUtils.isEmpty(getPath())) {
             if (StringUtils.isNotEmpty(beanName)
@@ -107,9 +90,6 @@ public class ServiceBean<T> extends ServiceConfig<T> implements InitializingBean
                 setPath(beanName);
             }
         }
-        if (!supportedApplicationListener) {
-            export();
-        }
     }
 
     /**
diff --git a/dubbo-config/dubbo-config-spring/src/main/resources/META-INF/compat/dubbo.xsd b/dubbo-config/dubbo-config-spring/src/main/resources/META-INF/compat/dubbo.xsd
index e926994..893cc5e 100644
--- a/dubbo-config/dubbo-config-spring/src/main/resources/META-INF/compat/dubbo.xsd
+++ b/dubbo-config/dubbo-config-spring/src/main/resources/META-INF/compat/dubbo.xsd
@@ -397,11 +397,16 @@
                 <xsd:documentation><![CDATA[ Is default. ]]></xsd:documentation>
             </xsd:annotation>
         </xsd:attribute>
-        <xsd:attribute name="metadata" type="xsd:string">
+        <xsd:attribute name="metadata-type" type="xsd:string">
             <xsd:annotation>
                 <xsd:documentation><![CDATA[ The metadta type: local or remote. ]]></xsd:documentation>
             </xsd:annotation>
         </xsd:attribute>
+        <xsd:attribute name="register-consumer" type="xsd:boolean">
+            <xsd:annotation>
+                <xsd:documentation><![CDATA[ Register consumer instance or not, default false. ]]></xsd:documentation>
+            </xsd:annotation>
+        </xsd:attribute>
 
     </xsd:complexType>
 
@@ -590,6 +595,17 @@
                 <xsd:documentation><![CDATA[ work as metadata center or not. ]]></xsd:documentation>
             </xsd:annotation>
         </xsd:attribute>
+        <xsd:attribute name="accepts" type="xsd:string">
+            <xsd:annotation>
+                <xsd:documentation>
+                    <![CDATA[ list of rpc protocols accepted by this registry, separated with ",". ]]></xsd:documentation>
+            </xsd:annotation>
+        </xsd:attribute>
+        <xsd:attribute name="preferred" type="xsd:boolean">
+            <xsd:annotation>
+                <xsd:documentation><![CDATA[ Is this registry the preferred one. ]]></xsd:documentation>
+            </xsd:annotation>
+        </xsd:attribute>
     </xsd:complexType>
 
     <xsd:complexType name="metadataReportType">
diff --git a/dubbo-config/dubbo-config-spring/src/main/resources/META-INF/dubbo.xsd b/dubbo-config/dubbo-config-spring/src/main/resources/META-INF/dubbo.xsd
index d75b51b..e538751 100644
--- a/dubbo-config/dubbo-config-spring/src/main/resources/META-INF/dubbo.xsd
+++ b/dubbo-config/dubbo-config-spring/src/main/resources/META-INF/dubbo.xsd
@@ -392,11 +392,16 @@
                 <xsd:documentation><![CDATA[ Is default. ]]></xsd:documentation>
             </xsd:annotation>
         </xsd:attribute>
-        <xsd:attribute name="metadata" type="xsd:string">
+        <xsd:attribute name="metadata-type" type="xsd:string">
             <xsd:annotation>
                 <xsd:documentation><![CDATA[ The metadta type: local or remote. ]]></xsd:documentation>
             </xsd:annotation>
         </xsd:attribute>
+        <xsd:attribute name="register-consumer" type="xsd:boolean">
+            <xsd:annotation>
+                <xsd:documentation><![CDATA[ Register consumer instance or not, default false. ]]></xsd:documentation>
+            </xsd:annotation>
+        </xsd:attribute>
     </xsd:complexType>
 
     <xsd:complexType name="moduleType">
@@ -584,6 +589,17 @@
                 <xsd:documentation><![CDATA[ work as metadata center or not. ]]></xsd:documentation>
             </xsd:annotation>
         </xsd:attribute>
+        <xsd:attribute name="accepts" type="xsd:string">
+            <xsd:annotation>
+                <xsd:documentation>
+                    <![CDATA[ list of rpc protocols accepted by this registry, separated with ",". ]]></xsd:documentation>
+            </xsd:annotation>
+        </xsd:attribute>
+        <xsd:attribute name="preferred" type="xsd:boolean">
+            <xsd:annotation>
+                <xsd:documentation><![CDATA[ Is this registry the preferred one. ]]></xsd:documentation>
+            </xsd:annotation>
+        </xsd:attribute>
     </xsd:complexType>
 
     <xsd:complexType name="metadataReportType">
diff --git a/dubbo-demo/dubbo-demo-interface/src/main/java/org/apache/dubbo/demo/GreetingService.java b/dubbo-demo/dubbo-demo-interface/src/main/java/org/apache/dubbo/demo/GreetingService.java
new file mode 100644
index 0000000..38c7a60
--- /dev/null
+++ b/dubbo-demo/dubbo-demo-interface/src/main/java/org/apache/dubbo/demo/GreetingService.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.demo;
+
+/**
+ *
+ */
+public interface GreetingService {
+    String hello();
+}
diff --git a/dubbo-demo/dubbo-demo-servicediscovery-xml/pom.xml b/dubbo-demo/dubbo-demo-servicediscovery-xml/pom.xml
new file mode 100644
index 0000000..92c583c
--- /dev/null
+++ b/dubbo-demo/dubbo-demo-servicediscovery-xml/pom.xml
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <groupId>org.apache.dubbo</groupId>
+        <artifactId>dubbo-demo</artifactId>
+        <version>${revision}</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+    <packaging>pom</packaging>
+
+    <artifactId>dubbo-demo-servicediscovery-xml</artifactId>
+
+    <properties>
+        <skip_maven_deploy>true</skip_maven_deploy>
+        <spring-boot-maven-plugin.version>2.1.4.RELEASE</spring-boot-maven-plugin.version>
+    </properties>
+
+    <modules>
+        <module>servicediscovery-provider</module>
+        <module>servicediscovery-consumer</module>
+    </modules>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <version>${spring-boot-maven-plugin.version}</version>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>repackage</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
diff --git a/dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-consumer/pom.xml b/dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-consumer/pom.xml
new file mode 100644
index 0000000..7d09428
--- /dev/null
+++ b/dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-consumer/pom.xml
@@ -0,0 +1,84 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.dubbo</groupId>
+        <artifactId>dubbo-demo-servicediscovery-xml</artifactId>
+        <version>${revision}</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+    <artifactId>servicediscovery-consumer</artifactId>
+    <packaging>jar</packaging>
+    <name>${project.artifactId}</name>
+    <description>The demo consumer module of dubbo project</description>
+    <properties>
+        <skip_maven_deploy>true</skip_maven_deploy>
+    </properties>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo-demo-interface</artifactId>
+            <version>${project.parent.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo-registry-multicast</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo-registry-nacos</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.alibaba.nacos</groupId>
+            <artifactId>nacos-client</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo-registry-zookeeper</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo-configcenter-zookeeper</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo-configcenter-nacos</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo-metadata-report-nacos</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo-config-spring</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo-rpc-dubbo</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo-remoting-netty4</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo-serialization-hessian2</artifactId>
+        </dependency>
+    </dependencies>
+</project>
diff --git a/dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-consumer/src/main/java/org/apache/dubbo/demo/consumer/Application.java b/dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-consumer/src/main/java/org/apache/dubbo/demo/consumer/Application.java
new file mode 100644
index 0000000..f448a18
--- /dev/null
+++ b/dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-consumer/src/main/java/org/apache/dubbo/demo/consumer/Application.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.demo.consumer;
+
+import org.apache.dubbo.demo.DemoService;
+
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class Application {
+    public static void main(String[] args) {
+        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/dubbo-consumer.xml");
+        context.start();
+        DemoService demoService = context.getBean("demoService", DemoService.class);
+        String hello = demoService.sayHello("world");
+        System.out.println("result: " + hello);
+    }
+}
diff --git a/dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-consumer/src/main/resources/dubbo.properties b/dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-consumer/src/main/resources/dubbo.properties
new file mode 100644
index 0000000..8c3cb25
--- /dev/null
+++ b/dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-consumer/src/main/resources/dubbo.properties
@@ -0,0 +1 @@
+dubbo.application.qos.port=33333
diff --git a/dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-consumer/src/main/resources/log4j.properties b/dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-consumer/src/main/resources/log4j.properties
new file mode 100644
index 0000000..2424381
--- /dev/null
+++ b/dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-consumer/src/main/resources/log4j.properties
@@ -0,0 +1,7 @@
+###set log levels###
+log4j.rootLogger=info, stdout
+###output to console###
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=[%d{dd/MM/yy HH:mm:ss:SSS z}] %t %5p %c{2}: %m%n
\ No newline at end of file
diff --git a/dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-consumer/src/main/resources/spring/dubbo-consumer.xml b/dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-consumer/src/main/resources/spring/dubbo-consumer.xml
new file mode 100644
index 0000000..d3081f6
--- /dev/null
+++ b/dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-consumer/src/main/resources/spring/dubbo-consumer.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+  -->
+<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"
+       xmlns="http://www.springframework.org/schema/beans"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
+       http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd">
+
+    <dubbo:application name="demo-consumer"/>
+
+    <dubbo:registry address="zookeeper://127.0.0.1:2181?registry.type=service"/>
+
+    <dubbo:reference id="demoService" check="false" interface="org.apache.dubbo.demo.DemoService"/>
+
+</beans>
diff --git a/dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-provider/pom.xml b/dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-provider/pom.xml
new file mode 100644
index 0000000..6140425
--- /dev/null
+++ b/dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-provider/pom.xml
@@ -0,0 +1,99 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.dubbo</groupId>
+        <artifactId>dubbo-demo-servicediscovery-xml</artifactId>
+        <version>${revision}</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+    <artifactId>servicediscovery-provider</artifactId>
+    <packaging>jar</packaging>
+    <name>${project.artifactId}</name>
+    <description>The demo provider module of dubbo project</description>
+    <properties>
+        <skip_maven_deploy>true</skip_maven_deploy>
+        <slf4j-log4j12.version>1.7.25</slf4j-log4j12.version>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo-demo-interface</artifactId>
+            <version>${project.parent.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo-registry-multicast</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo-registry-nacos</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.alibaba.nacos</groupId>
+            <artifactId>nacos-client</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo-registry-zookeeper</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo-configcenter-zookeeper</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo-configcenter-nacos</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo-metadata-report-nacos</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo-rpc-dubbo</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo-config-spring</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo-remoting-netty4</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo-serialization-hessian2</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+            <version>${slf4j-log4j12.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>log4j</groupId>
+            <artifactId>log4j</artifactId>
+        </dependency>
+    </dependencies>
+</project>
diff --git a/dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-provider/src/main/java/org/apache/dubbo/demo/provider/Application.java b/dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-provider/src/main/java/org/apache/dubbo/demo/provider/Application.java
new file mode 100644
index 0000000..d1ab5be
--- /dev/null
+++ b/dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-provider/src/main/java/org/apache/dubbo/demo/provider/Application.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.demo.provider;
+
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class Application {
+    public static void main(String[] args) throws Exception {
+        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/dubbo-provider.xml");
+        context.start();
+        System.in.read();
+    }
+}
diff --git a/dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-provider/src/main/java/org/apache/dubbo/demo/provider/DemoServiceImpl.java b/dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-provider/src/main/java/org/apache/dubbo/demo/provider/DemoServiceImpl.java
new file mode 100644
index 0000000..5e2ef23
--- /dev/null
+++ b/dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-provider/src/main/java/org/apache/dubbo/demo/provider/DemoServiceImpl.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.demo.provider;
+
+import org.apache.dubbo.demo.DemoService;
+import org.apache.dubbo.rpc.RpcContext;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DemoServiceImpl implements DemoService {
+    private static final Logger logger = LoggerFactory.getLogger(DemoServiceImpl.class);
+
+    @Override
+    public String sayHello(String name) {
+        logger.info("Hello " + name + ", request from consumer: " + RpcContext.getContext().getRemoteAddress());
+        return "Hello " + name + ", response from provider: " + RpcContext.getContext().getLocalAddress();
+    }
+
+}
diff --git a/dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-provider/src/main/resources/dubbo.properties b/dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-provider/src/main/resources/dubbo.properties
new file mode 100644
index 0000000..ad602ba
--- /dev/null
+++ b/dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-provider/src/main/resources/dubbo.properties
@@ -0,0 +1 @@
+dubbo.application.qos.port=22222
diff --git a/dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-provider/src/main/resources/log4j.properties b/dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-provider/src/main/resources/log4j.properties
new file mode 100644
index 0000000..15a0900
--- /dev/null
+++ b/dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-provider/src/main/resources/log4j.properties
@@ -0,0 +1,7 @@
+###set log levels###
+log4j.rootLogger=info, stdout
+###output to the console###
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=[%d{dd/MM/yy HH:mm:ss:SSS z}] %t %5p %c{2}: %m%n
\ No newline at end of file
diff --git a/dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-provider/src/main/resources/spring/dubbo-provider.xml b/dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-provider/src/main/resources/spring/dubbo-provider.xml
new file mode 100644
index 0000000..1eaf379
--- /dev/null
+++ b/dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-provider/src/main/resources/spring/dubbo-provider.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+  -->
+<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"
+       xmlns="http://www.springframework.org/schema/beans"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
+       http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd">
+
+    <dubbo:application name="demo-provider"/>
+
+    <dubbo:registry address="zookeeper://127.0.0.1:2181?registry.type=service"/>
+
+    <dubbo:protocol name="dubbo"/>
+
+    <bean id="demoService" class="org.apache.dubbo.demo.provider.DemoServiceImpl"/>
+
+    <dubbo:service interface="org.apache.dubbo.demo.DemoService" ref="demoService"/>
+
+</beans>
diff --git a/dubbo-demo/pom.xml b/dubbo-demo/pom.xml
index 4c03eda..a4dae32 100644
--- a/dubbo-demo/pom.xml
+++ b/dubbo-demo/pom.xml
@@ -35,7 +35,11 @@
         <module>dubbo-demo-xml</module>
         <module>dubbo-demo-annotation</module>
         <module>dubbo-demo-api</module>
+        <module>dubbo-demo-servicediscovery-xml</module>
+        <!--        <module>servicediscovery-transfer</module>-->
         <!--        <module>dubbo-call-sc</module>-->
+        <!--        <module>dubbo-call-sc&dubbo</module>-->
+        <!--        <module>sc-call-dubbo</module>-->
     </modules>
 
     <dependencyManagement>
diff --git a/dubbo-demo/servicediscovery-transfer/provider/src/main/java/org/apache/dubbo/demo/provider/GreetingServiceImpl.java b/dubbo-demo/servicediscovery-transfer/provider/src/main/java/org/apache/dubbo/demo/provider/GreetingServiceImpl.java
new file mode 100644
index 0000000..af86795
--- /dev/null
+++ b/dubbo-demo/servicediscovery-transfer/provider/src/main/java/org/apache/dubbo/demo/provider/GreetingServiceImpl.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.demo.provider;
+
+import org.apache.dubbo.demo.GreetingService;
+
+/**
+ *
+ */
+public class GreetingServiceImpl implements GreetingService {
+
+    @Override
+    public String hello() {
+        return "Greetings from server!";
+    }
+
+}
diff --git a/dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/pom.xml b/dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/pom.xml
new file mode 100644
index 0000000..dcf6e28
--- /dev/null
+++ b/dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/pom.xml
@@ -0,0 +1,84 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.dubbo</groupId>
+        <artifactId>servicediscovery-transfer</artifactId>
+        <version>${revision}</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+    <artifactId>servicediscovery-consumer</artifactId>
+    <packaging>jar</packaging>
+    <name>${project.artifactId}</name>
+    <description>The demo consumer module of dubbo project</description>
+    <properties>
+        <skip_maven_deploy>true</skip_maven_deploy>
+    </properties>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo-demo-interface</artifactId>
+            <version>${project.parent.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo-registry-multicast</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo-registry-nacos</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.alibaba.nacos</groupId>
+            <artifactId>nacos-client</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo-registry-zookeeper</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo-configcenter-zookeeper</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo-configcenter-nacos</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo-metadata-report-nacos</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo-config-spring</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo-rpc-dubbo</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo-remoting-netty4</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo-serialization-hessian2</artifactId>
+        </dependency>
+    </dependencies>
+</project>
diff --git a/dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/src/main/java/org/apache/dubbo/demo/consumer/Application.java b/dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/src/main/java/org/apache/dubbo/demo/consumer/Application.java
new file mode 100644
index 0000000..f448a18
--- /dev/null
+++ b/dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/src/main/java/org/apache/dubbo/demo/consumer/Application.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.demo.consumer;
+
+import org.apache.dubbo.demo.DemoService;
+
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class Application {
+    public static void main(String[] args) {
+        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/dubbo-consumer.xml");
+        context.start();
+        DemoService demoService = context.getBean("demoService", DemoService.class);
+        String hello = demoService.sayHello("world");
+        System.out.println("result: " + hello);
+    }
+}
diff --git a/dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/src/main/resources/dubbo.properties b/dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/src/main/resources/dubbo.properties
new file mode 100644
index 0000000..8c3cb25
--- /dev/null
+++ b/dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/src/main/resources/dubbo.properties
@@ -0,0 +1 @@
+dubbo.application.qos.port=33333
diff --git a/dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/src/main/resources/log4j.properties b/dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/src/main/resources/log4j.properties
new file mode 100644
index 0000000..2424381
--- /dev/null
+++ b/dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/src/main/resources/log4j.properties
@@ -0,0 +1,7 @@
+###set log levels###
+log4j.rootLogger=info, stdout
+###output to console###
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=[%d{dd/MM/yy HH:mm:ss:SSS z}] %t %5p %c{2}: %m%n
\ No newline at end of file
diff --git a/dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/src/main/resources/spring/dubbo-consumer.xml b/dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/src/main/resources/spring/dubbo-consumer.xml
new file mode 100644
index 0000000..d3081f6
--- /dev/null
+++ b/dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/src/main/resources/spring/dubbo-consumer.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+  -->
+<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"
+       xmlns="http://www.springframework.org/schema/beans"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
+       http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd">
+
+    <dubbo:application name="demo-consumer"/>
+
+    <dubbo:registry address="zookeeper://127.0.0.1:2181?registry.type=service"/>
+
+    <dubbo:reference id="demoService" check="false" interface="org.apache.dubbo.demo.DemoService"/>
+
+</beans>
diff --git a/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/WritableMetadataService.java b/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/WritableMetadataService.java
index e51fa2a..67ec3b7 100644
--- a/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/WritableMetadataService.java
+++ b/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/WritableMetadataService.java
@@ -106,20 +106,6 @@ public interface WritableMetadataService extends MetadataService {
         return getExtensionLoader(WritableMetadataService.class).getDefaultExtension();
     }
 
-    /**
-     * Get the metadata's storage type
-     *
-     * @param isDefaultStorageType is default storage type or not
-     * @return non-null, {@link #DEFAULT_METADATA_STORAGE_TYPE "default"} or {@link #REMOTE_METADATA_STORAGE_TYPE "remote"}
-     */
-    public static String getMetadataStorageType(boolean isDefaultStorageType) {
-        return isDefaultStorageType ? DEFAULT_METADATA_STORAGE_TYPE : REMOTE_METADATA_STORAGE_TYPE;
-    }
-
-    static WritableMetadataService getExtension(boolean isDefaultStorageType) {
-        return getExtension(getMetadataStorageType(isDefaultStorageType));
-    }
-
     static WritableMetadataService getExtension(String name) {
         return getExtensionLoader(WritableMetadataService.class).getOrDefaultExtension(name);
     }
diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/ServiceInstanceMetadataUtils.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/ServiceInstanceMetadataUtils.java
index 9367861..6eab648 100644
--- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/ServiceInstanceMetadataUtils.java
+++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/ServiceInstanceMetadataUtils.java
@@ -215,7 +215,7 @@ public class ServiceInstanceMetadataUtils {
      */
     public static String getDefaultMetadataStorageType() {
         return ConfigManager.getInstance().getApplication()
-                .map(ApplicationConfig::getMetadataStorageType)
+                .map(ApplicationConfig::getMetadataType)
                 .orElse(DEFAULT_METADATA_STORAGE_TYPE);
     }
 
@@ -223,11 +223,11 @@ public class ServiceInstanceMetadataUtils {
      * Set the metadata storage type in specified {@link ServiceInstance service instance}
      *
      * @param serviceInstance      {@link ServiceInstance service instance}
-     * @param isDefaultStorageType is default storage type or not
+     * @param metadataType remote or local
      */
-    public static void setMetadataStorageType(ServiceInstance serviceInstance, boolean isDefaultStorageType) {
+    public static void setMetadataStorageType(ServiceInstance serviceInstance, String metadataType) {
         Map<String, String> metadata = serviceInstance.getMetadata();
-        metadata.put(METADATA_STORAGE_TYPE_KEY, WritableMetadataService.getMetadataStorageType(isDefaultStorageType));
+        metadata.put(METADATA_STORAGE_TYPE_KEY, metadataType);
     }
 
     private static void setProviderHostParam(Map<String, String> params, URL providerURL) {