This is an automated email from the ASF dual-hosted git repository.
albumenj pushed a commit to branch 3.0
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/3.0 by this push:
new bb6d62b if user define interface service discovery, not publish
service name mapping info (#8179)
bb6d62b is described below
commit bb6d62b858afaa6fc1d63d1ac0ed3ba3a2f024a9
Author: 赵延 <[email protected]>
AuthorDate: Fri Jul 2 11:36:48 2021 +0800
if user define interface service discovery, not publish service name
mapping info (#8179)
* if user define interface service discovery, not use service name mapping.
* use service name mapping key to avoid logic conflict.
---
.../org/apache/dubbo/common/constants/CommonConstants.java | 2 ++
.../src/main/java/org/apache/dubbo/config/ServiceConfig.java | 12 ++++++++++--
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git
a/dubbo-common/src/main/java/org/apache/dubbo/common/constants/CommonConstants.java
b/dubbo-common/src/main/java/org/apache/dubbo/common/constants/CommonConstants.java
index 61c3fc6..4538574 100644
---
a/dubbo-common/src/main/java/org/apache/dubbo/common/constants/CommonConstants.java
+++
b/dubbo-common/src/main/java/org/apache/dubbo/common/constants/CommonConstants.java
@@ -428,4 +428,6 @@ public interface CommonConstants {
* Url merge processor key
*/
String URL_MERGE_PROCESSOR_KEY = "url-merge-processor";
+
+ String SERVICE_NAME_MAPPING_KEY = "service-name-mapping";
}
diff --git
a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java
b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java
index f681e27..3382e49 100644
---
a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java
+++
b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java
@@ -79,8 +79,10 @@ import static
org.apache.dubbo.common.constants.CommonConstants.PROVIDER_SIDE;
import static org.apache.dubbo.common.constants.CommonConstants.REGISTER_KEY;
import static
org.apache.dubbo.common.constants.CommonConstants.REMOTE_METADATA_STORAGE_TYPE;
import static org.apache.dubbo.common.constants.CommonConstants.REVISION_KEY;
+import static
org.apache.dubbo.common.constants.CommonConstants.SERVICE_NAME_MAPPING_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.SIDE_KEY;
import static org.apache.dubbo.common.constants.RegistryConstants.DYNAMIC_KEY;
+import static
org.apache.dubbo.common.constants.RegistryConstants.SERVICE_REGISTRY_PROTOCOL;
import static org.apache.dubbo.common.utils.NetUtils.getAvailablePort;
import static org.apache.dubbo.common.utils.NetUtils.getLocalHost;
import static org.apache.dubbo.common.utils.NetUtils.isInvalidLocalHost;
@@ -241,8 +243,10 @@ public class ServiceConfig<T> extends ServiceConfigBase<T>
{
exported = true;
List<URL> exportedURLs = this.getExportedUrls();
exportedURLs.forEach(url -> {
- ServiceNameMapping serviceNameMapping =
ServiceNameMapping.getDefaultExtension();
- serviceNameMapping.map(url);
+ if (url.getParameters().containsKey(SERVICE_NAME_MAPPING_KEY)) {
+ ServiceNameMapping serviceNameMapping =
ServiceNameMapping.getDefaultExtension();
+ serviceNameMapping.map(url);
+ }
});
onExported();
}
@@ -502,6 +506,10 @@ public class ServiceConfig<T> extends ServiceConfigBase<T>
{
if (!SCOPE_LOCAL.equalsIgnoreCase(scope)) {
if (CollectionUtils.isNotEmpty(registryURLs)) {
for (URL registryURL : registryURLs) {
+ if
(SERVICE_REGISTRY_PROTOCOL.equals(registryURL.getProtocol())) {
+ url =
url.addParameterIfAbsent(SERVICE_NAME_MAPPING_KEY, "true");
+ }
+
//if protocol is only injvm ,not register
if
(LOCAL_PROTOCOL.equalsIgnoreCase(url.getProtocol())) {
continue;