Skip to content

Commit

Permalink
support dubbo 3.0.8 (#903)
Browse files Browse the repository at this point in the history
  • Loading branch information
haoyann authored May 27, 2022
1 parent d8a49b1 commit 2353c81
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.apache.dubbo.registry.RegistryService;
import org.apache.dubbo.registry.client.ServiceDiscovery;
import org.apache.dubbo.registry.client.ServiceDiscoveryFactory;
import org.apache.dubbo.rpc.model.ApplicationModel;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand All @@ -46,6 +47,7 @@
import java.util.Arrays;

import static org.apache.dubbo.common.constants.CommonConstants.CLUSTER_KEY;
import static org.apache.dubbo.common.constants.RegistryConstants.ENABLE_EMPTY_PROTECTION_KEY;
import static org.apache.dubbo.registry.client.ServiceDiscoveryFactory.getExtension;

@Configuration
Expand Down Expand Up @@ -147,8 +149,8 @@ Registry getRegistry() {
}
registryUrl = formUrl(registryAddress, registryGroup, registryNameSpace, username, password);
}
RegistryFactory registryFactory = ExtensionLoader.getExtensionLoader(RegistryFactory.class).getAdaptiveExtension();
registry = registryFactory.getRegistry(registryUrl);
RegistryFactory registryFactory = ApplicationModel.defaultModel().getExtensionLoader(RegistryFactory.class).getAdaptiveExtension();
registry = registryFactory.getRegistry(registryUrl.addParameter(ENABLE_EMPTY_PROTECTION_KEY, String.valueOf(false)));
return registry;
}

Expand All @@ -166,7 +168,7 @@ MetaDataCollector getMetadataCollector() {
}
}
if (metadataUrl != null) {
metaDataCollector = ExtensionLoader.getExtensionLoader(MetaDataCollector.class).getExtension(metadataUrl.getProtocol());
metaDataCollector = ApplicationModel.defaultModel().getExtensionLoader(MetaDataCollector.class).getExtension(metadataUrl.getProtocol());
metaDataCollector.setUrl(metadataUrl);
metaDataCollector.init();
} else {
Expand All @@ -179,11 +181,10 @@ MetaDataCollector getMetadataCollector() {
@Bean(destroyMethod = "destroy")
@DependsOn("dubboRegistry")
ServiceDiscovery getServiceDiscoveryRegistry() throws Exception {
URL registryURL = registryUrl.setPath(RegistryService.class.getName());
URL registryURL = registryUrl.setPath(RegistryService.class.getName())
.addParameter(ENABLE_EMPTY_PROTECTION_KEY, String.valueOf(false));
ServiceDiscoveryFactory factory = getExtension(registryURL);
ServiceDiscovery serviceDiscovery = factory.getServiceDiscovery(registryURL);
serviceDiscovery.initialize(registryURL);
return serviceDiscovery;
return factory.getServiceDiscovery(registryURL);
}

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,8 @@ private String removeProtocol(String protocolServiceKey) {
}
}

@Override
public void stop() {
// ignore
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.apache.dubbo.metadata.MappingListener;
import org.apache.dubbo.remoting.zookeeper.ZookeeperClient;
import org.apache.dubbo.remoting.zookeeper.ZookeeperTransporter;
import org.apache.dubbo.rpc.model.ApplicationModel;

import java.util.List;
import java.util.Set;
Expand All @@ -45,7 +46,7 @@ public class ZookeeperServiceMapping implements ServiceMapping {

@Override
public void init(URL url) {
ZookeeperTransporter zookeeperTransporter = ZookeeperTransporter.getExtension();
ZookeeperTransporter zookeeperTransporter = ZookeeperTransporter.getExtension(ApplicationModel.defaultModel());
zkClient = zookeeperTransporter.connect(url);
listenerAll();
}
Expand Down
8 changes: 7 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,15 @@
<revision>0.4.0</revision>
<main.basedir>${project.basedir}</main.basedir>
<commons-lang3-version>3.7</commons-lang3-version>
<dubbo-version>3.0.2.1</dubbo-version>
<dubbo-version>3.0.8</dubbo-version>
<fastjson-version>1.2.67</fastjson-version>
<springfox-swagger-version>2.9.2</springfox-swagger-version>
<jacoco-version>0.8.2</jacoco-version>
<apollo-version>1.2.0</apollo-version>
<guava-version>20.0</guava-version>
<dubbo-mock-version>3.0.0</dubbo-mock-version>
<mybatis-plus-boot-version>3.4.2</mybatis-plus-boot-version>
<curator-test-veriosn>2.12.0</curator-test-veriosn>

<maven-checkstyle-plugin-version>3.0.0</maven-checkstyle-plugin-version>
<spring-boot-version>2.3.12.RELEASE</spring-boot-version>
Expand Down Expand Up @@ -143,6 +144,11 @@
<version>${mybatis-plus-boot-version}</version>
</dependency>

<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-test</artifactId>
<version>${curator-test-veriosn}</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down

0 comments on commit 2353c81

Please sign in to comment.