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 2020/09/03 09:48:06 UTC
[dubbo] branch 3.0 updated: refactor dependencies after sub modules
moved to dubbo-spi-extensions (#6685)
This is an automated email from the ASF dual-hosted git repository.
liujun 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 b235310 refactor dependencies after sub modules moved to dubbo-spi-extensions (#6685)
b235310 is described below
commit b2353107f2779f77713400a48d8a15aad2724551
Author: ken.lj <ke...@gmail.com>
AuthorDate: Thu Sep 3 17:47:23 2020 +0800
refactor dependencies after sub modules moved to dubbo-spi-extensions (#6685)
---
dubbo-compatible/pom.xml | 15 --
dubbo-config/dubbo-config-api/pom.xml | 75 ----------
dubbo-config/dubbo-config-spring/pom.xml | 12 --
.../dubbo-demo-annotation-consumer/pom.xml | 4 -
.../dubbo-demo-annotation-provider/pom.xml | 4 -
.../dubbo-demo-xml/dubbo-demo-xml-consumer/pom.xml | 4 -
.../dubbo-demo-xml/dubbo-demo-xml-provider/pom.xml | 4 -
dubbo-distribution/dubbo-bom/pom.xml | 166 +--------------------
dubbo-distribution/pom.xml | 1 +
dubbo-registry/dubbo-registry-multiple/pom.xml | 6 -
.../multiple/MultipleRegistry2S2RTest.java | 54 +++----
.../multiple/MultipleRegistryTestUtil.java | 44 ------
.../dubbo-remoting-http}/pom.xml | 37 +++--
.../org/apache/dubbo/remoting/http/HttpBinder.java | 23 ++-
.../apache/dubbo/remoting/http/HttpHandler.java | 29 ++--
.../org/apache/dubbo/remoting/http/HttpServer.java | 72 +++++++++
.../dubbo/remoting/http/jetty/JettyHttpBinder.java | 19 ++-
.../dubbo/remoting/http/jetty/JettyHttpServer.java | 112 ++++++++++++++
.../remoting/http/servlet/BootstrapListener.java | 24 +--
.../remoting/http/servlet/DispatcherServlet.java | 65 ++++++++
.../remoting/http/servlet/ServletHttpBinder.java | 23 ++-
.../remoting/http/servlet/ServletHttpServer.java | 25 ++--
.../remoting/http/servlet/ServletManager.java | 49 ++++++
.../remoting/http/support/AbstractHttpServer.java | 134 +++++++++++++++++
.../remoting/http/tomcat/TomcatHttpBinder.java | 25 ++--
.../remoting/http/tomcat/TomcatHttpServer.java | 93 ++++++++++++
.../org.apache.dubbo.remoting.http.HttpBinder | 3 +
.../remoting/http/jetty/JettyHttpBinderTest.java | 54 +++++++
.../remoting/http/tomcat/TomcatHttpBinderTest.java | 55 +++++++
dubbo-remoting/pom.xml | 1 +
dubbo-rpc/dubbo-rpc-dubbo/pom.xml | 6 -
.../rpc/protocol/dubbo/DubboProtocolTest.java | 79 +++++-----
32 files changed, 811 insertions(+), 506 deletions(-)
diff --git a/dubbo-compatible/pom.xml b/dubbo-compatible/pom.xml
index c72edde..9d6f462 100644
--- a/dubbo-compatible/pom.xml
+++ b/dubbo-compatible/pom.xml
@@ -45,16 +45,6 @@
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-remoting-http</artifactId>
- <version>${project.parent.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-remoting-p2p</artifactId>
- <version>${project.parent.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-remoting-zookeeper</artifactId>
<version>${project.parent.version}</version>
</dependency>
@@ -65,11 +55,6 @@
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-rpc-thrift</artifactId>
- <version>${project.parent.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-filter-cache</artifactId>
<version>${project.parent.version}</version>
</dependency>
diff --git a/dubbo-config/dubbo-config-api/pom.xml b/dubbo-config/dubbo-config-api/pom.xml
index f5cfd34..86880eb 100644
--- a/dubbo-config/dubbo-config-api/pom.xml
+++ b/dubbo-config/dubbo-config-api/pom.xml
@@ -73,20 +73,6 @@
<dependency>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-rpc-rmi</artifactId>
- <version>${project.parent.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-rpc-hessian</artifactId>
- <version>${project.parent.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-remoting-netty4</artifactId>
<version>${project.parent.version}</version>
<scope>test</scope>
@@ -122,33 +108,6 @@
<dependency>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-registry-eureka</artifactId>
- <version>${project.parent.version}</version>
- <scope>test</scope>
- <exclusions>
- <exclusion>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-registry-etcd3</artifactId>
- <version>${project.parent.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-registry-consul</artifactId>
- <version>${project.parent.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-metadata-report-zookeeper</artifactId>
<version>${project.parent.version}</version>
<scope>test</scope>
@@ -162,33 +121,6 @@
<dependency>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-metadata-report-etcd</artifactId>
- <version>${project.parent.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-metadata-report-nacos</artifactId>
- <version>${project.parent.version}</version>
- <scope>test</scope>
- <exclusions>
- <exclusion>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-metadata-report-consul</artifactId>
- <version>${project.parent.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-metadata-report-redis</artifactId>
<version>${project.parent.version}</version>
<scope>test</scope>
@@ -216,13 +148,6 @@
<dependency>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-configcenter-consul</artifactId>
- <version>${project.parent.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-filter-cache</artifactId>
<version>${project.parent.version}</version>
<scope>test</scope>
diff --git a/dubbo-config/dubbo-config-spring/pom.xml b/dubbo-config/dubbo-config-spring/pom.xml
index 31bfcf4..c1255cc 100644
--- a/dubbo-config/dubbo-config-spring/pom.xml
+++ b/dubbo-config/dubbo-config-spring/pom.xml
@@ -66,12 +66,6 @@
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-registry-default</artifactId>
- <version>${project.parent.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-monitor-default</artifactId>
<version>${project.parent.version}</version>
<scope>test</scope>
@@ -84,12 +78,6 @@
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-rpc-rmi</artifactId>
- <version>${project.parent.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-rpc-injvm</artifactId>
<version>${project.parent.version}</version>
</dependency>
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 6dd31d2..c48478a 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
@@ -65,10 +65,6 @@
</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>
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 27186ea..b78ec15 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
@@ -66,10 +66,6 @@
</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>
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 b3a4acc..fffa2bd 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
@@ -65,10 +65,6 @@
</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>
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 c4590c2..20e3b52 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
@@ -64,10 +64,6 @@
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-metadata-report-nacos</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-metadata-report-zookeeper</artifactId>
</dependency>
<dependency>
diff --git a/dubbo-distribution/dubbo-bom/pom.xml b/dubbo-distribution/dubbo-bom/pom.xml
index afd52bd..d3c1b33 100644
--- a/dubbo-distribution/dubbo-bom/pom.xml
+++ b/dubbo-distribution/dubbo-bom/pom.xml
@@ -85,31 +85,6 @@
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-remoting-mina</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-remoting-grizzly</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-remoting-p2p</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-remoting-http</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-remoting-etcd3</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-rpc-api</artifactId>
<version>${project.version}</version>
</dependency>
@@ -125,56 +100,11 @@
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-rpc-http</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-rpc-rmi</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-rpc-hessian</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-rpc-webservice</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-rpc-thrift</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-rpc-native-thrift</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-rpc-memcached</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-rpc-redis</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-rpc-rest</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-rpc-xml</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-rpc-grpc</artifactId>
<version>${project.version}</version>
</dependency>
@@ -185,7 +115,7 @@
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-registry-default</artifactId>
+ <artifactId>dubbo-registry-multiple</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
@@ -200,31 +130,11 @@
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-registry-redis</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-registry-etcd3</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-registry-consul</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-registry-nacos</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-registry-sofa</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-monitor-api</artifactId>
<version>${project.version}</version>
</dependency>
@@ -235,17 +145,12 @@
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-container-spring</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-container-log4j</artifactId>
+ <artifactId>dubbo-container-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-container-logback</artifactId>
+ <artifactId>dubbo-container-spring</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
@@ -260,59 +165,20 @@
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-serialization-fastjson</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-serialization-fst</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-serialization-hessian2</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-serialization-native-hession</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-serialization-jdk</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-serialization-kryo</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-serialization-protostuff</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-serialization-avro</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-serialization-gson</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-serialization-protobuf</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-compatible</artifactId>
<version>${project.version}</version>
</dependency>
+
<!-- metadata -->
<dependency>
<groupId>org.apache.dubbo</groupId>
@@ -331,17 +197,12 @@
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-metadata-report-consul</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-metadata-report-etcd</artifactId>
+ <artifactId>dubbo-metadata-processor</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-metadata-report-nacos</artifactId>
+ <artifactId>dubbo-metadata-definition-protobuf</artifactId>
<version>${project.version}</version>
</dependency>
@@ -358,24 +219,9 @@
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-configcenter-consul</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-configcenter-etcd</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-configcenter-nacos</artifactId>
<version>${project.version}</version>
</dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-metadata-definition-protobuf</artifactId>
- <version>${project.version}</version>
- </dependency>
</dependencies>
</dependencyManagement>
diff --git a/dubbo-distribution/pom.xml b/dubbo-distribution/pom.xml
index 2dc703e..a28d3f4 100644
--- a/dubbo-distribution/pom.xml
+++ b/dubbo-distribution/pom.xml
@@ -45,6 +45,7 @@
</activation>
<modules>
<module>dubbo-all</module>
+ <module>dubbo-bom</module>
</modules>
</profile>
<profile>
diff --git a/dubbo-registry/dubbo-registry-multiple/pom.xml b/dubbo-registry/dubbo-registry-multiple/pom.xml
index 1b5dac4..e4c5165 100644
--- a/dubbo-registry/dubbo-registry-multiple/pom.xml
+++ b/dubbo-registry/dubbo-registry-multiple/pom.xml
@@ -42,12 +42,6 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-registry-redis</artifactId>
- <version>${project.parent.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-test</artifactId>
<scope>test</scope>
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 9243730..0dafdab 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<Registry> 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<URL> list = new ArrayList<URL>();
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<URL> list = new ArrayList<URL>();
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 9544ef8..a0aeef2 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<Registry> 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-registry/dubbo-registry-multiple/pom.xml b/dubbo-remoting/dubbo-remoting-http/pom.xml
similarity index 62%
copy from dubbo-registry/dubbo-registry-multiple/pom.xml
copy to dubbo-remoting/dubbo-remoting-http/pom.xml
index 1b5dac4..b4abaea 100644
--- a/dubbo-registry/dubbo-registry-multiple/pom.xml
+++ b/dubbo-remoting/dubbo-remoting-http/pom.xml
@@ -14,53 +14,50 @@
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">
+<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-registry</artifactId>
+ <artifactId>dubbo-remoting</artifactId>
<version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>
- <artifactId>dubbo-registry-multiple</artifactId>
+ <artifactId>dubbo-remoting-http</artifactId>
<packaging>jar</packaging>
<name>${project.artifactId}</name>
- <description>The multiple registry module of dubbo project</description>
+ <description>The http remoting module of dubbo project</description>
<properties>
<skip_maven_deploy>false</skip_maven_deploy>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-registry-api</artifactId>
+ <artifactId>dubbo-common</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-registry-zookeeper</artifactId>
+ <artifactId>dubbo-remoting-api</artifactId>
<version>${project.parent.version}</version>
- <scope>test</scope>
</dependency>
<dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-registry-redis</artifactId>
- <version>${project.parent.version}</version>
- <scope>test</scope>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-server</artifactId>
</dependency>
<dependency>
- <groupId>org.apache.curator</groupId>
- <artifactId>curator-test</artifactId>
- <scope>test</scope>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-servlet</artifactId>
</dependency>
<dependency>
- <groupId>com.github.kstyrc</groupId>
- <artifactId>embedded-redis</artifactId>
- <scope>test</scope>
+ <groupId>org.apache.tomcat.embed</groupId>
+ <artifactId>tomcat-embed-core</artifactId>
</dependency>
<dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-lang3</artifactId>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>fluent-hc</artifactId>
+ <version>4.5.5</version>
<scope>test</scope>
</dependency>
</dependencies>
-</project>
+</project>
\ 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 a2f9f41..031139d 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-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/HttpHandler.java
similarity index 60%
copy from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/consumer/DemoActionBySetter.java
copy to dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/HttpHandler.java
index 0606e26..c8cd217 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/HttpHandler.java
@@ -14,23 +14,26 @@
* 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;
-import org.apache.dubbo.config.api.DemoService;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
/**
- * DemoAction
+ * http invocation handler.
*/
-public class DemoActionBySetter {
+public interface HttpHandler {
- private DemoService demoService;
-
- public DemoService getDemoService() {
- return demoService;
- }
-
- public void setDemoService(DemoService demoService) {
- this.demoService = demoService;
- }
+ /**
+ * 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 0000000..2cc6766
--- /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/DemoInterceptor.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/DemoInterceptor.java
rename to dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/jetty/JettyHttpBinder.java
index 46d7e9a..9a41285 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/jetty/JettyHttpBinder.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.jetty;
-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
+ * JettyHttpTransporter
*/
-public class DemoInterceptor implements MethodInterceptor {
+public class JettyHttpBinder implements HttpBinder {
- public Object invoke(MethodInvocation invocation) throws Throwable {
- return "aop:" + invocation.proceed();
+ @Override
+ public HttpServer bind(URL url, HttpHandler handler) {
+ return new JettyHttpServer(url, handler);
}
-}
\ 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 0000000..4a18896
--- /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-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/servlet/BootstrapListener.java
similarity index 53%
copy from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/consumer/DemoActionBySetter.java
copy to dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/servlet/BootstrapListener.java
index 0606e26..94554ba 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/servlet/BootstrapListener.java
@@ -14,23 +14,23 @@
* 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.apache.dubbo.config.api.DemoService;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
/**
- * DemoAction
+ * This class must be defined before something like spring's ContextLoaderListener in web.xml
*/
-public class DemoActionBySetter {
+public class BootstrapListener implements ServletContextListener {
- private DemoService demoService;
-
- public DemoService getDemoService() {
- return demoService;
+ @Override
+ public void contextInitialized(ServletContextEvent servletContextEvent) {
+ ServletManager.getInstance().addServletContext(ServletManager.EXTERNAL_SERVER_PORT, servletContextEvent.getServletContext());
}
- public void setDemoService(DemoService demoService) {
- this.demoService = demoService;
+ @Override
+ public void contextDestroyed(ServletContextEvent servletContextEvent) {
+ ServletManager.getInstance().removeServletContext(ServletManager.EXTERNAL_SERVER_PORT);
}
-
-}
\ No newline at end of file
+}
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 0000000..3500f05
--- /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<Integer, HttpHandler> HANDLERS = new ConcurrentHashMap<Integer, HttpHandler>();
+ 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/DemoActionByAnnotation.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/DemoActionByAnnotation.java
rename to dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/servlet/ServletHttpBinder.java
index 23d00e4..447ea4e 100644
--- 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/servlet/ServletHttpBinder.java
@@ -14,22 +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.apache.dubbo.config.api.DemoService;
-
-import org.springframework.beans.factory.annotation.Autowired;
+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
+ * ServletHttpTransporter
*/
-public class DemoActionByAnnotation {
-
- @Autowired
- private DemoService demoService;
+public class ServletHttpBinder implements HttpBinder {
- public DemoService getDemoService() {
- return demoService;
+ @Override
+ public HttpServer bind(URL url, HttpHandler handler) {
+ return new ServletHttpServer(url, handler);
}
-}
\ 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/servlet/ServletHttpServer.java
similarity index 62%
copy from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/consumer/DemoActionBySetter.java
copy to dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/servlet/ServletHttpServer.java
index 0606e26..29e02d2 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/servlet/ServletHttpServer.java
@@ -14,23 +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.servlet;
-import org.apache.dubbo.config.api.DemoService;
+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;
-/**
- * DemoAction
- */
-public class DemoActionBySetter {
-
- private DemoService demoService;
-
- public DemoService getDemoService() {
- return demoService;
- }
+public class ServletHttpServer extends AbstractHttpServer {
- public void setDemoService(DemoService demoService) {
- this.demoService = demoService;
+ public ServletHttpServer(URL url, HttpHandler handler) {
+ super(url, handler);
+ DispatcherServlet.addHttpHandler(url.getParameter(Constants.BIND_PORT_KEY, 8080), handler);
}
-}
\ No newline at end of file
+}
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 0000000..e81fae2
--- /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<Integer, ServletContext> contextMap = new ConcurrentHashMap<Integer, ServletContext>();
+
+ 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 0000000..437ac0d
--- /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<Channel> 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/DemoActionBySetter.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/DemoActionBySetter.java
rename to dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/tomcat/TomcatHttpBinder.java
index 0606e26..4e4a74b
--- 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/tomcat/TomcatHttpBinder.java
@@ -14,23 +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;
-/**
- * DemoAction
- */
-public class DemoActionBySetter {
-
- private DemoService demoService;
-
- public DemoService getDemoService() {
- return demoService;
- }
+public class TomcatHttpBinder implements HttpBinder {
- public void setDemoService(DemoService demoService) {
- this.demoService = 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 0000000..9fd9652
--- /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 0000000..845124b
--- /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 0000000..1741292
--- /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 0000000..f31b6ce
--- /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 5c37a6d..e0ab094 100644
--- a/dubbo-remoting/pom.xml
+++ b/dubbo-remoting/pom.xml
@@ -32,6 +32,7 @@
</properties>
<modules>
<module>dubbo-remoting-api</module>
+ <module>dubbo-remoting-http</module>
<module>dubbo-remoting-netty</module>
<module>dubbo-remoting-zookeeper</module>
<module>dubbo-remoting-netty4</module>
diff --git a/dubbo-rpc/dubbo-rpc-dubbo/pom.xml b/dubbo-rpc/dubbo-rpc-dubbo/pom.xml
index 052daca..42a0196 100644
--- a/dubbo-rpc/dubbo-rpc-dubbo/pom.xml
+++ b/dubbo-rpc/dubbo-rpc-dubbo/pom.xml
@@ -52,12 +52,6 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-remoting-mina</artifactId>
- <version>${project.parent.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<scope>test</scope>
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 e55f7ac..6788b0c 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<String, String> map = new HashMap<String, String>();
- map.put("aa", "bb");
- for (int i = 0; i < 10; i++) {
- Set<String> 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<String, String> map = new HashMap<String, String>();
+// map.put("aa", "bb");
+// for (int i = 0; i < 10; i++) {
+// Set<String> 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 {