diff --git a/dubbo-compatible/pom.xml b/dubbo-compatible/pom.xml
index c72eddeaca..9d6f462ecd 100644
--- a/dubbo-compatible/pom.xml
+++ b/dubbo-compatible/pom.xml
@@ -43,16 +43,6 @@
dubbo-qos
${project.parent.version}
-
- org.apache.dubbo
- dubbo-remoting-http
- ${project.parent.version}
-
-
- org.apache.dubbo
- dubbo-remoting-p2p
- ${project.parent.version}
-
org.apache.dubbo
dubbo-remoting-zookeeper
@@ -63,11 +53,6 @@
dubbo-rpc-rest
${project.parent.version}
-
- org.apache.dubbo
- dubbo-rpc-thrift
- ${project.parent.version}
-
org.apache.dubbo
dubbo-filter-cache
diff --git a/dubbo-config/dubbo-config-api/pom.xml b/dubbo-config/dubbo-config-api/pom.xml
index f5cfd34c97..86880ebbf1 100644
--- a/dubbo-config/dubbo-config-api/pom.xml
+++ b/dubbo-config/dubbo-config-api/pom.xml
@@ -71,20 +71,6 @@
test
-
- org.apache.dubbo
- dubbo-rpc-rmi
- ${project.parent.version}
- test
-
-
-
- org.apache.dubbo
- dubbo-rpc-hessian
- ${project.parent.version}
- test
-
-
org.apache.dubbo
dubbo-remoting-netty4
@@ -120,33 +106,6 @@
test
-
- org.apache.dubbo
- dubbo-registry-eureka
- ${project.parent.version}
- test
-
-
- com.google.guava
- guava
-
-
-
-
-
- org.apache.dubbo
- dubbo-registry-etcd3
- ${project.parent.version}
- test
-
-
-
- org.apache.dubbo
- dubbo-registry-consul
- ${project.parent.version}
- test
-
-
org.apache.dubbo
dubbo-metadata-report-zookeeper
@@ -160,33 +119,6 @@
-
- org.apache.dubbo
- dubbo-metadata-report-etcd
- ${project.parent.version}
- test
-
-
-
- org.apache.dubbo
- dubbo-metadata-report-nacos
- ${project.parent.version}
- test
-
-
- com.google.guava
- guava
-
-
-
-
-
- org.apache.dubbo
- dubbo-metadata-report-consul
- ${project.parent.version}
- test
-
-
org.apache.dubbo
dubbo-metadata-report-redis
@@ -214,13 +146,6 @@
-
- org.apache.dubbo
- dubbo-configcenter-consul
- ${project.parent.version}
- test
-
-
org.apache.dubbo
dubbo-filter-cache
diff --git a/dubbo-config/dubbo-config-spring/pom.xml b/dubbo-config/dubbo-config-spring/pom.xml
index 31bfcf4c14..c1255cce11 100644
--- a/dubbo-config/dubbo-config-spring/pom.xml
+++ b/dubbo-config/dubbo-config-spring/pom.xml
@@ -64,12 +64,6 @@
1.9.5
test
-
- org.apache.dubbo
- dubbo-registry-default
- ${project.parent.version}
- test
-
org.apache.dubbo
dubbo-monitor-default
@@ -82,12 +76,6 @@
${project.parent.version}
test
-
- org.apache.dubbo
- dubbo-rpc-rmi
- ${project.parent.version}
- test
-
org.apache.dubbo
dubbo-rpc-injvm
diff --git a/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-consumer/pom.xml b/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-consumer/pom.xml
index 6dd31d2942..c48478ac59 100644
--- a/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-consumer/pom.xml
+++ b/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-consumer/pom.xml
@@ -63,10 +63,6 @@
org.apache.dubbo
dubbo-configcenter-nacos
-
- org.apache.dubbo
- dubbo-metadata-report-nacos
-
org.apache.dubbo
dubbo-rpc-dubbo
diff --git a/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-provider/pom.xml b/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-provider/pom.xml
index 27186ea7be..b78ec15492 100644
--- a/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-provider/pom.xml
+++ b/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-provider/pom.xml
@@ -64,10 +64,6 @@
org.apache.dubbo
dubbo-configcenter-nacos
-
- org.apache.dubbo
- dubbo-metadata-report-nacos
-
org.apache.dubbo
dubbo-rpc-dubbo
diff --git a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-consumer/pom.xml b/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-consumer/pom.xml
index b3a4accb3f..fffa2bd1c1 100644
--- a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-consumer/pom.xml
+++ b/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-consumer/pom.xml
@@ -63,10 +63,6 @@
org.apache.dubbo
dubbo-configcenter-nacos
-
- org.apache.dubbo
- dubbo-metadata-report-nacos
-
org.apache.dubbo
dubbo-config-spring
diff --git a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-provider/pom.xml b/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-provider/pom.xml
index c4590c2671..20e3b529f7 100644
--- a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-provider/pom.xml
+++ b/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-provider/pom.xml
@@ -62,10 +62,6 @@
org.apache.dubbo
dubbo-configcenter-nacos
-
- org.apache.dubbo
- dubbo-metadata-report-nacos
-
org.apache.dubbo
dubbo-metadata-report-zookeeper
diff --git a/dubbo-distribution/dubbo-bom/pom.xml b/dubbo-distribution/dubbo-bom/pom.xml
index afd52bddab..d3c1b3305e 100644
--- a/dubbo-distribution/dubbo-bom/pom.xml
+++ b/dubbo-distribution/dubbo-bom/pom.xml
@@ -83,31 +83,6 @@
dubbo-remoting-netty4
${project.version}
-
- org.apache.dubbo
- dubbo-remoting-mina
- ${project.version}
-
-
- org.apache.dubbo
- dubbo-remoting-grizzly
- ${project.version}
-
-
- org.apache.dubbo
- dubbo-remoting-p2p
- ${project.version}
-
-
- org.apache.dubbo
- dubbo-remoting-http
- ${project.version}
-
-
- org.apache.dubbo
- dubbo-remoting-etcd3
- ${project.version}
-
org.apache.dubbo
dubbo-rpc-api
@@ -123,56 +98,11 @@
dubbo-rpc-injvm
${project.version}
-
- org.apache.dubbo
- dubbo-rpc-http
- ${project.version}
-
-
- org.apache.dubbo
- dubbo-rpc-rmi
- ${project.version}
-
-
- org.apache.dubbo
- dubbo-rpc-hessian
- ${project.version}
-
-
- org.apache.dubbo
- dubbo-rpc-webservice
- ${project.version}
-
-
- org.apache.dubbo
- dubbo-rpc-thrift
- ${project.version}
-
-
- org.apache.dubbo
- dubbo-rpc-native-thrift
- ${project.version}
-
-
- org.apache.dubbo
- dubbo-rpc-memcached
- ${project.version}
-
-
- org.apache.dubbo
- dubbo-rpc-redis
- ${project.version}
-
org.apache.dubbo
dubbo-rpc-rest
${project.version}
-
- org.apache.dubbo
- dubbo-rpc-xml
- ${project.version}
-
org.apache.dubbo
dubbo-rpc-grpc
@@ -185,7 +115,7 @@
org.apache.dubbo
- dubbo-registry-default
+ dubbo-registry-multiple
${project.version}
@@ -198,31 +128,11 @@
dubbo-registry-zookeeper
${project.version}
-
- org.apache.dubbo
- dubbo-registry-redis
- ${project.version}
-
-
- org.apache.dubbo
- dubbo-registry-etcd3
- ${project.version}
-
-
- org.apache.dubbo
- dubbo-registry-consul
- ${project.version}
-
org.apache.dubbo
dubbo-registry-nacos
${project.version}
-
- org.apache.dubbo
- dubbo-registry-sofa
- ${project.version}
-
org.apache.dubbo
dubbo-monitor-api
@@ -233,21 +143,16 @@
dubbo-monitor-default
${project.version}
+
+ org.apache.dubbo
+ dubbo-container-api
+ ${project.version}
+
org.apache.dubbo
dubbo-container-spring
${project.version}
-
- org.apache.dubbo
- dubbo-container-log4j
- ${project.version}
-
-
- org.apache.dubbo
- dubbo-container-logback
- ${project.version}
-
org.apache.dubbo
dubbo-qos
@@ -258,61 +163,22 @@
dubbo-serialization-api
${project.version}
-
- org.apache.dubbo
- dubbo-serialization-fastjson
- ${project.version}
-
-
- org.apache.dubbo
- dubbo-serialization-fst
- ${project.version}
-
org.apache.dubbo
dubbo-serialization-hessian2
${project.version}
-
- org.apache.dubbo
- dubbo-serialization-native-hession
- ${project.version}
-
org.apache.dubbo
dubbo-serialization-jdk
${project.version}
-
- org.apache.dubbo
- dubbo-serialization-kryo
- ${project.version}
-
-
- org.apache.dubbo
- dubbo-serialization-protostuff
- ${project.version}
-
-
- org.apache.dubbo
- dubbo-serialization-avro
- ${project.version}
-
-
- org.apache.dubbo
- dubbo-serialization-gson
- ${project.version}
-
-
- org.apache.dubbo
- dubbo-serialization-protobuf
- ${project.version}
-
org.apache.dubbo
dubbo-compatible
${project.version}
+
org.apache.dubbo
@@ -331,17 +197,12 @@
org.apache.dubbo
- dubbo-metadata-report-consul
+ dubbo-metadata-processor
${project.version}
org.apache.dubbo
- dubbo-metadata-report-etcd
- ${project.version}
-
-
- org.apache.dubbo
- dubbo-metadata-report-nacos
+ dubbo-metadata-definition-protobuf
${project.version}
@@ -356,26 +217,11 @@
dubbo-configcenter-apollo
${project.version}
-
- org.apache.dubbo
- dubbo-configcenter-consul
- ${project.version}
-
-
- org.apache.dubbo
- dubbo-configcenter-etcd
- ${project.version}
-
org.apache.dubbo
dubbo-configcenter-nacos
${project.version}
-
- org.apache.dubbo
- dubbo-metadata-definition-protobuf
- ${project.version}
-
diff --git a/dubbo-distribution/pom.xml b/dubbo-distribution/pom.xml
index 2dc703e939..a28d3f426d 100644
--- a/dubbo-distribution/pom.xml
+++ b/dubbo-distribution/pom.xml
@@ -45,6 +45,7 @@
dubbo-all
+ dubbo-bom
diff --git a/dubbo-registry/dubbo-registry-multiple/pom.xml b/dubbo-registry/dubbo-registry-multiple/pom.xml
index 1b5dac4381..e4c5165a63 100644
--- a/dubbo-registry/dubbo-registry-multiple/pom.xml
+++ b/dubbo-registry/dubbo-registry-multiple/pom.xml
@@ -41,12 +41,6 @@
${project.parent.version}
test
-
- org.apache.dubbo
- dubbo-registry-redis
- ${project.parent.version}
- test
-
org.apache.curator
curator-test
diff --git a/dubbo-registry/dubbo-registry-multiple/src/test/java/org/apache/dubbo/registry/multiple/MultipleRegistry2S2RTest.java b/dubbo-registry/dubbo-registry-multiple/src/test/java/org/apache/dubbo/registry/multiple/MultipleRegistry2S2RTest.java
index 924373087e..0dafdab0bf 100644
--- a/dubbo-registry/dubbo-registry-multiple/src/test/java/org/apache/dubbo/registry/multiple/MultipleRegistry2S2RTest.java
+++ b/dubbo-registry/dubbo-registry-multiple/src/test/java/org/apache/dubbo/registry/multiple/MultipleRegistry2S2RTest.java
@@ -16,12 +16,10 @@
*/
package org.apache.dubbo.registry.multiple;
-import org.apache.commons.lang3.SystemUtils;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.utils.NetUtils;
import org.apache.dubbo.registry.NotifyListener;
import org.apache.dubbo.registry.Registry;
-import org.apache.dubbo.registry.redis.RedisRegistry;
import org.apache.dubbo.registry.zookeeper.ZookeeperRegistry;
import org.apache.dubbo.remoting.zookeeper.ZookeeperClient;
import org.apache.dubbo.remoting.zookeeper.curator.CuratorZookeeperClient;
@@ -31,8 +29,6 @@ import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
-import redis.embedded.RedisServer;
-import redis.embedded.RedisServerBuilder;
import java.util.ArrayList;
import java.util.List;
@@ -46,19 +42,20 @@ public class MultipleRegistry2S2RTest {
private static final String SERVICE2_NAME = "org.apache.dubbo.registry.MultipleService2S2R2";
private static TestingServer zkServer;
- private static RedisServer redisServer;
+ private static TestingServer zkServer2;
static int zkServerPort;
- static int redisServerPort;
+ static int zkServerPort2;
private static String zookeeperRegistryURLStr;
- private static String redisRegistryURLStr;
+ private static String zookeeperRegistryURLStr2;
private static MultipleRegistry multipleRegistry;
// for test content
private static ZookeeperClient zookeeperClient;
+ private static ZookeeperClient zookeeperClient2;
private static ZookeeperRegistry zookeeperRegistry;
- private static RedisRegistry redisRegistry;
+ private static ZookeeperRegistry zookeeperRegistry2;
@BeforeAll
@@ -67,32 +64,27 @@ public class MultipleRegistry2S2RTest {
zkServer = new TestingServer(zkServerPort, true);
zookeeperRegistryURLStr = "zookeeper://127.0.0.1:" + zkServerPort;
- redisServerPort = NetUtils.getAvailablePort();
- RedisServerBuilder builder = RedisServer.builder().port(redisServerPort);
- if (SystemUtils.IS_OS_WINDOWS) {
- // set maxheap to fix Windows error 0x70 while starting redis
- builder.setting("maxheap 128mb");
- }
- redisServer = builder.build();
- redisServer.start();
- redisRegistryURLStr = "redis://127.0.0.1:" + redisServerPort;
+ zkServerPort2 = NetUtils.getAvailablePort();
+ zkServer2 = new TestingServer(zkServerPort2, true);
+ zookeeperRegistryURLStr2 = "zookeeper://127.0.0.1:" + zkServerPort2;
URL url = URL.valueOf("multiple://127.0.0.1?application=vic&" +
- MultipleRegistry.REGISTRY_FOR_SERVICE + "=" + zookeeperRegistryURLStr + "," + redisRegistryURLStr + "&"
- + MultipleRegistry.REGISTRY_FOR_REFERENCE + "=" + zookeeperRegistryURLStr + "," + redisRegistryURLStr);
+ MultipleRegistry.REGISTRY_FOR_SERVICE + "=" + zookeeperRegistryURLStr + "," + zookeeperRegistryURLStr2 + "&"
+ + MultipleRegistry.REGISTRY_FOR_REFERENCE + "=" + zookeeperRegistryURLStr + "," + zookeeperRegistryURLStr2);
multipleRegistry = (MultipleRegistry) new MultipleRegistryFactory().createRegistry(url);
// for test validation
zookeeperClient = new CuratorZookeeperClient(URL.valueOf(zookeeperRegistryURLStr));
zookeeperRegistry = MultipleRegistryTestUtil.getZookeeperRegistry(multipleRegistry.getServiceRegistries().values());
- redisRegistry = MultipleRegistryTestUtil.getRedisRegistry(multipleRegistry.getServiceRegistries().values());
+ zookeeperClient2 = new CuratorZookeeperClient(URL.valueOf(zookeeperRegistryURLStr2));
+ zookeeperRegistry2 = MultipleRegistryTestUtil.getZookeeperRegistry(multipleRegistry.getServiceRegistries().values());
}
@AfterAll
public static void tearDown() throws Exception {
zkServer.stop();
- redisServer.stop();
+ zkServer2.stop();
}
@Test
@@ -100,36 +92,34 @@ public class MultipleRegistry2S2RTest {
Assertions.assertEquals(2, multipleRegistry.origReferenceRegistryURLs.size());
Assertions.assertTrue(multipleRegistry.origReferenceRegistryURLs.contains(zookeeperRegistryURLStr));
- Assertions.assertTrue(multipleRegistry.origReferenceRegistryURLs.contains(redisRegistryURLStr));
+ Assertions.assertTrue(multipleRegistry.origReferenceRegistryURLs.contains(zookeeperRegistryURLStr2));
Assertions.assertEquals(2, multipleRegistry.origServiceRegistryURLs.size());
Assertions.assertTrue(multipleRegistry.origServiceRegistryURLs.contains(zookeeperRegistryURLStr));
- Assertions.assertTrue(multipleRegistry.origServiceRegistryURLs.contains(redisRegistryURLStr));
+ Assertions.assertTrue(multipleRegistry.origServiceRegistryURLs.contains(zookeeperRegistryURLStr2));
Assertions.assertEquals(2, multipleRegistry.effectReferenceRegistryURLs.size());
Assertions.assertTrue(multipleRegistry.effectReferenceRegistryURLs.contains(zookeeperRegistryURLStr));
- Assertions.assertTrue(multipleRegistry.effectReferenceRegistryURLs.contains(redisRegistryURLStr));
+ Assertions.assertTrue(multipleRegistry.effectReferenceRegistryURLs.contains(zookeeperRegistryURLStr2));
Assertions.assertEquals(2, multipleRegistry.effectServiceRegistryURLs.size());
Assertions.assertTrue(multipleRegistry.effectServiceRegistryURLs.contains(zookeeperRegistryURLStr));
- Assertions.assertTrue(multipleRegistry.effectServiceRegistryURLs.contains(redisRegistryURLStr));
+ Assertions.assertTrue(multipleRegistry.effectServiceRegistryURLs.contains(zookeeperRegistryURLStr2));
Assertions.assertTrue(multipleRegistry.getServiceRegistries().containsKey(zookeeperRegistryURLStr));
- Assertions.assertTrue(multipleRegistry.getServiceRegistries().containsKey(redisRegistryURLStr));
+ Assertions.assertTrue(multipleRegistry.getServiceRegistries().containsKey(zookeeperRegistryURLStr2));
Assertions.assertEquals(2, multipleRegistry.getServiceRegistries().values().size());
// java.util.Iterator registryIterable = multipleRegistry.getServiceRegistries().values().iterator();
// Registry firstRegistry = registryIterable.next();
// Registry secondRegistry = registryIterable.next();
Assertions.assertNotNull(MultipleRegistryTestUtil.getZookeeperRegistry(multipleRegistry.getServiceRegistries().values()));
- Assertions.assertNotNull(MultipleRegistryTestUtil.getRedisRegistry(multipleRegistry.getServiceRegistries().values()));
Assertions.assertNotNull(MultipleRegistryTestUtil.getZookeeperRegistry(multipleRegistry.getReferenceRegistries().values()));
- Assertions.assertNotNull(MultipleRegistryTestUtil.getRedisRegistry(multipleRegistry.getReferenceRegistries().values()));
Assertions.assertEquals(MultipleRegistryTestUtil.getZookeeperRegistry(multipleRegistry.getServiceRegistries().values()),
MultipleRegistryTestUtil.getZookeeperRegistry(multipleRegistry.getReferenceRegistries().values()));
- Assertions.assertEquals(MultipleRegistryTestUtil.getRedisRegistry(multipleRegistry.getServiceRegistries().values()),
- MultipleRegistryTestUtil.getRedisRegistry(multipleRegistry.getReferenceRegistries().values()));
+ Assertions.assertEquals(MultipleRegistryTestUtil.getZookeeperRegistry(multipleRegistry.getServiceRegistries().values()),
+ MultipleRegistryTestUtil.getZookeeperRegistry(multipleRegistry.getReferenceRegistries().values()));
Assertions.assertEquals(multipleRegistry.getApplicationName(), "vic");
@@ -147,8 +137,6 @@ public class MultipleRegistry2S2RTest {
Assertions.assertTrue(!providerList.isEmpty());
System.out.println(providerList.get(0));
- Assertions.assertNotNull(MultipleRegistryTestUtil.getRedisHashContent(redisServerPort, path, serviceUrl.toFullString()));
-
final List list = new ArrayList();
multipleRegistry.subscribe(serviceUrl, new NotifyListener() {
@Override
@@ -180,8 +168,6 @@ public class MultipleRegistry2S2RTest {
Assertions.assertTrue(!providerList.isEmpty());
System.out.println(providerList.get(0));
- Assertions.assertNotNull(MultipleRegistryTestUtil.getRedisHashContent(redisServerPort, path, serviceUrl.toFullString()));
-
final List list = new ArrayList();
multipleRegistry.subscribe(serviceUrl, new NotifyListener() {
@Override
diff --git a/dubbo-registry/dubbo-registry-multiple/src/test/java/org/apache/dubbo/registry/multiple/MultipleRegistryTestUtil.java b/dubbo-registry/dubbo-registry-multiple/src/test/java/org/apache/dubbo/registry/multiple/MultipleRegistryTestUtil.java
index 9544ef800b..a0aeef2e2d 100644
--- a/dubbo-registry/dubbo-registry-multiple/src/test/java/org/apache/dubbo/registry/multiple/MultipleRegistryTestUtil.java
+++ b/dubbo-registry/dubbo-registry-multiple/src/test/java/org/apache/dubbo/registry/multiple/MultipleRegistryTestUtil.java
@@ -21,11 +21,7 @@ import org.apache.dubbo.common.utils.StringUtils;
import org.apache.dubbo.common.utils.UrlUtils;
import org.apache.dubbo.registry.ListenerRegistryWrapper;
import org.apache.dubbo.registry.Registry;
-import org.apache.dubbo.registry.redis.RedisRegistry;
import org.apache.dubbo.registry.zookeeper.ZookeeperRegistry;
-import org.apache.dubbo.rpc.RpcException;
-
-import redis.clients.jedis.Jedis;
import java.util.Collection;
import java.util.Collections;
@@ -60,46 +56,6 @@ public class MultipleRegistryTestUtil {
return null;
}
- public static RedisRegistry getRedisRegistry(Collection registryCollection) {
- for (Registry registry : registryCollection) {
- if (registry instanceof ListenerRegistryWrapper) {
- registry = ((ListenerRegistryWrapper) registry).getRegistry();
- }
- if (registry instanceof RedisRegistry) {
- return (RedisRegistry) registry;
- }
- }
- return null;
- }
-
- public static String getRedisContent(int port, String key) {
- Jedis jedis = null;
- try {
- jedis = new Jedis("127.0.0.1", port);
- return jedis.get(key);
- } catch (Throwable e) {
- throw new RpcException("Failed to put to redis . cause: " + e.getMessage(), e);
- } finally {
- if (jedis != null) {
- jedis.close();
- }
- }
- }
-
- public static String getRedisHashContent(int port, String key, String field) {
- Jedis jedis = null;
- try {
- jedis = new Jedis("127.0.0.1", port);
- return jedis.hget(key, field);
- } catch (Throwable e) {
- throw new RpcException("Failed to put to redis . cause: " + e.getMessage(), e);
- } finally {
- if (jedis != null) {
- jedis.close();
- }
- }
- }
-
/**
* copy from @org.apache.dubbo.registry.integration.RegistryDirectory#notify(java.util.List)
*
diff --git a/dubbo-remoting/dubbo-remoting-http/pom.xml b/dubbo-remoting/dubbo-remoting-http/pom.xml
new file mode 100644
index 0000000000..b4abaea5ec
--- /dev/null
+++ b/dubbo-remoting/dubbo-remoting-http/pom.xml
@@ -0,0 +1,63 @@
+
+
+ 4.0.0
+
+ org.apache.dubbo
+ dubbo-remoting
+ ${revision}
+ ../pom.xml
+
+ dubbo-remoting-http
+ jar
+ ${project.artifactId}
+ The http remoting module of dubbo project
+
+ false
+
+
+
+ org.apache.dubbo
+ dubbo-common
+ ${project.parent.version}
+
+
+ org.apache.dubbo
+ dubbo-remoting-api
+ ${project.parent.version}
+
+
+ org.eclipse.jetty
+ jetty-server
+
+
+ org.eclipse.jetty
+ jetty-servlet
+
+
+ org.apache.tomcat.embed
+ tomcat-embed-core
+
+
+ org.apache.httpcomponents
+ fluent-hc
+ 4.5.5
+ test
+
+
+
\ No newline at end of file
diff --git a/dubbo-compatible/src/main/java/com/alibaba/dubbo/remoting/p2p/Networker.java b/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/HttpBinder.java
similarity index 62%
rename from dubbo-compatible/src/main/java/com/alibaba/dubbo/remoting/p2p/Networker.java
rename to dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/HttpBinder.java
index a2f9f41d21..031139dff1 100644
--- a/dubbo-compatible/src/main/java/com/alibaba/dubbo/remoting/p2p/Networker.java
+++ b/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/HttpBinder.java
@@ -14,9 +14,26 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+package org.apache.dubbo.remoting.http;
-package com.alibaba.dubbo.remoting.p2p;
+import org.apache.dubbo.common.URL;
+import org.apache.dubbo.common.extension.Adaptive;
+import org.apache.dubbo.common.extension.SPI;
+import org.apache.dubbo.remoting.Constants;
+
+/**
+ * HttpBinder
+ */
+@SPI("jetty")
+public interface HttpBinder {
+
+ /**
+ * bind the server.
+ *
+ * @param url server url.
+ * @return server.
+ */
+ @Adaptive({Constants.SERVER_KEY})
+ HttpServer bind(URL url, HttpHandler handler);
-@Deprecated
-public interface Networker extends org.apache.dubbo.remoting.p2p.Networker {
}
diff --git a/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/HttpHandler.java b/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/HttpHandler.java
new file mode 100644
index 0000000000..c8cd21781b
--- /dev/null
+++ b/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/HttpHandler.java
@@ -0,0 +1,39 @@
+/*
+ * 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.remoting.http;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ * http invocation handler.
+ */
+public interface HttpHandler {
+
+ /**
+ * invoke.
+ *
+ * @param request request.
+ * @param response response.
+ * @throws IOException
+ * @throws ServletException
+ */
+ void handle(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException;
+
+}
\ No newline at end of file
diff --git a/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/HttpServer.java b/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/HttpServer.java
new file mode 100644
index 0000000000..2cc6766af3
--- /dev/null
+++ b/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/HttpServer.java
@@ -0,0 +1,72 @@
+/*
+ * 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.remoting.http;
+
+import org.apache.dubbo.common.Resetable;
+import org.apache.dubbo.common.URL;
+import org.apache.dubbo.remoting.RemotingServer;
+
+import java.net.InetSocketAddress;
+
+public interface HttpServer extends Resetable, RemotingServer {
+
+ /**
+ * get http handler.
+ *
+ * @return http handler.
+ */
+ HttpHandler getHttpHandler();
+
+ /**
+ * get url.
+ *
+ * @return url
+ */
+ URL getUrl();
+
+ /**
+ * get local address.
+ *
+ * @return local address.
+ */
+ InetSocketAddress getLocalAddress();
+
+ /**
+ * close the channel.
+ */
+ void close();
+
+ /**
+ * Graceful close the channel.
+ */
+ void close(int timeout);
+
+ /**
+ * is bound.
+ *
+ * @return bound
+ */
+ boolean isBound();
+
+ /**
+ * is closed.
+ *
+ * @return closed
+ */
+ boolean isClosed();
+
+}
\ No newline at end of file
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/consumer/DemoActionBySetter.java b/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/jetty/JettyHttpBinder.java
similarity index 65%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/consumer/DemoActionBySetter.java
rename to dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/jetty/JettyHttpBinder.java
index 0606e262b5..9a41285684 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/consumer/DemoActionBySetter.java
+++ b/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/jetty/JettyHttpBinder.java
@@ -14,23 +14,21 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.config.consumer;
+package org.apache.dubbo.remoting.http.jetty;
-import org.apache.dubbo.config.api.DemoService;
+import org.apache.dubbo.common.URL;
+import org.apache.dubbo.remoting.http.HttpBinder;
+import org.apache.dubbo.remoting.http.HttpHandler;
+import org.apache.dubbo.remoting.http.HttpServer;
/**
- * DemoAction
+ * JettyHttpTransporter
*/
-public class DemoActionBySetter {
+public class JettyHttpBinder implements HttpBinder {
- private DemoService demoService;
-
- public DemoService getDemoService() {
- return demoService;
+ @Override
+ public HttpServer bind(URL url, HttpHandler handler) {
+ return new JettyHttpServer(url, handler);
}
- public void setDemoService(DemoService demoService) {
- this.demoService = demoService;
- }
-
-}
\ No newline at end of file
+}
diff --git a/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/jetty/JettyHttpServer.java b/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/jetty/JettyHttpServer.java
new file mode 100644
index 0000000000..4a188967b8
--- /dev/null
+++ b/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/jetty/JettyHttpServer.java
@@ -0,0 +1,112 @@
+/*
+ * 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.remoting.http.jetty;
+
+import org.apache.dubbo.common.URL;
+import org.apache.dubbo.common.logger.Logger;
+import org.apache.dubbo.common.logger.LoggerFactory;
+import org.apache.dubbo.common.utils.NetUtils;
+import org.apache.dubbo.remoting.Constants;
+import org.apache.dubbo.remoting.http.HttpHandler;
+import org.apache.dubbo.remoting.http.servlet.DispatcherServlet;
+import org.apache.dubbo.remoting.http.servlet.ServletManager;
+import org.apache.dubbo.remoting.http.support.AbstractHttpServer;
+
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.ServerConnector;
+import org.eclipse.jetty.servlet.ServletContextHandler;
+import org.eclipse.jetty.servlet.ServletHandler;
+import org.eclipse.jetty.servlet.ServletHolder;
+import org.eclipse.jetty.util.log.Log;
+import org.eclipse.jetty.util.log.StdErrLog;
+import org.eclipse.jetty.util.thread.QueuedThreadPool;
+
+import static org.apache.dubbo.common.constants.CommonConstants.DEFAULT_THREADS;
+import static org.apache.dubbo.common.constants.CommonConstants.THREADS_KEY;
+
+public class JettyHttpServer extends AbstractHttpServer {
+
+ private static final Logger logger = LoggerFactory.getLogger(JettyHttpServer.class);
+
+ private Server server;
+
+ private URL url;
+
+ public JettyHttpServer(URL url, final HttpHandler handler) {
+ super(url, handler);
+ this.url = url;
+ // TODO we should leave this setting to slf4j
+ // we must disable the debug logging for production use
+ Log.setLog(new StdErrLog());
+ Log.getLog().setDebugEnabled(false);
+
+ DispatcherServlet.addHttpHandler(url.getParameter(Constants.BIND_PORT_KEY, url.getPort()), handler);
+
+ int threads = url.getParameter(THREADS_KEY, DEFAULT_THREADS);
+ QueuedThreadPool threadPool = new QueuedThreadPool();
+ threadPool.setDaemon(true);
+ threadPool.setMaxThreads(threads);
+ threadPool.setMinThreads(threads);
+
+ server = new Server(threadPool);
+
+ ServerConnector connector = new ServerConnector(server);
+
+ String bindIp = url.getParameter(Constants.BIND_IP_KEY, url.getHost());
+ if (!url.isAnyHost() && NetUtils.isValidLocalHost(bindIp)) {
+ connector.setHost(bindIp);
+ }
+ connector.setPort(url.getParameter(Constants.BIND_PORT_KEY, url.getPort()));
+
+ server.addConnector(connector);
+
+ ServletHandler servletHandler = new ServletHandler();
+ ServletHolder servletHolder = servletHandler.addServletWithMapping(DispatcherServlet.class, "/*");
+ servletHolder.setInitOrder(2);
+
+ // dubbo's original impl can't support the use of ServletContext
+ // server.addHandler(servletHandler);
+ // TODO Context.SESSIONS is the best option here? (In jetty 9.x, it becomes ServletContextHandler.SESSIONS)
+ ServletContextHandler context = new ServletContextHandler(server, "/", ServletContextHandler.SESSIONS);
+ context.setServletHandler(servletHandler);
+ ServletManager.getInstance().addServletContext(url.getParameter(Constants.BIND_PORT_KEY, url.getPort()), context.getServletContext());
+
+ try {
+ server.start();
+ } catch (Exception e) {
+ throw new IllegalStateException("Failed to start jetty server on " + url.getParameter(Constants.BIND_IP_KEY) + ":" + url.getParameter(Constants.BIND_PORT_KEY) + ", cause: "
+ + e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public void close() {
+ super.close();
+
+ //
+ ServletManager.getInstance().removeServletContext(url.getParameter(Constants.BIND_PORT_KEY, url.getPort()));
+
+ if (server != null) {
+ try {
+ server.stop();
+ } catch (Exception e) {
+ logger.warn(e.getMessage(), e);
+ }
+ }
+ }
+
+}
diff --git a/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/servlet/BootstrapListener.java b/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/servlet/BootstrapListener.java
new file mode 100644
index 0000000000..94554ba56f
--- /dev/null
+++ b/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/servlet/BootstrapListener.java
@@ -0,0 +1,36 @@
+/*
+ * 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.remoting.http.servlet;
+
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+
+/**
+ * This class must be defined before something like spring's ContextLoaderListener in web.xml
+ */
+public class BootstrapListener implements ServletContextListener {
+
+ @Override
+ public void contextInitialized(ServletContextEvent servletContextEvent) {
+ ServletManager.getInstance().addServletContext(ServletManager.EXTERNAL_SERVER_PORT, servletContextEvent.getServletContext());
+ }
+
+ @Override
+ public void contextDestroyed(ServletContextEvent servletContextEvent) {
+ ServletManager.getInstance().removeServletContext(ServletManager.EXTERNAL_SERVER_PORT);
+ }
+}
diff --git a/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/servlet/DispatcherServlet.java b/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/servlet/DispatcherServlet.java
new file mode 100644
index 0000000000..3500f05e0f
--- /dev/null
+++ b/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/servlet/DispatcherServlet.java
@@ -0,0 +1,65 @@
+/*
+ * 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.remoting.http.servlet;
+
+import org.apache.dubbo.remoting.http.HttpHandler;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * Service dispatcher Servlet.
+ */
+public class DispatcherServlet extends HttpServlet {
+
+ private static final long serialVersionUID = 5766349180380479888L;
+ private static final Map HANDLERS = new ConcurrentHashMap();
+ private static DispatcherServlet INSTANCE;
+
+ public DispatcherServlet() {
+ DispatcherServlet.INSTANCE = this;
+ }
+
+ public static void addHttpHandler(int port, HttpHandler processor) {
+ HANDLERS.put(port, processor);
+ }
+
+ public static void removeHttpHandler(int port) {
+ HANDLERS.remove(port);
+ }
+
+ public static DispatcherServlet getInstance() {
+ return INSTANCE;
+ }
+
+ @Override
+ protected void service(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ HttpHandler handler = HANDLERS.get(request.getLocalPort());
+ if (handler == null) {// service not found.
+ response.sendError(HttpServletResponse.SC_NOT_FOUND, "Service not found.");
+ } else {
+ handler.handle(request, response);
+ }
+ }
+
+}
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/consumer/DemoInterceptor.java b/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/servlet/ServletHttpBinder.java
similarity index 64%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/consumer/DemoInterceptor.java
rename to dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/servlet/ServletHttpBinder.java
index 46d7e9afb2..447ea4e6ed 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/consumer/DemoInterceptor.java
+++ b/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/servlet/ServletHttpBinder.java
@@ -14,18 +14,21 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.config.consumer;
+package org.apache.dubbo.remoting.http.servlet;
-import org.aopalliance.intercept.MethodInterceptor;
-import org.aopalliance.intercept.MethodInvocation;
+import org.apache.dubbo.common.URL;
+import org.apache.dubbo.remoting.http.HttpBinder;
+import org.apache.dubbo.remoting.http.HttpHandler;
+import org.apache.dubbo.remoting.http.HttpServer;
/**
- * DemoInterceptor
+ * ServletHttpTransporter
*/
-public class DemoInterceptor implements MethodInterceptor {
+public class ServletHttpBinder implements HttpBinder {
- public Object invoke(MethodInvocation invocation) throws Throwable {
- return "aop:" + invocation.proceed();
+ @Override
+ public HttpServer bind(URL url, HttpHandler handler) {
+ return new ServletHttpServer(url, handler);
}
-}
\ No newline at end of file
+}
diff --git a/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/servlet/ServletHttpServer.java b/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/servlet/ServletHttpServer.java
new file mode 100644
index 0000000000..29e02d2208
--- /dev/null
+++ b/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/servlet/ServletHttpServer.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.remoting.http.servlet;
+
+import org.apache.dubbo.common.URL;
+import org.apache.dubbo.remoting.Constants;
+import org.apache.dubbo.remoting.http.HttpHandler;
+import org.apache.dubbo.remoting.http.support.AbstractHttpServer;
+
+public class ServletHttpServer extends AbstractHttpServer {
+
+ public ServletHttpServer(URL url, HttpHandler handler) {
+ super(url, handler);
+ DispatcherServlet.addHttpHandler(url.getParameter(Constants.BIND_PORT_KEY, 8080), handler);
+ }
+
+}
diff --git a/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/servlet/ServletManager.java b/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/servlet/ServletManager.java
new file mode 100644
index 0000000000..e81fae23c6
--- /dev/null
+++ b/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/servlet/ServletManager.java
@@ -0,0 +1,49 @@
+/*
+ * 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.remoting.http.servlet;
+
+import javax.servlet.ServletContext;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * TODO this may not be a pretty elegant solution,
+ */
+public class ServletManager {
+
+ public static final int EXTERNAL_SERVER_PORT = -1234;
+
+ private static final ServletManager INSTANCE = new ServletManager();
+
+ private final Map contextMap = new ConcurrentHashMap();
+
+ public static ServletManager getInstance() {
+ return INSTANCE;
+ }
+
+ public void addServletContext(int port, ServletContext servletContext) {
+ contextMap.put(port, servletContext);
+ }
+
+ public void removeServletContext(int port) {
+ contextMap.remove(port);
+ }
+
+ public ServletContext getServletContext(int port) {
+ return contextMap.get(port);
+ }
+}
diff --git a/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/support/AbstractHttpServer.java b/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/support/AbstractHttpServer.java
new file mode 100644
index 0000000000..437ac0d36d
--- /dev/null
+++ b/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/support/AbstractHttpServer.java
@@ -0,0 +1,134 @@
+/*
+ * 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.remoting.http.support;
+
+import org.apache.dubbo.common.Parameters;
+import org.apache.dubbo.common.URL;
+import org.apache.dubbo.remoting.Channel;
+import org.apache.dubbo.remoting.ChannelHandler;
+import org.apache.dubbo.remoting.RemotingException;
+import org.apache.dubbo.remoting.http.HttpHandler;
+import org.apache.dubbo.remoting.http.HttpServer;
+
+import java.net.InetSocketAddress;
+import java.util.Collection;
+
+/**
+ * AbstractHttpServer
+ */
+public abstract class AbstractHttpServer implements HttpServer {
+
+ private final URL url;
+
+ private final HttpHandler handler;
+
+ private volatile boolean closed;
+
+ public AbstractHttpServer(URL url, HttpHandler handler) {
+ if (url == null) {
+ throw new IllegalArgumentException("url == null");
+ }
+ if (handler == null) {
+ throw new IllegalArgumentException("handler == null");
+ }
+ this.url = url;
+ this.handler = handler;
+ }
+
+ @Override
+ public HttpHandler getHttpHandler() {
+ return handler;
+ }
+
+ @Override
+ public URL getUrl() {
+ return url;
+ }
+
+ @Override
+ public void reset(URL url) {
+ }
+
+ @Override
+ public boolean isBound() {
+ return true;
+ }
+
+ @Override
+ public InetSocketAddress getLocalAddress() {
+ return url.toInetSocketAddress();
+ }
+
+ @Override
+ public void close() {
+ closed = true;
+ }
+
+ @Override
+ public void close(int timeout) {
+ close();
+ }
+
+ @Override
+ public boolean isClosed() {
+ return closed;
+ }
+
+ /**
+ * Following methods are extended from RemotingServer, useless for http servers
+ */
+
+ @Override
+ public boolean canHandleIdle() {
+ return false;
+ }
+
+ @Override
+ public Collection getChannels() {
+ return null;
+ }
+
+ @Override
+ public Channel getChannel(InetSocketAddress remoteAddress) {
+ return null;
+ }
+
+ @Override
+ public void reset(Parameters parameters) {
+
+ }
+
+ @Override
+ public ChannelHandler getChannelHandler() {
+ return null;
+ }
+
+ @Override
+ public void send(Object message) throws RemotingException {
+
+ }
+
+ @Override
+ public void send(Object message, boolean sent) throws RemotingException {
+
+ }
+
+ @Override
+ public void startClose() {
+
+ }
+}
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/consumer/DemoActionByAnnotation.java b/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/tomcat/TomcatHttpBinder.java
old mode 100644
new mode 100755
similarity index 66%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/consumer/DemoActionByAnnotation.java
rename to dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/tomcat/TomcatHttpBinder.java
index 23d00e4022..4e4a74bb7e
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/consumer/DemoActionByAnnotation.java
+++ b/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/tomcat/TomcatHttpBinder.java
@@ -14,22 +14,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.config.consumer;
+package org.apache.dubbo.remoting.http.tomcat;
-import org.apache.dubbo.config.api.DemoService;
+import org.apache.dubbo.common.URL;
+import org.apache.dubbo.remoting.http.HttpBinder;
+import org.apache.dubbo.remoting.http.HttpHandler;
+import org.apache.dubbo.remoting.http.HttpServer;
-import org.springframework.beans.factory.annotation.Autowired;
+public class TomcatHttpBinder implements HttpBinder {
-/**
- * DemoAction
- */
-public class DemoActionByAnnotation {
-
- @Autowired
- private DemoService demoService;
-
- public DemoService getDemoService() {
- return demoService;
+ @Override
+ public HttpServer bind(URL url, HttpHandler handler) {
+ return new TomcatHttpServer(url, handler);
}
-}
\ No newline at end of file
+}
diff --git a/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/tomcat/TomcatHttpServer.java b/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/tomcat/TomcatHttpServer.java
new file mode 100755
index 0000000000..9fd96524f1
--- /dev/null
+++ b/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/tomcat/TomcatHttpServer.java
@@ -0,0 +1,93 @@
+/*
+ * 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.remoting.http.tomcat;
+
+import org.apache.dubbo.common.URL;
+import org.apache.dubbo.common.logger.Logger;
+import org.apache.dubbo.common.logger.LoggerFactory;
+import org.apache.dubbo.remoting.http.HttpHandler;
+import org.apache.dubbo.remoting.http.servlet.DispatcherServlet;
+import org.apache.dubbo.remoting.http.servlet.ServletManager;
+import org.apache.dubbo.remoting.http.support.AbstractHttpServer;
+
+import org.apache.catalina.Context;
+import org.apache.catalina.LifecycleException;
+import org.apache.catalina.connector.Connector;
+import org.apache.catalina.startup.Tomcat;
+
+import java.io.File;
+
+import static org.apache.dubbo.common.constants.CommonConstants.DEFAULT_THREADS;
+import static org.apache.dubbo.common.constants.CommonConstants.THREADS_KEY;
+import static org.apache.dubbo.remoting.Constants.ACCEPTS_KEY;
+
+public class TomcatHttpServer extends AbstractHttpServer {
+
+ private static final Logger logger = LoggerFactory.getLogger(TomcatHttpServer.class);
+
+ private final Tomcat tomcat;
+
+ private final URL url;
+
+ public TomcatHttpServer(URL url, final HttpHandler handler) {
+ super(url, handler);
+
+ this.url = url;
+ DispatcherServlet.addHttpHandler(url.getPort(), handler);
+ String baseDir = new File(System.getProperty("java.io.tmpdir")).getAbsolutePath();
+ tomcat = new Tomcat();
+
+ Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
+ connector.setPort(url.getPort());
+ connector.setProperty("maxThreads", String.valueOf(url.getParameter(THREADS_KEY, DEFAULT_THREADS)));
+ connector.setProperty("maxConnections", String.valueOf(url.getParameter(ACCEPTS_KEY, -1)));
+ connector.setProperty("URIEncoding", "UTF-8");
+ connector.setProperty("connectionTimeout", "60000");
+ connector.setProperty("maxKeepAliveRequests", "-1");
+ tomcat.setConnector(connector);
+
+ tomcat.setBaseDir(baseDir);
+ tomcat.setPort(url.getPort());
+
+ Context context = tomcat.addContext("/", baseDir);
+ Tomcat.addServlet(context, "dispatcher", new DispatcherServlet());
+ context.addServletMapping("/*", "dispatcher");
+ ServletManager.getInstance().addServletContext(url.getPort(), context.getServletContext());
+
+ // tell tomcat to fail on startup failures.
+ System.setProperty("org.apache.catalina.startup.EXIT_ON_INIT_FAILURE", "true");
+
+ try {
+ tomcat.start();
+ } catch (LifecycleException e) {
+ throw new IllegalStateException("Failed to start tomcat server at " + url.getAddress(), e);
+ }
+ }
+
+ @Override
+ public void close() {
+ super.close();
+
+ ServletManager.getInstance().removeServletContext(url.getPort());
+
+ try {
+ tomcat.stop();
+ } catch (Exception e) {
+ logger.warn(e.getMessage(), e);
+ }
+ }
+}
diff --git a/dubbo-remoting/dubbo-remoting-http/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.remoting.http.HttpBinder b/dubbo-remoting/dubbo-remoting-http/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.remoting.http.HttpBinder
new file mode 100644
index 0000000000..845124bb43
--- /dev/null
+++ b/dubbo-remoting/dubbo-remoting-http/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.remoting.http.HttpBinder
@@ -0,0 +1,3 @@
+servlet=org.apache.dubbo.remoting.http.servlet.ServletHttpBinder
+jetty=org.apache.dubbo.remoting.http.jetty.JettyHttpBinder
+tomcat=org.apache.dubbo.remoting.http.tomcat.TomcatHttpBinder
\ No newline at end of file
diff --git a/dubbo-remoting/dubbo-remoting-http/src/test/java/org/apache/dubbo/remoting/http/jetty/JettyHttpBinderTest.java b/dubbo-remoting/dubbo-remoting-http/src/test/java/org/apache/dubbo/remoting/http/jetty/JettyHttpBinderTest.java
new file mode 100644
index 0000000000..1741292a7e
--- /dev/null
+++ b/dubbo-remoting/dubbo-remoting-http/src/test/java/org/apache/dubbo/remoting/http/jetty/JettyHttpBinderTest.java
@@ -0,0 +1,54 @@
+/*
+ * 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.remoting.http.jetty;
+
+import org.apache.dubbo.common.URL;
+import org.apache.dubbo.common.utils.NetUtils;
+import org.apache.dubbo.remoting.Constants;
+import org.apache.dubbo.remoting.http.HttpHandler;
+import org.apache.dubbo.remoting.http.HttpServer;
+
+import org.apache.http.client.fluent.Request;
+import org.junit.jupiter.api.Test;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+public class JettyHttpBinderTest {
+ @Test
+ public void shouldAbleHandleRequestForJettyBinder() throws Exception {
+ int port = NetUtils.getAvailablePort();
+ URL url = new URL("http", "localhost", port,
+ new String[]{Constants.BIND_PORT_KEY, String.valueOf(port)});
+ HttpServer httpServer = new JettyHttpServer(url, new HttpHandler() {
+ @Override
+ public void handle(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ response.getWriter().write("Jetty");
+ }
+ });
+
+ String response = Request.Get(url.toJavaURL().toURI()).execute().returnContent().asString();
+
+ assertThat(response, is("Jetty"));
+
+ httpServer.close();
+ }
+}
diff --git a/dubbo-remoting/dubbo-remoting-http/src/test/java/org/apache/dubbo/remoting/http/tomcat/TomcatHttpBinderTest.java b/dubbo-remoting/dubbo-remoting-http/src/test/java/org/apache/dubbo/remoting/http/tomcat/TomcatHttpBinderTest.java
new file mode 100644
index 0000000000..f31b6ce23c
--- /dev/null
+++ b/dubbo-remoting/dubbo-remoting-http/src/test/java/org/apache/dubbo/remoting/http/tomcat/TomcatHttpBinderTest.java
@@ -0,0 +1,55 @@
+/*
+ * 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.remoting.http.tomcat;
+
+import org.apache.dubbo.common.URL;
+import org.apache.dubbo.common.utils.NetUtils;
+import org.apache.dubbo.remoting.Constants;
+import org.apache.dubbo.remoting.http.HttpHandler;
+import org.apache.dubbo.remoting.http.HttpServer;
+
+import org.apache.http.client.fluent.Request;
+import org.junit.jupiter.api.Test;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+public class TomcatHttpBinderTest {
+ @Test
+ public void shouldAbleHandleRequestForTomcatBinder() throws Exception {
+ int port = NetUtils.getAvailablePort();
+ URL url = new URL("http", "localhost", port,
+ new String[]{Constants.BIND_PORT_KEY, String.valueOf(port)});
+
+ HttpServer httpServer = new TomcatHttpBinder().bind(url, new HttpHandler() {
+ @Override
+ public void handle(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ response.getWriter().write("Tomcat");
+ }
+ });
+
+ String response = Request.Get(url.toJavaURL().toURI()).execute().returnContent().asString();
+
+ assertThat(response, is("Tomcat"));
+
+ httpServer.close();
+ }
+}
diff --git a/dubbo-remoting/pom.xml b/dubbo-remoting/pom.xml
index 5c37a6debb..e0ab094b30 100644
--- a/dubbo-remoting/pom.xml
+++ b/dubbo-remoting/pom.xml
@@ -32,6 +32,7 @@
dubbo-remoting-api
+ dubbo-remoting-http
dubbo-remoting-netty
dubbo-remoting-zookeeper
dubbo-remoting-netty4
diff --git a/dubbo-rpc/dubbo-rpc-dubbo/pom.xml b/dubbo-rpc/dubbo-rpc-dubbo/pom.xml
index 052daca652..42a019615b 100644
--- a/dubbo-rpc/dubbo-rpc-dubbo/pom.xml
+++ b/dubbo-rpc/dubbo-rpc-dubbo/pom.xml
@@ -51,12 +51,6 @@
${project.parent.version}
test
-
- org.apache.dubbo
- dubbo-remoting-mina
- ${project.parent.version}
- test
-
io.netty
netty-all
diff --git a/dubbo-rpc/dubbo-rpc-dubbo/src/test/java/org/apache/dubbo/rpc/protocol/dubbo/DubboProtocolTest.java b/dubbo-rpc/dubbo-rpc-dubbo/src/test/java/org/apache/dubbo/rpc/protocol/dubbo/DubboProtocolTest.java
index e55f7ac31d..6788b0c5d0 100644
--- a/dubbo-rpc/dubbo-rpc-dubbo/src/test/java/org/apache/dubbo/rpc/protocol/dubbo/DubboProtocolTest.java
+++ b/dubbo-rpc/dubbo-rpc-dubbo/src/test/java/org/apache/dubbo/rpc/protocol/dubbo/DubboProtocolTest.java
@@ -20,7 +20,6 @@ package org.apache.dubbo.rpc.protocol.dubbo;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.utils.NetUtils;
-import org.apache.dubbo.remoting.Constants;
import org.apache.dubbo.rpc.Protocol;
import org.apache.dubbo.rpc.ProxyFactory;
import org.apache.dubbo.rpc.RpcException;
@@ -108,45 +107,45 @@ public class DubboProtocolTest {
assertEquals(echo.$echo(1234), 1234);
}
- @Test
- public void testDubboProtocolWithMina() throws Exception {
- DemoService service = new DemoServiceImpl();
- int port = NetUtils.getAvailablePort();
- protocol.export(proxy.getInvoker(service, DemoService.class, URL.valueOf("dubbo://127.0.0.1:" + port + "/" + DemoService.class.getName()).addParameter(Constants.SERVER_KEY, "mina")));
- service = proxy.getProxy(protocol.refer(DemoService.class, URL.valueOf("dubbo://127.0.0.1:" + port + "/" + DemoService.class.getName()).addParameter(Constants.CLIENT_KEY, "mina").addParameter("timeout",
- 3000L)));
- for (int i = 0; i < 10; i++) {
- assertEquals(service.enumlength(new Type[]{}), Type.Lower);
- assertEquals(service.getSize(null), -1);
- assertEquals(service.getSize(new String[]{"", "", ""}), 3);
- }
- Map map = new HashMap();
- map.put("aa", "bb");
- for (int i = 0; i < 10; i++) {
- Set set = service.keys(map);
- assertEquals(set.size(), 1);
- assertEquals(set.iterator().next(), "aa");
- service.invoke("dubbo://127.0.0.1:" + port + "/" + DemoService.class.getName() + "", "invoke");
- }
-
- service = proxy.getProxy(protocol.refer(DemoService.class, URL.valueOf("dubbo://127.0.0.1:" + port + "/" + DemoService.class.getName() + "?client=mina").addParameter("timeout",
- 3000L)));
- // test netty client
- StringBuffer buf = new StringBuffer();
- for (int i = 0; i < 1024 * 32 + 32; i++)
- buf.append('A');
- System.out.println(service.stringLength(buf.toString()));
-
- // cast to EchoService
- EchoService echo = proxy.getProxy(protocol.refer(EchoService.class, URL.valueOf("dubbo://127.0.0.1:" + port + "/" + DemoService.class.getName() + "?client=mina").addParameter("timeout",
- 3000L)));
- for (int i = 0; i < 10; i++) {
- assertEquals(echo.$echo(buf.toString()), buf.toString());
- assertEquals(echo.$echo("test"), "test");
- assertEquals(echo.$echo("abcdefg"), "abcdefg");
- assertEquals(echo.$echo(1234), 1234);
- }
- }
+// @Test
+// public void testDubboProtocolWithMina() throws Exception {
+// DemoService service = new DemoServiceImpl();
+// int port = NetUtils.getAvailablePort();
+// protocol.export(proxy.getInvoker(service, DemoService.class, URL.valueOf("dubbo://127.0.0.1:" + port + "/" + DemoService.class.getName()).addParameter(Constants.SERVER_KEY, "mina")));
+// service = proxy.getProxy(protocol.refer(DemoService.class, URL.valueOf("dubbo://127.0.0.1:" + port + "/" + DemoService.class.getName()).addParameter(Constants.CLIENT_KEY, "mina").addParameter("timeout",
+// 3000L)));
+// for (int i = 0; i < 10; i++) {
+// assertEquals(service.enumlength(new Type[]{}), Type.Lower);
+// assertEquals(service.getSize(null), -1);
+// assertEquals(service.getSize(new String[]{"", "", ""}), 3);
+// }
+// Map map = new HashMap();
+// map.put("aa", "bb");
+// for (int i = 0; i < 10; i++) {
+// Set set = service.keys(map);
+// assertEquals(set.size(), 1);
+// assertEquals(set.iterator().next(), "aa");
+// service.invoke("dubbo://127.0.0.1:" + port + "/" + DemoService.class.getName() + "", "invoke");
+// }
+//
+// service = proxy.getProxy(protocol.refer(DemoService.class, URL.valueOf("dubbo://127.0.0.1:" + port + "/" + DemoService.class.getName() + "?client=mina").addParameter("timeout",
+// 3000L)));
+// // test netty client
+// StringBuffer buf = new StringBuffer();
+// for (int i = 0; i < 1024 * 32 + 32; i++)
+// buf.append('A');
+// System.out.println(service.stringLength(buf.toString()));
+//
+// // cast to EchoService
+// EchoService echo = proxy.getProxy(protocol.refer(EchoService.class, URL.valueOf("dubbo://127.0.0.1:" + port + "/" + DemoService.class.getName() + "?client=mina").addParameter("timeout",
+// 3000L)));
+// for (int i = 0; i < 10; i++) {
+// assertEquals(echo.$echo(buf.toString()), buf.toString());
+// assertEquals(echo.$echo("test"), "test");
+// assertEquals(echo.$echo("abcdefg"), "abcdefg");
+// assertEquals(echo.$echo(1234), 1234);
+// }
+// }
@Test
public void testDubboProtocolMultiService() throws Exception {