Skip to content

Commit

Permalink
put default version&group from provider and consumer into service met…
Browse files Browse the repository at this point in the history
…adata. (apache#6111)

* put default version&group from provider and consumer into service metadata.
  • Loading branch information
chickenlj authored May 13, 2020
1 parent 911bfa1 commit fe71a91
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 14 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ Apache Dubbo is a high-performance, Java based open source RPC framework. Please

We are now collecting dubbo user info in order to help us to improve Dubbo better, pls. kindly help us by providing yours on [issue#1012: Wanted: who's using dubbo](https://github.com/apache/dubbo/issues/1012), thanks :)

[使用文档](http://dubbo.apache.org/zh-cn/docs/user/new-features-in-a-glance.html)/[Documentation](http://dubbo.apache.org/en-us/docs/user/quick-start.html)

## Architecture

![Architecture](http://dubbo.apache.org/img/architecture.png)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,17 @@ protected void computeValidRegistryIds() {

@Parameter(excluded = true)
public String getUniqueServiceName() {
String group = StringUtils.isEmpty(this.group) ? consumer.getGroup() : this.group;
String version = StringUtils.isEmpty(this.version) ? consumer.getVersion() : this.version;
return URL.buildKey(interfaceName, group, version);
return URL.buildKey(interfaceName, getGroup(), getVersion());
}

@Override
public String getVersion() {
return StringUtils.isEmpty(this.version) ? (consumer != null ? consumer.getVersion() : this.version) : this.version;
}

@Override
public String getGroup() {
return StringUtils.isEmpty(this.group) ? (consumer != null ? consumer.getGroup() : this.group) : this.group;
}

public abstract T get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,9 +399,17 @@ public String getPrefix() {

@Parameter(excluded = true)
public String getUniqueServiceName() {
String group = StringUtils.isEmpty(this.group) ? provider.getGroup() : this.group;
String version = StringUtils.isEmpty(this.version) ? provider.getVersion() : this.version;
return URL.buildKey(interfaceName, group, version);
return URL.buildKey(interfaceName, getGroup(), getVersion());
}

@Override
public String getGroup() {
return StringUtils.isEmpty(this.group) ? (provider != null ? provider.getGroup() : this.group) : this.group;
}

@Override
public String getVersion() {
return StringUtils.isEmpty(this.version) ? (provider != null ? provider.getVersion() : this.version) : this.version;
}

private void computeValidProtocolIds() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,9 +399,9 @@ public void checkAndUpdateSubConfigs() {
}

//init serivceMetadata
serviceMetadata.setVersion(version);
serviceMetadata.setGroup(group);
serviceMetadata.setDefaultGroup(group);
serviceMetadata.setVersion(getVersion());
serviceMetadata.setGroup(getGroup());
serviceMetadata.setDefaultGroup(getGroup());
serviceMetadata.setServiceType(getActualInterface());
serviceMetadata.setServiceInterfaceName(interfaceName);
// TODO, uncomment this line once service key is unified
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,9 @@ public synchronized void export() {
checkAndUpdateSubConfigs();

//init serviceMetadata
serviceMetadata.setVersion(version);
serviceMetadata.setGroup(group);
serviceMetadata.setDefaultGroup(group);
serviceMetadata.setVersion(getVersion());
serviceMetadata.setGroup(getGroup());
serviceMetadata.setDefaultGroup(getGroup());
serviceMetadata.setServiceType(getInterfaceClass());
serviceMetadata.setServiceInterfaceName(getInterface());
serviceMetadata.setTarget(getRef());
Expand Down

0 comments on commit fe71a91

Please sign in to comment.