You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by la...@apache.org on 2021/09/09 04:34:50 UTC
[dubbo-go-samples] branch config-enhance updated: Rft/add config
enhance generic dubbo (#230)
This is an automated email from the ASF dual-hosted git repository.
laurence pushed a commit to branch config-enhance
in repository https://gitbox.apache.org/repos/asf/dubbo-go-samples.git
The following commit(s) were added to refs/heads/config-enhance by this push:
new a7b9517 Rft/add config enhance generic dubbo (#230)
a7b9517 is described below
commit a7b951763067196580ef4c876618c9c9ea1496a6
Author: yaoyinnan <35...@users.noreply.github.com>
AuthorDate: Thu Sep 9 12:34:43 2021 +0800
Rft/add config enhance generic dubbo (#230)
* add config-enhance generic-dubbo
* add config-enhance generic-dubbo run.xml
* add config-enhance generic-dubbo
* add config-enhance generic-dubbo
* add config-enhance generic-dubbo README
* add config-enhance generic-dubbo java
* add config-enhance generic-dubbo yml
* add config-enhance generic-dubbo
* fix: config-enhance generic-dubbo, use `default` as the directory name
* fix: config-enhance generic-dubbo, modify README.md
* fix: config-enhance generic-dubbo, modify .run
* rft: config-enhance generic-dubbo, add ci
* rft: config-enhance generic-dubbo, add ci
* rft: config-enhance generic-dubbo, add ci
* rft: config-enhance generic-dubbo, add ci
* rft: config-enhance generic-dubbo, add ci
* rft: config-enhance generic-dubbo, add ci
* rft: config-enhance generic-dubbo, add ci
* rft: config-enhance generic-dubbo, add ci
* rft: config-enhance generic-dubbo, add ci
---
.run/generic-default-go-client.run.xml | 14 ++
.run/generic-default-go-server.run.xml | 14 ++
.run/generic-default-java-client.run.xml | 17 ++
.run/generic-default-java-server.run.xml | 17 ++
.run/generic-go-client.run.xml | 15 --
.run/generic-go-server.run.xml | 15 --
generic/README.md | 66 ++---
generic/README_zh.md | 66 ++---
generic/default/go-client/cmd/client.go | 230 +++++++++++++++--
generic/default/go-client/conf/client.yml | 59 -----
generic/default/go-client/conf/dubbogo.yml | 12 +
generic/default/go-client/conf/log.yml | 28 ---
generic/default/go-server/cmd/server.go | 25 +-
generic/default/go-server/conf/client.yml | 59 -----
generic/default/go-server/conf/dubbogo.yml | 16 ++
generic/default/go-server/conf/log.yml | 28 ---
generic/default/go-server/conf/server.yml | 55 ----
.../default/go-server/docker/docker-compose.yml | 9 -
.../go-server/docker/docker-health-check.sh | 10 -
generic/default/go-server/pkg/user.go | 121 ++++++++-
.../tests/integration/userprovider_test.go | 74 ------
generic/default/java-client/2.6/pom.xml | 79 ------
.../src/main/java/org/apache/dubbo/Consumer.java | 53 ----
generic/default/java-client/2.7/pom.xml | 126 ----------
.../src/main/java/org/apache/dubbo/Consumer.java | 53 ----
.../2.7/src/main/java/org/apache/dubbo/User.java | 77 ------
generic/default/java-client/pom.xml | 162 ++++++++++++
generic/default/java-client/run.sh | 2 +
.../main/java/org/apache/dubbo/ApiConsumer.java | 159 ++++++++++++
.../src/main/java/org/apache/dubbo/User.java | 2 +-
.../{2.7 => }/src/main/resources/log4j.properties | 0
generic/default/java-server/2.6/pom.xml | 79 ------
.../src/main/java/org/apache/dubbo/Provider.java | 34 ---
.../src/main/java/org/apache/dubbo/Response.java | 92 -------
.../2.6/src/main/java/org/apache/dubbo/User.java | 95 -------
.../org/apache/dubbo/UserProviderAnotherImpl.java | 143 -----------
.../java/org/apache/dubbo/UserProviderImpl.java | 115 ---------
.../resources/META-INF/spring/dubbo.provider.xml | 36 ---
.../2.6/src/main/resources/log4j.properties | 20 --
generic/default/java-server/2.7/pom.xml | 126 ----------
.../2.7/src/main/java/org/apache/dubbo/Gender.java | 23 --
.../src/main/java/org/apache/dubbo/Provider.java | 34 ---
.../main/java/org/apache/dubbo/UserProvider.java | 50 ----
.../java/org/apache/dubbo/UserProviderImpl.java | 115 ---------
.../resources/META-INF/spring/dubbo.provider.xml | 36 ---
.../2.7/src/main/resources/log4j.properties | 20 --
generic/default/java-server/pom.xml | 164 ++++++++++++
generic/default/java-server/run.sh | 2 +
.../main/java/org/apache/dubbo/ApiProvider.java | 40 +++
.../src/main/java/org/apache/dubbo/Gender.java | 46 ++--
.../src/main/java/org/apache/dubbo/Response.java | 0
.../src/main/java/org/apache/dubbo/User.java | 190 +++++++-------
.../main/java/org/apache/dubbo/UserProvider.java | 104 ++++----
.../java/org/apache/dubbo/UserProviderImpl.java} | 278 ++++++++++-----------
.../src/main/resources/log4j.properties | 1 +
generic/protobufjson/go-client/cmd/client.go | 114 ---------
generic/protobufjson/go-client/conf/client.yml | 59 -----
generic/protobufjson/go-client/conf/log.yml | 28 ---
generic/protobufjson/go-client/pkg/user.go | 33 ---
generic/protobufjson/go-server/cmd/server.go | 80 ------
generic/protobufjson/go-server/conf/client.yml | 59 -----
generic/protobufjson/go-server/conf/log.yml | 28 ---
generic/protobufjson/go-server/conf/server.yml | 55 ----
generic/protobufjson/go-server/pkg/user.go | 43 ----
generic/protobufjson/go-server/pkg/user.pb.go | 219 ----------------
.../go-server/tests/integration/main_test.go | 55 ----
.../tests/integration/userprovider_test.go | 47 ----
generic/protobufjson/user.proto | 14 --
.../generic/default}/docker/docker-compose.yml | 0
.../generic/default}/docker/docker-health-check.sh | 0
.../default}/tests/integration/main_test.go | 54 ++--
.../default/tests/integration/userprovider_test.go | 216 ++++++++++++++++
start_integrate_test.sh | 2 +
73 files changed, 1543 insertions(+), 3069 deletions(-)
diff --git a/.run/generic-default-go-client.run.xml b/.run/generic-default-go-client.run.xml
new file mode 100644
index 0000000..3457202
--- /dev/null
+++ b/.run/generic-default-go-client.run.xml
@@ -0,0 +1,14 @@
+<component name="ProjectRunConfigurationManager">
+ <configuration default="false" name="generic-default-go-client" type="GoApplicationRunConfiguration" factoryName="Go Application" folderName="v3config-generic">
+ <module name="dubbo-go-samples" />
+ <working_directory value="$PROJECT_DIR$" />
+ <envs>
+ <env name="DUBBO_GO_CONFIG_PATH" value="$PROJECT_DIR$/generic/default/go-client/conf/dubbogo.yml" />
+ </envs>
+ <kind value="PACKAGE" />
+ <package value="github.com/apache/dubbo-go-samples/generic/default/go-client/cmd" />
+ <directory value="$PROJECT_DIR$/generic/default/go-client/cmd" />
+ <filePath value="$PROJECT_DIR$/generic/default/go-client/cmd/client.go" />
+ <method v="2" />
+ </configuration>
+</component>
\ No newline at end of file
diff --git a/.run/generic-default-go-server.run.xml b/.run/generic-default-go-server.run.xml
new file mode 100644
index 0000000..c7423bd
--- /dev/null
+++ b/.run/generic-default-go-server.run.xml
@@ -0,0 +1,14 @@
+<component name="ProjectRunConfigurationManager">
+ <configuration default="false" name="generic-default-go-server" type="GoApplicationRunConfiguration" factoryName="Go Application" folderName="v3config-generic">
+ <module name="dubbo-go-samples" />
+ <working_directory value="$PROJECT_DIR$" />
+ <envs>
+ <env name="DUBBO_GO_CONFIG_PATH" value="$PROJECT_DIR$/generic/default/go-server/conf/dubbogo.yml" />
+ </envs>
+ <kind value="PACKAGE" />
+ <package value="github.com/apache/dubbo-go-samples/generic/default/go-server/cmd" />
+ <directory value="$PROJECT_DIR$/generic/default/go-server/cmd" />
+ <filePath value="$PROJECT_DIR$/generic/default/go-server/cmd/server.go" />
+ <method v="2" />
+ </configuration>
+</component>
\ No newline at end of file
diff --git a/.run/generic-default-java-client.run.xml b/.run/generic-default-java-client.run.xml
new file mode 100644
index 0000000..84bf92a
--- /dev/null
+++ b/.run/generic-default-java-client.run.xml
@@ -0,0 +1,17 @@
+<component name="ProjectRunConfigurationManager">
+ <configuration default="false" name="generic-default-java-client" type="ShConfigurationType" folderName="v3config-generic">
+ <option name="SCRIPT_TEXT" value="" />
+ <option name="INDEPENDENT_SCRIPT_PATH" value="false" />
+ <option name="SCRIPT_PATH" value="$PROJECT_DIR$/generic/default/java-client/run.sh" />
+ <option name="SCRIPT_OPTIONS" value="" />
+ <option name="INDEPENDENT_SCRIPT_WORKING_DIRECTORY" value="false" />
+ <option name="SCRIPT_WORKING_DIRECTORY" value="$PROJECT_DIR$/generic/default/java-client" />
+ <option name="INDEPENDENT_INTERPRETER_PATH" value="true" />
+ <option name="INTERPRETER_PATH" value="" />
+ <option name="INTERPRETER_OPTIONS" value="" />
+ <option name="EXECUTE_IN_TERMINAL" value="true" />
+ <option name="EXECUTE_SCRIPT_FILE" value="true" />
+ <envs />
+ <method v="2" />
+ </configuration>
+</component>
\ No newline at end of file
diff --git a/.run/generic-default-java-server.run.xml b/.run/generic-default-java-server.run.xml
new file mode 100644
index 0000000..b97b888
--- /dev/null
+++ b/.run/generic-default-java-server.run.xml
@@ -0,0 +1,17 @@
+<component name="ProjectRunConfigurationManager">
+ <configuration default="false" name="generic-default-java-server" type="ShConfigurationType" folderName="v3config-generic">
+ <option name="SCRIPT_TEXT" value="" />
+ <option name="INDEPENDENT_SCRIPT_PATH" value="false" />
+ <option name="SCRIPT_PATH" value="$PROJECT_DIR$/generic/default/java-server/run.sh" />
+ <option name="SCRIPT_OPTIONS" value="" />
+ <option name="INDEPENDENT_SCRIPT_WORKING_DIRECTORY" value="false" />
+ <option name="SCRIPT_WORKING_DIRECTORY" value="$PROJECT_DIR$/generic/default/java-server" />
+ <option name="INDEPENDENT_INTERPRETER_PATH" value="true" />
+ <option name="INTERPRETER_PATH" value="" />
+ <option name="INTERPRETER_OPTIONS" value="" />
+ <option name="EXECUTE_IN_TERMINAL" value="true" />
+ <option name="EXECUTE_SCRIPT_FILE" value="true" />
+ <envs />
+ <method v="2" />
+ </configuration>
+</component>
\ No newline at end of file
diff --git a/.run/generic-go-client.run.xml b/.run/generic-go-client.run.xml
deleted file mode 100644
index 5f62b11..0000000
--- a/.run/generic-go-client.run.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-<component name="ProjectRunConfigurationManager">
- <configuration default="false" name="generic-go-client" type="GoApplicationRunConfiguration" factoryName="Go Application">
- <module name="dubbo-go-samples" />
- <working_directory value="$PROJECT_DIR$" />
- <envs>
- <env name="APP_LOG_CONF_FILE" value="$PROJECT_DIR$/generic/go-client/conf/log.yml" />
- <env name="CONF_CONSUMER_FILE_PATH" value="$PROJECT_DIR$/generic/go-client/conf/client.yml" />
- </envs>
- <kind value="PACKAGE" />
- <filePath value="$PROJECT_DIR$/generic/go-client/cmd/client.go" />
- <package value="github.com/apache/dubbo-go-samples/generic/go-client/cmd" />
- <directory value="$PROJECT_DIR$" />
- <method v="2" />
- </configuration>
-</component>
\ No newline at end of file
diff --git a/.run/generic-go-server.run.xml b/.run/generic-go-server.run.xml
deleted file mode 100644
index 3d34d45..0000000
--- a/.run/generic-go-server.run.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-<component name="ProjectRunConfigurationManager">
- <configuration default="false" name="generic-go-server" type="GoApplicationRunConfiguration" factoryName="Go Application">
- <module name="dubbo-go-samples" />
- <working_directory value="$PROJECT_DIR$" />
- <envs>
- <env name="APP_LOG_CONF_FILE" value="$PROJECT_DIR$/generic/go-server/conf/log.yml" />
- <env name="CONF_PROVIDER_FILE_PATH" value="$PROJECT_DIR$/generic/go-server/conf/server.yml" />
- </envs>
- <kind value="PACKAGE" />
- <filePath value="$PROJECT_DIR$/generic/go-server/cmd/server.go" />
- <package value="github.com/apache/dubbo-go-samples/generic/go-server/cmd" />
- <directory value="$PROJECT_DIR$" />
- <method v="2" />
- </configuration>
-</component>
\ No newline at end of file
diff --git a/generic/README.md b/generic/README.md
index 5f5943e..b1e67f1 100644
--- a/generic/README.md
+++ b/generic/README.md
@@ -4,61 +4,39 @@ Generic invocation is mainly used when the client does not have API interface or
## Getting Started
-You should provide the information of config for both provider and consumer, in this case, we use `default` directory as an example.
+### Instructions
-```shell
-export CONF_PROVIDER_FILE_PATH="$(pwd)/default/go-server/conf/server.yml"
-export CONF_CONSUMER_FILE_PATH="$(pwd)/default/go-client/conf/client.yml"
-```
+1. Start zookeeper
-ZooKeeper is required as well, you could launch it using docker-compose.
+ ```shell
+ cd ./default/go-server/docker \
+ && docker-compose up -d
+ ```
-```shell
-cd ./default/go-server/docker \
- && docker-compose up -d
-```
+2. Start the server to run provider.
-### Map: Default Way
+ 1. go
-The case for map is at `default` directory. Launch the provider by the following code.
+ Use goland to start generic-default-go-server
-```shell
-cd ./default/go-server/cmd \
- && go run server.go
-```
+ 2. java
-Run the consumer to invoke generic invocations.
+ Use goland to start generic-default-java-server
+
+ or
-```shell
-cd ./default/go-client/cmd \
- && go run client.go
-```
+ Execute `sh run.sh` in the java-server folder to start the java server
-### Protobuf Json (Disabled)
+3. Start the client to run consumers to initiate generic invocation.
-The case for Protobuf Json is at `protobufjson` directory. The first step is to generate struct definitions with proto file. (The `user.api.go` is generated for integrated tests, but we highly recommend you generate by yourself.)
+ 1. go
-```shell
-cd ./protobufjson \
- && protoc --go_out=. user.proto
-```
+ Use goland to start generic-default-go-client
-Copy `user.api.go` file generated by protobuf to provider.
+ 2. java
-```shell
-mv ./protobufjson/user.api.go ./protobufjson/go-server/pkg
-```
+ Use goland to start generic-default-java-client
+
+ or
-Launch the provider by the following code.
-
-```shell
-cd ./protobufjson/go-server/cmd \
- && go run server.go
-```
-
-Run the consumer to invoke generic invocations.
-
-```shell
-cd ./protobufjson/go-client/cmd \
- && go run client.go
-```
+ Execute `sh run.sh` in the java-client folder to start the java client
\ No newline at end of file
diff --git a/generic/README_zh.md b/generic/README_zh.md
index 043bcbc..672b989 100644
--- a/generic/README_zh.md
+++ b/generic/README_zh.md
@@ -1,64 +1,42 @@
# 泛化调用
-泛化接口调用方式主要用于客户端没有 API 接口及模型类元的情况,参数及返回值中的所有 POJO 均用 Map 表示,通常用于框架集成,比如:实现一个通用的服务测试框架,可通过`GenericService`调用所有服务实现。更多信息请参与文档。
+泛化接口调用方式主要用于客户端没有 API 接口及模型类元的情况,参数及返回值中的所有 POJO 均用 Map 表示,通常用于框架集成,比如:实现一个通用的服务测试框架,可通过`GenericService`调用所有服务实现。更多信息请参考文档。
## 开始
-你需要提供提供者(provider)和消费者(consumer)的配置文件信息,在这个例子中,使用`default`文件夹作为示例。
+### 使用方法
-```shell
-export CONF_PROVIDER_FILE_PATH="$(pwd)/default/go-server/conf/server.yml"
-export CONF_CONSUMER_FILE_PATH="$(pwd)/default/go-client/conf/client.yml"
-```
+1. 启动 zookeeper
-ZooKeeper也是必须的,你可以使用docker-compose启动它。
+ ```shell
+ cd ./default/go-server/docker \
+ && docker-compose up -d
+ ```
-```shell
-cd ./default/go-server/docker \
- && docker-compose up -d
-```
+2. 启动服务端运行提供者
-### Map:默认方式
+ 1. go
-Map的例子放在`default`文件夹中。通过下面的代码启动提供者。
+ 使用 goland 启动 generic-default-go-server
-```shell
-cd ./default/go-server/cmd \
- && go run server.go
-```
+ 2. java
-运行消费者来发起泛化调用。
+ 在goland启动generic-default-java-server
+
+ 或
-```shell
-cd ./default/go-client/cmd \
- && go run client.go
-```
+ 在 java-server 文件夹下执行 `sh run.sh` 启动 java server
-### Protobuf Json (暂时禁用)
+3. 启动客户端运行消费者发启泛化调用
-Protobuf Json的例子放在`protobufjson`文件夹中。首先需要根据proto文件生成结构体定义。(注:`user.api.go`已经生成,这是为了CI的集成测试使用的,但是我们仍然强烈建议你自己生成一次。)
+ 1. go
-```shell
-cd ./protobufjson \
- && protoc --go_out=. user.proto
-```
+ 使用 goland 启动 generic-default-go-client
-拷贝`user.api.go`文件到提供者文件夹。
+ 2. java
-```shell
-mv ./protobufjson/user.api.go ./protobufjson/go-server/pkg
-```
+ 在goland启动generic-default-java-client
-通过下面的代码启动提供者。
+ 或
-```shell
-cd ./protobufjson/go-server/cmd \
- && go run server.go
-```
-
-运行消费者来发起泛化调用。
-
-```shell
-cd ./protobufjson/go-client/cmd \
- && go run client.go
-```
+ 在 java-client 文件夹下执行 `sh run.sh` 启动 java client
\ No newline at end of file
diff --git a/generic/default/go-client/cmd/client.go b/generic/default/go-client/cmd/client.go
index 5f428d9..1af7b8c 100644
--- a/generic/default/go-client/cmd/client.go
+++ b/generic/default/go-client/cmd/client.go
@@ -32,39 +32,56 @@ import (
"dubbo.apache.org/dubbo-go/v3/common/logger"
_ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory"
"dubbo.apache.org/dubbo-go/v3/config"
+ "dubbo.apache.org/dubbo-go/v3/config/generic"
_ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl"
"dubbo.apache.org/dubbo-go/v3/protocol/dubbo"
_ "dubbo.apache.org/dubbo-go/v3/registry/protocol"
_ "dubbo.apache.org/dubbo-go/v3/registry/zookeeper"
hessian "github.com/apache/dubbo-go-hessian2"
+)
- "github.com/dubbogo/gost/log"
+import (
+ "github.com/apache/dubbo-go-samples/generic/default/go-client/pkg"
)
var (
- appName = "UserConsumer"
+ appName = "dubbo.io"
+ referenceConfig config.ReferenceConfig
+)
+
+func init() {
+ registryConfig := &config.RegistryConfig{
+ Protocol: "zookeeper",
+ Address: "127.0.0.1:2181",
+ }
+
referenceConfig = config.ReferenceConfig{
InterfaceName: "org.apache.dubbo.UserProvider",
Cluster: "failover",
- Registry: "demoZk",
+ Registry: []string{"zk"},
Protocol: dubbo.DUBBO,
Generic: "true",
}
-)
-func init() {
- config.Load()
- referenceConfig.GenericLoad(appName) //appName is the unique identification of RPCService
- time.Sleep(3 * time.Second)
+ rootConfig := config.NewRootConfig(config.WithRootRegistryConfig("zk", registryConfig))
+ _ = rootConfig.Init()
+ _ = referenceConfig.Init(rootConfig)
+ referenceConfig.GenericLoad(appName)
}
-// need to setup environment variable "CONF_CONSUMER_FILE_PATH" to "conf/client.yml" before run
+// export DUBBO_GO_CONFIG_PATH= PATH_TO_SAMPLES/generic/default/go-client/conf/dubbogo.yml
func main() {
- gxlog.CInfo("\n\ncall getUser")
+ hessian.RegisterPOJO(&pkg.User{})
+
callGetUser()
- gxlog.CInfo("\n\ncall queryUser")
+ //callGetOneUser()
+ callGetUsers()
+ callGetUsersMap()
callQueryUser()
+ callQueryUsers()
+ //callQueryAll()
+
initSignal()
}
@@ -93,11 +110,12 @@ func initSignal() {
}
func callGetUser() {
- gxlog.CInfo("\n\n\nstart to generic invoke")
- resp, err := referenceConfig.GetRPCService().(*config.GenericService).Invoke(
+ logger.Infof("Call GetUser")
+ logger.Infof("Start to generic invoke")
+ resp, err := referenceConfig.GetRPCService().(*generic.GenericService).Invoke(
context.TODO(),
[]interface{}{
- "GetUser",
+ "GetUser1",
[]string{"java.lang.String"},
[]hessian.Object{"A003"},
},
@@ -105,13 +123,118 @@ func callGetUser() {
if err != nil {
panic(err)
}
- gxlog.CInfo("res: %+v\n", resp)
- gxlog.CInfo("success!")
+ logger.Infof("\n\nGetUser1(userId string) res: %+v\n", resp)
+
+ resp, err = referenceConfig.GetRPCService().(*generic.GenericService).Invoke(
+ context.TODO(),
+ []interface{}{
+ "GetUser2",
+ []string{"java.lang.String", "java.lang.String"},
+ []hessian.Object{"A003", "lily"},
+ },
+ )
+ if err != nil {
+ panic(err)
+ }
+ logger.Infof("\n\nGetUser2(userId string, name string) res: %+v\n", resp)
+
+ resp, err = referenceConfig.GetRPCService().(*generic.GenericService).Invoke(
+ context.TODO(),
+ []interface{}{
+ "GetUser3",
+ []string{"int"},
+ []hessian.Object{1},
+ },
+ )
+ if err != nil {
+ panic(err)
+ }
+ logger.Infof("\n\nGetUser3(userCode int) res: %+v\n", resp)
+
+ resp, err = referenceConfig.GetRPCService().(*generic.GenericService).Invoke(
+ context.TODO(),
+ []interface{}{
+ "GetUser4",
+ []string{"int", "java.lang.String"},
+ []hessian.Object{1, "zhangsan"},
+ },
+ )
+ if err != nil {
+ panic(err)
+ }
+ logger.Infof("\n\nGetUser4(userCode int, name string) res: %+v\n", resp)
+
+ logger.Infof("success!")
+}
+
+func callGetOneUser() {
+ logger.Infof("Call GetOneUser")
+ logger.Infof("Start to generic invoke")
+ resp, err := referenceConfig.GetRPCService().(*generic.GenericService).Invoke(
+ context.TODO(),
+ []interface{}{
+ "GetOneUser",
+ []string{},
+ // TODO go-go []hessian.Object{}, go-java []string{}
+ //[]hessian.Object{},
+ []hessian.Object{},
+ },
+ )
+ if err != nil {
+ panic(err)
+ }
+ logger.Infof("\n\nGetOneUser() res: %+v\n", resp)
+ logger.Infof("success!")
+}
+
+func callGetUsers() {
+ logger.Infof("Call GetUsers")
+ logger.Infof("Start to generic invoke")
+ resp, err := referenceConfig.GetRPCService().(*generic.GenericService).Invoke(
+ context.TODO(),
+ []interface{}{
+ "GetUsers",
+ []string{"java.util.List"},
+ []hessian.Object{
+ []hessian.Object{
+ "001", "002", "003", "004",
+ },
+ },
+ },
+ )
+ if err != nil {
+ panic(err)
+ }
+ logger.Infof("\n\nGetUsers1(userIdList []*string) res: %+v\n", resp)
+ logger.Infof("success!")
+}
+func callGetUsersMap() {
+ logger.Infof("Call GetUsersMap")
+ logger.Infof("Start to generic invoke")
+ resp, err := referenceConfig.GetRPCService().(*generic.GenericService).Invoke(
+ context.TODO(),
+ []interface{}{
+ "GetUsersMap",
+ []string{"java.util.List"},
+ []hessian.Object{
+ []hessian.Object{
+ "001", "002", "003", "004",
+ },
+ },
+ },
+ )
+ if err != nil {
+ panic(err)
+ }
+ logger.Infof("\n\nGetUserMap(userIdList []*string) res: %+v\n", resp)
+ logger.Infof("success!")
}
+
func callQueryUser() {
- gxlog.CInfo("\n\n\nstart to generic invoke")
- resp, err := referenceConfig.GetRPCService().(*config.GenericService).Invoke(
+ logger.Infof("Call QueryUser")
+ logger.Infof("Start to generic invoke")
+ resp, err := referenceConfig.GetRPCService().(*generic.GenericService).Invoke(
context.TODO(),
[]interface{}{
"queryUser",
@@ -123,18 +246,73 @@ func callQueryUser() {
// Age: 25,
// Time: time.Now(),
// }
- []hessian.Object{map[string]hessian.Object{
- "iD": "3213",
- "name": "panty",
- "age": 25,
- "time": time.Now(),
- }},
+ []hessian.Object{
+ map[string]hessian.Object{
+ "iD": "3213",
+ "name": "panty",
+ "age": 25,
+ "time": time.Now(),
+ }},
+ },
+ )
+ if err != nil {
+ panic(err)
+ }
+ logger.Infof("\n\nqueryUser(user *User) res: %+v\n", resp)
+ logger.Infof("success!")
+}
+
+func callQueryUsers() {
+ logger.Infof("Call QueryUsers")
+ logger.Infof("Start to generic invoke")
+ var resp, err = referenceConfig.GetRPCService().(*generic.GenericService).Invoke(
+ context.TODO(),
+ []interface{}{
+ "queryUsers",
+ []string{"java.util.ArrayList"},
+ []hessian.Object{
+ []hessian.Object{
+ map[string]hessian.Object{
+ "id": "3212",
+ "name": "XavierNiu",
+ "age": 24,
+ "time": time.Now().Add(4),
+ "class": "org.apache.dubbo.User",
+ },
+ map[string]hessian.Object{
+ "iD": "3213",
+ "name": "zhangsan",
+ "age": 21,
+ "time": time.Now().Add(4),
+ "class": "org.apache.dubbo.User",
+ },
+ },
+ },
},
)
if err != nil {
panic(err)
}
- gxlog.CInfo("res: %+v\n", resp)
- gxlog.CInfo("success!")
+ logger.Infof("\n\nqueryUsers(users []*User) res: %+v\n", resp)
+ logger.Infof("success!")
+}
+func callQueryAll() {
+ logger.Infof("Call queryAll")
+ logger.Infof("Start to generic invoke")
+ resp, err := referenceConfig.GetRPCService().(*generic.GenericService).Invoke(
+ context.TODO(),
+ []interface{}{
+ "queryAll",
+ []string{},
+ // TODO go-go []hessian.Object{}, go-java []string{}
+ //[]hessian.Object{},
+ []hessian.Object{},
+ },
+ )
+ if err != nil {
+ panic(err)
+ }
+ logger.Infof("\n\nqueryAll() res: %+v\n", resp)
+ logger.Infof("success!")
}
diff --git a/generic/default/go-client/conf/client.yml b/generic/default/go-client/conf/client.yml
deleted file mode 100644
index 047d367..0000000
--- a/generic/default/go-client/conf/client.yml
+++ /dev/null
@@ -1,59 +0,0 @@
-# dubbo client yaml configure file
-
-check: true
-# client
-request_timeout : "3s"
-# connect timeout
-connect_timeout : "3s"
-
-# application config
-application:
- organization : "dubbo.io"
- name : "UserConsumer"
- module : "dubbo-go user-info client"
- version : "0.0.1"
- environment : "dev"
-
-# registry config
-registries :
- "demoZk":
- protocol: "zookeeper"
- timeout : "3s"
- address: "127.0.0.1:2181"
- username: ""
- password: ""
-
-# reference config
-references:
- "UserProvider":
- registry: "demoZk"
- protocol : "dubbo"
- interface : "org.apache.dubbo.UserProvider"
- cluster: "failover"
- methods :
- - name: "GetUser"
- retries: 3
-
-# protocol config
-protocol_conf:
- dubbo:
- reconnect_interval: 0
- connection_number: 1
- heartbeat_period: "5s"
- session_timeout: "180s"
- pool_size: 64
- pool_ttl: 600
- getty_session_param:
- compress_encoding: false
- tcp_no_delay: true
- tcp_keep_alive: true
- keep_alive_period: "120s"
- tcp_r_buf_size: 262144
- tcp_w_buf_size: 65536
- pkg_rq_size: 1024
- pkg_wq_size: 512
- tcp_read_timeout: "1s"
- tcp_write_timeout: "5s"
- wait_timeout: "1s"
- max_msg_len: 1024000
- session_name: "client"
diff --git a/generic/default/go-client/conf/dubbogo.yml b/generic/default/go-client/conf/dubbogo.yml
new file mode 100644
index 0000000..771c75b
--- /dev/null
+++ b/generic/default/go-client/conf/dubbogo.yml
@@ -0,0 +1,12 @@
+dubbo:
+ registries:
+ zk:
+ protocol: zookeeper
+ timeout: 3s
+ address: 127.0.0.1:2181
+ consumer:
+ registry: zk
+ references:
+ UserProvider:
+ protocol: dubbo
+ interface: org.apache.dubbo.UserProvider # must be compatible with grpc or dubbo-java
\ No newline at end of file
diff --git a/generic/default/go-client/conf/log.yml b/generic/default/go-client/conf/log.yml
deleted file mode 100644
index d19d907..0000000
--- a/generic/default/go-client/conf/log.yml
+++ /dev/null
@@ -1,28 +0,0 @@
-
-level: "warn"
-development: true
-disableCaller: false
-disableStacktrace: false
-sampling:
-encoding: "console"
-
-# encoder
-encoderConfig:
- messageKey: "message"
- levelKey: "level"
- timeKey: "time"
- nameKey: "logger"
- callerKey: "caller"
- stacktraceKey: "stacktrace"
- lineEnding: ""
- levelEncoder: "capital"
- timeEncoder: "iso8601"
- durationEncoder: "seconds"
- callerEncoder: "short"
- nameEncoder: ""
-
-outputPaths:
- - "stderr"
-errorOutputPaths:
- - "stderr"
-initialFields:
diff --git a/generic/default/go-server/cmd/server.go b/generic/default/go-server/cmd/server.go
index f73c7ae..7100ad3 100644
--- a/generic/default/go-server/cmd/server.go
+++ b/generic/default/go-server/cmd/server.go
@@ -26,39 +26,30 @@ import (
)
import (
- _ "dubbo.apache.org/dubbo-go/v3/cluster/cluster_impl"
- _ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance"
"dubbo.apache.org/dubbo-go/v3/common/logger"
- _ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory"
"dubbo.apache.org/dubbo-go/v3/config"
- _ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl"
- _ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo"
- _ "dubbo.apache.org/dubbo-go/v3/registry/protocol"
- _ "dubbo.apache.org/dubbo-go/v3/registry/zookeeper"
+ _ "dubbo.apache.org/dubbo-go/v3/imports"
hessian "github.com/apache/dubbo-go-hessian2"
)
import (
- "github.com/apache/dubbo-go-samples/generic/default/go-server/pkg"
+ pkg "github.com/apache/dubbo-go-samples/generic/default/go-server/pkg"
)
-var (
- survivalTimeout = int(3e9)
-)
-
-// need to setup environment variable "CONF_PROVIDER_FILE_PATH" to "conf/server.yml" before run
+// export DUBBO_GO_CONFIG_PATH= PATH_TO_SAMPLES/generic/default/go-server/conf/dubbogo.yml
func main() {
hessian.RegisterPOJO(&pkg.User{})
+ config.SetProviderService(&pkg.User{})
config.Load()
-
initSignal()
}
func initSignal() {
signals := make(chan os.Signal, 1)
// It is not possible to block SIGKILL or syscall.SIGSTOP
- signal.Notify(signals, os.Interrupt, os.Kill, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
+ signal.Notify(signals, os.Interrupt, os.Kill, syscall.SIGHUP,
+ syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
for {
sig := <-signals
logger.Infof("get signal %s", sig.String())
@@ -66,13 +57,13 @@ func initSignal() {
case syscall.SIGHUP:
// reload()
default:
- time.AfterFunc(time.Duration(survivalTimeout), func() {
+ time.AfterFunc(10*time.Second, func() {
logger.Warnf("app exit now by force...")
os.Exit(1)
})
// The program exits normally or timeout forcibly exits.
- fmt.Println("provider app exit now...")
+ fmt.Println("app exit now...")
return
}
}
diff --git a/generic/default/go-server/conf/client.yml b/generic/default/go-server/conf/client.yml
deleted file mode 100644
index eec5777..0000000
--- a/generic/default/go-server/conf/client.yml
+++ /dev/null
@@ -1,59 +0,0 @@
-# dubbo client yaml configure file
-
-check: true
-# client
-request_timeout : "3s"
-# connect timeout
-connect_timeout : "3s"
-
-# application config
-application:
- organization : "dubbo.io"
- name : "UserConsumerTest"
- module : "dubbo-go user-info client"
- version : "0.0.1"
- environment : "dev"
-
-# registry config
-registries :
- "demoZk":
- protocol: "zookeeper"
- timeout : "3s"
- address: "127.0.0.1:2181"
- username: ""
- password: ""
-
-# reference config
-references:
- "UserProvider":
- registry: "demoZk"
- protocol : "dubbo"
- interface : "org.apache.dubbo.UserProvider"
- cluster: "failover"
- methods :
- - name: "GetUser"
- retries: 3
-
-# protocol config
-protocol_conf:
- dubbo:
- reconnect_interval: 0
- connection_number: 1
- heartbeat_period: "5s"
- session_timeout: "180s"
- pool_size: 64
- pool_ttl: 600
- getty_session_param:
- compress_encoding: false
- tcp_no_delay: true
- tcp_keep_alive: true
- keep_alive_period: "120s"
- tcp_r_buf_size: 262144
- tcp_w_buf_size: 65536
- pkg_rq_size: 1024
- pkg_wq_size: 512
- tcp_read_timeout: "1s"
- tcp_write_timeout: "5s"
- wait_timeout: "1s"
- max_msg_len: 1024000
- session_name: "client"
diff --git a/generic/default/go-server/conf/dubbogo.yml b/generic/default/go-server/conf/dubbogo.yml
new file mode 100644
index 0000000..aa70d6a
--- /dev/null
+++ b/generic/default/go-server/conf/dubbogo.yml
@@ -0,0 +1,16 @@
+dubbo:
+ registries:
+ zk:
+ protocol: zookeeper
+ timeout: 3s
+ address: 127.0.0.1:2181
+ protocols:
+ dubbo:
+ name: dubbo
+ port: 20000
+ provider:
+ registry: zk
+ services:
+ UserProvider:
+ protocol: dubbo
+ interface: org.apache.dubbo.UserProvider
\ No newline at end of file
diff --git a/generic/default/go-server/conf/log.yml b/generic/default/go-server/conf/log.yml
deleted file mode 100644
index a75bccb..0000000
--- a/generic/default/go-server/conf/log.yml
+++ /dev/null
@@ -1,28 +0,0 @@
-
-level: "error"
-development: true
-disableCaller: false
-disableStacktrace: false
-sampling:
-encoding: "console"
-
-# encoder
-encoderConfig:
- messageKey: "message"
- levelKey: "level"
- timeKey: "time"
- nameKey: "logger"
- callerKey: "caller"
- stacktraceKey: "stacktrace"
- lineEnding: ""
- levelEncoder: "capital"
- timeEncoder: "iso8601"
- durationEncoder: "seconds"
- callerEncoder: "short"
- nameEncoder: ""
-
-outputPaths:
- - "stderr"
-errorOutputPaths:
- - "stderr"
-initialFields:
diff --git a/generic/default/go-server/conf/server.yml b/generic/default/go-server/conf/server.yml
deleted file mode 100644
index 6e8970c..0000000
--- a/generic/default/go-server/conf/server.yml
+++ /dev/null
@@ -1,55 +0,0 @@
-# dubbo server yaml configure file
-
-# application config
-application:
- organization : "dubbo.io"
- name : "UserInfoServer"
- module : "dubbo-go user-info server"
- version : "0.0.1"
- environment : "dev"
-
-# registry config
-registries :
- "demoZk":
- protocol: "zookeeper"
- timeout : "3s"
- address: "127.0.0.1:2181"
-
-# service config
-services:
- "UserProvider":
- registry: "demoZk"
- protocol : "dubbo"
- interface : "org.apache.dubbo.UserProvider"
- loadbalance: "random"
- warmup: "100"
- cluster: "failover"
- methods:
- - name: "GetUser"
- retries: 1
- loadbalance: "random"
-
-# protocol config
-protocols:
- "dubbo":
- name: "dubbo"
- port: 20000
-
-protocol_conf:
- dubbo:
- session_number: 700
- session_timeout: "180s"
- getty_session_param:
- compress_encoding: false
- tcp_no_delay: true
- tcp_keep_alive: true
- keep_alive_period: "120s"
- tcp_r_buf_size: 262144
- tcp_w_buf_size: 65536
- pkg_rq_size: 1024
- pkg_wq_size: 512
- tcp_read_timeout: "1s"
- tcp_write_timeout: "5s"
- wait_timeout: "1s"
- max_msg_len: 1024000
- session_name: "server"
diff --git a/generic/default/go-server/docker/docker-compose.yml b/generic/default/go-server/docker/docker-compose.yml
deleted file mode 100644
index 8724179..0000000
--- a/generic/default/go-server/docker/docker-compose.yml
+++ /dev/null
@@ -1,9 +0,0 @@
-version: '3'
-
-services:
- zookeeper:
- image: zookeeper
- ports:
- - 2181:2181
- restart: on-failure
-
diff --git a/generic/default/go-server/docker/docker-health-check.sh b/generic/default/go-server/docker/docker-health-check.sh
deleted file mode 100644
index 2cc32c2..0000000
--- a/generic/default/go-server/docker/docker-health-check.sh
+++ /dev/null
@@ -1,10 +0,0 @@
-curl 127.0.0.1:2181
-res=$?
-passCode=52
-while [ "$res" != "$passCode" ];do
- sleep 5
- curl 127.0.0.1:2181
- res=$?
-done
-
-sleep 5
diff --git a/generic/default/go-server/pkg/user.go b/generic/default/go-server/pkg/user.go
index f2288cf..3295836 100644
--- a/generic/default/go-server/pkg/user.go
+++ b/generic/default/go-server/pkg/user.go
@@ -19,21 +19,24 @@ package pkg
import (
"context"
+ "strconv"
"time"
)
import (
+ "dubbo.apache.org/dubbo-go/v3/common/logger"
"dubbo.apache.org/dubbo-go/v3/config"
hessian "github.com/apache/dubbo-go-hessian2"
-
- "github.com/dubbogo/gost/log"
)
func init() {
config.SetProviderService(new(UserProvider))
// ------for hessian2------
hessian.RegisterPOJO(&User{})
+ hessian.RegisterPOJO(&UserResponse{})
+
+ initUserMap()
}
type User struct {
@@ -43,26 +46,118 @@ type User struct {
Time time.Time
}
+type UserResponse struct {
+ Users []*User
+}
+
type UserProvider struct {
}
-func (u *UserProvider) GetUser(ctx context.Context, userID string) (*User, error) {
- gxlog.CInfo("req:%#v", userID)
- rsp := User{"A001", "Alex Stocks", 18, time.Now()}
- gxlog.CInfo("rsp:%#v", rsp)
+var userMap = make(map[string]*User)
+
+func initUserMap() {
+ userMap["001"] = &User{"001", "other-zhangsan", 23, time.Date(1998, 1, 2, 3, 4, 5, 0, time.Local)}
+ userMap["002"] = &User{"002", "other-lisi", 25, time.Date(1996, 1, 2, 3, 4, 5, 0, time.Local)}
+ userMap["003"] = &User{"003", "other-lily", 28, time.Date(1993, 1, 2, 3, 4, 5, 0, time.Local)}
+ userMap["004"] = &User{"004", "other-lisa", 36, time.Date(1985, 1, 2, 3, 4, 5, 0, time.Local)}
+}
+
+func (u *UserProvider) GetUser1(_ context.Context, userID string) (*User, error) {
+ logger.Infof("req:%#v", userID)
+ rsp := User{userID, "Joe", 48, time.Now()}
+ logger.Infof("rsp:%#v", rsp)
+ return &rsp, nil
+}
+
+func (u *UserProvider) GetUser2(_ context.Context, userID string, name string) (*User, error) {
+ logger.Infof("req:%#v, %#v", userID, name)
+ rsp := User{userID, name, 48, time.Now()}
+ logger.Infof("rsp:%#v", rsp)
+ return &rsp, nil
+}
+
+func (u *UserProvider) GetUser3(_ context.Context, userCode int) (*User, error) {
+ logger.Infof("req:%#v", userCode)
+ rsp := User{strconv.Itoa(userCode), "Alex Stocks", 18, time.Now()}
+ logger.Infof("rsp:%#v", rsp)
+ return &rsp, nil
+}
+
+func (u *UserProvider) GetUser4(_ context.Context, userCode int, name string) (*User, error) {
+ logger.Infof("req:%#v, %#v", userCode, name)
+ rsp := User{strconv.Itoa(userCode), name, 18, time.Now()}
+ logger.Infof("rsp:%#v", rsp)
return &rsp, nil
}
-func (u *UserProvider) QueryUser(ctx context.Context, user *User) (*User, error) {
- gxlog.CInfo("req1:%#v", user)
+func (u *UserProvider) GetOneUser(_ context.Context) (*User, error) {
+ return &User{
+ ID: "1000",
+ Name: "xavierniu",
+ Age: 24,
+ Time: time.Now(),
+ }, nil
+}
+
+func (u *UserProvider) GetUsers(_ context.Context, userIdList []string) (*UserResponse, error) {
+ logger.Infof("req:%#v", userIdList)
+ var users []*User
+ for _, i := range userIdList {
+ users = append(users, userMap[i])
+ }
+ return &UserResponse{
+ Users: users,
+ }, nil
+}
+
+func (u *UserProvider) GetUsersMap(_ context.Context, userIdList []string) (map[string]*User, error) {
+ logger.Infof("req:%#v", userIdList)
+ var users = make(map[string]*User)
+ for _, i := range userIdList {
+ users[i] = userMap[i]
+ }
+ return users, nil
+}
+
+func (u *UserProvider) QueryUser(_ context.Context, user *User) (*User, error) {
+ logger.Infof("req1:%#v", user)
rsp := User{user.ID, user.Name, user.Age, time.Now()}
- gxlog.CInfo("rsp1:%#v", rsp)
+ logger.Infof("rsp1:%#v", rsp)
return &rsp, nil
}
+func (u *UserProvider) QueryUsers(_ context.Context, users []*User) (*UserResponse, error) {
+ return &UserResponse{
+ Users: users,
+ }, nil
+}
+
+func (u *UserProvider) QueryAll(_ context.Context) (*UserResponse, error) {
+ users := []*User{
+ {
+ ID: "001",
+ Name: "Joe",
+ Age: 18,
+ Time: time.Now(),
+ },
+ {
+ ID: "002",
+ Name: "Wen",
+ Age: 20,
+ Time: time.Now(),
+ },
+ }
+
+ return &UserResponse{
+ Users: users,
+ }, nil
+}
+
func (u *UserProvider) MethodMapper() map[string]string {
return map[string]string{
- "QueryUser": "queryUser",
+ "QueryUser": "queryUser",
+ "QueryUsers": "queryUsers",
+ "QueryAll": "queryAll",
}
}
@@ -70,6 +165,10 @@ func (u *UserProvider) Reference() string {
return "UserProvider"
}
-func (u User) JavaClassName() string {
+func (u *User) JavaClassName() string {
return "org.apache.dubbo.User"
}
+
+func (u *UserResponse) JavaClassName() string {
+ return "org.apache.dubbo.UserResponse"
+}
diff --git a/generic/default/go-server/tests/integration/userprovider_test.go b/generic/default/go-server/tests/integration/userprovider_test.go
deleted file mode 100644
index 6b8971a..0000000
--- a/generic/default/go-server/tests/integration/userprovider_test.go
+++ /dev/null
@@ -1,74 +0,0 @@
-// +build integration
-
-/*
- * 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 integration
-
-import (
- "context"
- "testing"
- "time"
-)
-
-import (
- "dubbo.apache.org/dubbo-go/v3/config"
-
- hessian "github.com/apache/dubbo-go-hessian2"
-
- "github.com/stretchr/testify/assert"
-)
-
-func TestGetUser(t *testing.T) {
- o, err := referenceConfig.GetRPCService().(*config.GenericService).Invoke(
- context.TODO(),
- []interface{}{
- "GetUser",
- []string{"java.lang.String"},
- []hessian.Object{"A003"},
- },
- )
- assert.Nil(t, err)
- assert.IsType(t, make(map[interface{}]interface{}, 0), o)
- resp := o.(map[interface{}]interface{})
- assert.Equal(t, "Alex Stocks", resp["name"])
- assert.Equal(t, int32(18), resp["age"])
- assert.Equal(t, "A001", resp["iD"])
-}
-
-func TestQueryUser(t *testing.T) {
- o, err := referenceConfig.GetRPCService().(*config.GenericService).Invoke(
- context.TODO(),
- []interface{}{
- "queryUser",
- []string{"org.apache.dubbo.User"},
- []hessian.Object{map[string]hessian.Object{
- "iD": "3213",
- "name": "panty",
- "age": 25,
- "time": time.Now(),
- }},
- },
- )
-
- assert.Nil(t, err)
- assert.IsType(t, make(map[interface{}]interface{}, 0), o)
- resp := o.(map[interface{}]interface{})
- assert.Equal(t, "panty", resp["name"])
- assert.Equal(t, int32(25), resp["age"])
- assert.Equal(t, "3213", resp["iD"])
-}
diff --git a/generic/default/java-client/2.6/pom.xml b/generic/default/java-client/2.6/pom.xml
deleted file mode 100644
index 908dfdb..0000000
--- a/generic/default/java-client/2.6/pom.xml
+++ /dev/null
@@ -1,79 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<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/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>org.apache.dubbo</groupId>
- <artifactId>2.6</artifactId>
- <version>0.0.1</version>
-
- <properties>
- <skip_maven_deploy>false</skip_maven_deploy>
- <dubbo-version>2.6.5</dubbo-version>
- <curator.version>2.12.0</curator.version>
- <zk.version>3.4.14</zk.version>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>1.7.25</version>
- </dependency>
-
- <dependency>
- <groupId>com.alibaba</groupId>
- <artifactId>dubbo</artifactId>
- <version>${dubbo-version}</version>
- <exclusions>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>io.netty</groupId>
- <artifactId>netty-all</artifactId>
- <version>4.1.25.Final</version>
- </dependency>
- <dependency>
- <groupId>org.apache.curator</groupId>
- <artifactId>curator-framework</artifactId>
- <version>${curator.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>jetty</artifactId>
- <version>6.1.26</version>
- </dependency>
-
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-core</artifactId>
- <version>2.10.0</version>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-databind</artifactId>
- <version>2.10.0</version>
- </dependency>
-
- <dependency>
- <groupId>com.github.sgroschupf</groupId>
- <artifactId>zkclient</artifactId>
- <version>0.1</version>
- <exclusions>
- <exclusion>
- <artifactId>org.apache.zookeeper</artifactId>
- <groupId>zookeeper</groupId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.apache.zookeeper</groupId>
- <artifactId>zookeeper</artifactId>
- <version>${zk.version}</version>
- </dependency>
- </dependencies>
-</project>
\ No newline at end of file
diff --git a/generic/default/java-client/2.6/src/main/java/org/apache/dubbo/Consumer.java b/generic/default/java-client/2.6/src/main/java/org/apache/dubbo/Consumer.java
deleted file mode 100644
index 0e9e952..0000000
--- a/generic/default/java-client/2.6/src/main/java/org/apache/dubbo/Consumer.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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;
-
-import com.alibaba.dubbo.config.ApplicationConfig;
-import com.alibaba.dubbo.config.ReferenceConfig;
-import com.alibaba.dubbo.config.RegistryConfig;
-import com.alibaba.dubbo.rpc.service.GenericService;
-
-public class Consumer {
- public static void main(String[] args) {
-
- System.out.println("\n\n\nstart to generic invoke");
- ApplicationConfig applicationConfig = new ApplicationConfig();
- ReferenceConfig<GenericService> reference = new ReferenceConfig<GenericService>();
- applicationConfig.setName("UserProviderGer");
- reference.setApplication(applicationConfig);
- RegistryConfig registryConfig = new RegistryConfig();
- registryConfig.setAddress("zookeeper://127.0.0.1:2181");
- reference.setRegistry(registryConfig);
- reference.setGeneric(true);
- reference.setInterface("com.ikurento.user.UserProvider");
- GenericService genericService = reference.get();
- Object[] parameterArgs = new Object[]{"A003"};
- Object result = genericService.$invoke("GetUser", null , parameterArgs);
- System.out.println("res: " + result);
-
- System.out.println("\n\n\nstart to generic invoke1");
- User user = new User();
- user.setName("Patrick");
- user.setId("id");
- user.setAge(10);
- parameterArgs = new Object[]{user};
- Object result1 = genericService.$invoke("queryUser", new String[]{"com.ikurento.user.User"} , parameterArgs);
- System.out.println("res: " + result1);
- }
-
-}
diff --git a/generic/default/java-client/2.7/pom.xml b/generic/default/java-client/2.7/pom.xml
deleted file mode 100644
index 50dd888..0000000
--- a/generic/default/java-client/2.7/pom.xml
+++ /dev/null
@@ -1,126 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<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/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>org.apache.dubbo</groupId>
- <artifactId>2.7</artifactId>
- <version>0.0.1</version>
-
- <properties>
- <skip_maven_deploy>false</skip_maven_deploy>
- <dubbo-version>2.7.7</dubbo-version>
- <curator.version>2.12.0</curator.version>
- <zk.version>3.4.14</zk.version>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>1.7.25</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo</artifactId>
- <version>${dubbo-version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-spring-boot-starter</artifactId>
- <version>${dubbo-version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.curator</groupId>
- <artifactId>curator-framework</artifactId>
- <version>${curator.version}</version>
- <exclusions>
- <exclusion>
- <artifactId>zookeeper</artifactId>
- <groupId>org.apache.zookeeper</groupId>
- </exclusion>
- <exclusion>
- <artifactId>slf4j-api</artifactId>
- <groupId>org.slf4j</groupId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.curator</groupId>
- <artifactId>curator-recipes</artifactId>
- <version>2.8.0</version>
- <exclusions>
- <exclusion>
- <artifactId>zookeeper</artifactId>
- <groupId>org.apache.zookeeper</groupId>
- </exclusion>
- <exclusion>
- <artifactId>curator-framework</artifactId>
- <groupId>org.apache.curator</groupId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>io.netty</groupId>
- <artifactId>netty-all</artifactId>
- <version>4.1.25.Final</version>
- </dependency>
-
- <dependency>
- <groupId>jetty</groupId>
- <artifactId>org.mortbay.jetty</artifactId>
- <version>6.0.0alpha3</version>
- </dependency>
- <dependency>
- <groupId>jetty</groupId>
- <artifactId>jetty-util</artifactId>
- <version>6.0.0</version>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>javax.servlet-api</artifactId>
- <version>4.0.0</version>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-core</artifactId>
- <version>2.10.0</version>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-databind</artifactId>
- <version>2.10.0</version>
- </dependency>
-
- <dependency>
- <groupId>com.github.sgroschupf</groupId>
- <artifactId>zkclient</artifactId>
- <version>0.1</version>
- <exclusions>
- <exclusion>
- <artifactId>org.apache.zookeeper</artifactId>
- <groupId>zookeeper</groupId>
- </exclusion>
- <exclusion>
- <artifactId>log4j</artifactId>
- <groupId>log4j</groupId>
- </exclusion>
- <exclusion>
- <artifactId>zookeeper</artifactId>
- <groupId>org.apache.zookeeper</groupId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.apache.zookeeper</groupId>
- <artifactId>zookeeper</artifactId>
- <version>${zk.version}</version>
- </dependency>
-
- </dependencies>
-</project>
\ No newline at end of file
diff --git a/generic/default/java-client/2.7/src/main/java/org/apache/dubbo/Consumer.java b/generic/default/java-client/2.7/src/main/java/org/apache/dubbo/Consumer.java
deleted file mode 100644
index 3c32a70..0000000
--- a/generic/default/java-client/2.7/src/main/java/org/apache/dubbo/Consumer.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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;
-
-import org.apache.dubbo.config.ApplicationConfig;
-import org.apache.dubbo.config.ReferenceConfig;
-import org.apache.dubbo.config.RegistryConfig;
-import org.apache.dubbo.rpc.service.GenericService;
-
-public class Consumer {
- public static void main(String[] args) {
-
- System.out.println("\n\n\nstart to generic invoke");
- ApplicationConfig applicationConfig = new ApplicationConfig();
- ReferenceConfig<GenericService> reference = new ReferenceConfig<GenericService>();
- applicationConfig.setName("UserProviderGer");
- reference.setApplication(applicationConfig);
- RegistryConfig registryConfig = new RegistryConfig();
- registryConfig.setAddress("zookeeper://127.0.0.1:2181");
- reference.setRegistry(registryConfig);
- reference.setGeneric(true);
- reference.setInterface("org.apache.dubbo.UserProvider");
- GenericService genericService = reference.get();
- Object[] parameterArgs = new Object[]{"A003"};
- Object result = genericService.$invoke("GetUser", null , parameterArgs);
- System.out.println("res: " + result);
-
- System.out.println("\n\n\nstart to generic invoke1");
- User user = new User();
- user.setName("Patrick");
- user.setId("id");
- user.setAge(10);
- parameterArgs = new Object[]{user};
- Object result1 = genericService.$invoke("queryUser", new String[]{"com.ikurento.user.User"} , parameterArgs);
- System.out.println("res: " + result1);
- }
-
-}
diff --git a/generic/default/java-client/2.7/src/main/java/org/apache/dubbo/User.java b/generic/default/java-client/2.7/src/main/java/org/apache/dubbo/User.java
deleted file mode 100644
index 1fa1831..0000000
--- a/generic/default/java-client/2.7/src/main/java/org/apache/dubbo/User.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * 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;
-
-import java.util.Date;
-import java.io.Serializable;
-
-public class User implements Serializable{
-
- private String id;
-
- private String name;
-
- private int age;
-
- private Date time = new Date();
-
-
- public User() {
- }
-
-
- public User(String id, String name, int age) {
- this.id = id;
- this.name = name;
- this.age = age;
- }
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public int getAge() {
- return age;
- }
-
- public void setAge(int age) {
- this.age = age;
- }
-
- public Date getTime() {
- return time;
- }
-
- public void setTime(Date time) {
- this.time = time;
- }
-
-
-}
diff --git a/generic/default/java-client/pom.xml b/generic/default/java-client/pom.xml
new file mode 100644
index 0000000..ecbe628
--- /dev/null
+++ b/generic/default/java-client/pom.xml
@@ -0,0 +1,162 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.dubbo</groupId>
+ <version>1.0-SNAPSHOT</version>
+ <artifactId>generic-dubbo-java-client</artifactId>
+
+ <properties>
+ <source.level>1.8</source.level>
+ <target.level>1.8</target.level>
+ <dubbo.version>3.0.2</dubbo.version>
+ <junit.version>4.12</junit.version>
+ <spring-test.version>4.3.16.RELEASE</spring-test.version>
+ <maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
+ <maven-failsafe-plugin.version>2.21.0</maven-failsafe-plugin.version>
+ <spring-boot.version>1.5.13.RELEASE</spring-boot.version>
+ <grpc.version>1.19.0</grpc.version>
+ <protoc.version>3.7.1</protoc.version>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo</artifactId>
+ <version>${dubbo.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.protobuf</groupId>
+ <artifactId>protobuf-java</artifactId>
+ <version>3.14.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-dependencies-zookeeper</artifactId>
+ <version>${dubbo.version}</version>
+ <type>pom</type>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.zookeeper</groupId>
+ <artifactId>zookeeper</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.zookeeper</groupId>
+ <artifactId>zookeeper</artifactId>
+ <version>3.4.8</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${junit.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <version>${spring-test.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.testcontainers</groupId>
+ <artifactId>testcontainers</artifactId>
+ <version>1.12.3</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <profiles>
+ <!-- For jdk 11 above JavaEE annotation -->
+ <profile>
+ <id>javax.annotation</id>
+ <activation>
+ <jdk>[1.11,)</jdk>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>javax.annotation-api</artifactId>
+ <version>1.3.2</version>
+ </dependency>
+ </dependencies>
+ </profile>
+ </profiles>
+
+ <build>
+ <extensions>
+ <extension>
+ <groupId>kr.motd.maven</groupId>
+ <artifactId>os-maven-plugin</artifactId>
+ <version>1.6.1</version>
+ </extension>
+ </extensions>
+ <plugins>
+ <plugin>
+ <groupId>org.xolstice.maven.plugins</groupId>
+ <artifactId>protobuf-maven-plugin</artifactId>
+ <version>0.6.1</version>
+ <configuration>
+ <protocArtifact>com.google.protobuf:protoc:3.17.3:exe:${os.detected.classifier}</protocArtifact>
+ <pluginId>triple-java</pluginId>
+ <outputDirectory>build/generated/source/proto/main/java</outputDirectory>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>compile</goal>
+ <goal>test-compile</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>${maven-compiler-plugin.version}</version>
+ <configuration>
+ <source>${source.level}</source>
+ <target>${target.level}</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>build/generated/source/proto/main/java</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
\ No newline at end of file
diff --git a/generic/default/java-client/run.sh b/generic/default/java-client/run.sh
new file mode 100644
index 0000000..14cebf9
--- /dev/null
+++ b/generic/default/java-client/run.sh
@@ -0,0 +1,2 @@
+mvn install -DSkipTests
+mvn exec:java -Dexec.mainClass="org.apache.dubbo.ApiConsumer"
\ No newline at end of file
diff --git a/generic/default/java-client/src/main/java/org/apache/dubbo/ApiConsumer.java b/generic/default/java-client/src/main/java/org/apache/dubbo/ApiConsumer.java
new file mode 100644
index 0000000..5a45d5d
--- /dev/null
+++ b/generic/default/java-client/src/main/java/org/apache/dubbo/ApiConsumer.java
@@ -0,0 +1,159 @@
+/*
+ * 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;
+
+import org.apache.dubbo.config.ApplicationConfig;
+import org.apache.dubbo.config.ReferenceConfig;
+import org.apache.dubbo.config.RegistryConfig;
+import org.apache.dubbo.rpc.service.GenericService;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.lang.Integer;
+
+public class ApiConsumer {
+ private static final Logger logger = LoggerFactory.getLogger("userLogger"); // Output to com.dubbogo.user-server.log
+
+ private static GenericService genericService;
+
+ public static void main(String[] args) {
+ initConfig();
+
+ callGetUser();
+ callGetOneUser();
+ callGetUsers();
+ callGetUsersMap();
+ callQueryUser();
+ callQueryUsers();
+ callQueryAll();
+ }
+
+ private static void initConfig() {
+ logger.info("\n\n\nstart to init config\n\n\n");
+ ApplicationConfig applicationConfig = new ApplicationConfig();
+ ReferenceConfig<GenericService> reference = new ReferenceConfig<GenericService>();
+ applicationConfig.setName("user-info-server");
+ reference.setApplication(applicationConfig);
+ RegistryConfig registryConfig = new RegistryConfig();
+ registryConfig.setAddress("zookeeper://127.0.0.1:2181");
+ reference.setRegistry(registryConfig);
+ reference.setGeneric(true);
+ reference.setInterface("org.apache.dubbo.UserProvider");
+ genericService = reference.get();
+ }
+
+ private static void callGetUser() {
+ logger.info("\n\n\nCall GetUser");
+ logger.info("Start to generic invoke");
+ Object result;
+
+ result = genericService.$invoke("GetUser1", new String[]{"java.lang.String"}, new Object[]{"A003"});
+ logger.info("\n\n\n" + "GetUser1(String userId) " + "res: " + result + "\n\n\n");
+
+ result = genericService.$invoke("GetUser2", new String[]{"java.lang.String", "java.lang.String"}, new Object[]{"A003", "lily"});
+ logger.info("\n\n\n" + "GetUser2(String userId, String name) " + "res: " + result + "\n\n\n");
+
+ result = genericService.$invoke("GetUser3", new String[]{"int"}, new Object[]{1});
+ logger.info("\n\n\n" + "GetUser3(int userCode) " + "res: " + result + "\n\n\n");
+
+ result = genericService.$invoke("GetUser4", new String[]{"int", "java.lang.String"}, new Object[]{1, "zhangsan"});
+ logger.info("\n\n\n" + "GetUser4(int userCode, String name) " + "res: " + result + "\n\n\n");
+ }
+
+ private static void callGetOneUser() {
+ logger.info("\n\n\nCall GetOneUser");
+ logger.info("Start to generic invoke");
+
+ Object result = genericService.$invoke("GetOneUser", new String[]{}, new Object[]{});
+ logger.info("\n\n\n" + "GetOneUser() " + "res: " + result + "\n\n\n");
+ }
+
+ private static void callGetUsers() {
+ logger.info("\n\n\nCall GetUsers");
+ logger.info("Start to generic invoke");
+
+ List<String> userIdList = new ArrayList<String>();
+ userIdList.add("001");
+ userIdList.add("002");
+ userIdList.add("003");
+ userIdList.add("004");
+
+ Object result = genericService.$invoke("GetUsers", new String[]{"java.util.List"}, new Object[]{userIdList});
+ logger.info("\n\n\n" + "GetUsers(List<String> userIdList) " + "res: " + result + "\n\n\n");
+ }
+
+ private static void callGetUsersMap() {
+ logger.info("\n\n\nCall GetUsersMap");
+ logger.info("Start to generic invoke");
+ Object result;
+
+ List<String> userIdList = new ArrayList<String>();
+ userIdList.add("001");
+ userIdList.add("002");
+ userIdList.add("003");
+ userIdList.add("004");
+
+ result = genericService.$invoke("GetUsersMap", new String[]{"java.util.List"}, new Object[]{userIdList});
+ logger.info("\n\n\n" + "GetUserMap(List<String> userIdList) " + "res: " + result + "\n\n\n");
+ }
+
+ private static void callQueryUser() {
+ logger.info("\n\n\nCall QueryUser");
+ logger.info("Start to generic invoke");
+
+ User user = new User();
+ user.setName("panty");
+ user.setId("3213");
+ user.setAge(25);
+ Object result = genericService.$invoke("queryUser", new String[]{"org.apache.dubbo.User"}, new Object[]{user});
+ logger.info("\n\n\n" + "queryUser(User user) " + "res: " + result + "\n\n\n");
+ }
+
+ private static void callQueryUsers() {
+ logger.info("\n\n\nCall QueryUsers");
+ logger.info("Start to generic invoke");
+
+ ArrayList<Map> userArr = new ArrayList<>();
+ Map<Object, Object> userMap1 = new HashMap<>();
+ userMap1.put("id", "3212");
+ userMap1.put("name", "XavierNiu");
+ userMap1.put("age", 24);
+ Map<Object, Object> userMap2 = new HashMap<>();
+ userMap2.put("id", "3213");
+ userMap2.put("name", "zhangsan");
+ userMap2.put("age", 21);
+ userArr.add(userMap1);
+ userArr.add(userMap2);
+
+ Object result = genericService.$invoke("queryUsers", new String[]{"java.util.ArrayList"}, new Object[]{userArr});
+ logger.info("\n\n\n" + "queryUsers(ArrayList<User> userList) " + "res: " + result + "\n\n\n");
+ }
+
+ private static void callQueryAll() {
+ logger.info("\n\n\nCall queryAll");
+ logger.info("Start to generic invoke");
+
+ Object result = genericService.$invoke("queryAll", new String[]{}, new Object[]{});
+ logger.info("\n\n\n" + "queryAll() " + "res: " + result + "\n\n\n");
+ }
+}
diff --git a/generic/default/java-client/2.6/src/main/java/org/apache/dubbo/User.java b/generic/default/java-client/src/main/java/org/apache/dubbo/User.java
similarity index 97%
rename from generic/default/java-client/2.6/src/main/java/org/apache/dubbo/User.java
rename to generic/default/java-client/src/main/java/org/apache/dubbo/User.java
index 1fa1831..8c42b59 100644
--- a/generic/default/java-client/2.6/src/main/java/org/apache/dubbo/User.java
+++ b/generic/default/java-client/src/main/java/org/apache/dubbo/User.java
@@ -20,7 +20,7 @@ package org.apache.dubbo;
import java.util.Date;
import java.io.Serializable;
-public class User implements Serializable{
+public class User implements Serializable {
private String id;
diff --git a/generic/default/java-client/2.7/src/main/resources/log4j.properties b/generic/default/java-client/src/main/resources/log4j.properties
similarity index 100%
rename from generic/default/java-client/2.7/src/main/resources/log4j.properties
rename to generic/default/java-client/src/main/resources/log4j.properties
diff --git a/generic/default/java-server/2.6/pom.xml b/generic/default/java-server/2.6/pom.xml
deleted file mode 100644
index 908dfdb..0000000
--- a/generic/default/java-server/2.6/pom.xml
+++ /dev/null
@@ -1,79 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<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/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>org.apache.dubbo</groupId>
- <artifactId>2.6</artifactId>
- <version>0.0.1</version>
-
- <properties>
- <skip_maven_deploy>false</skip_maven_deploy>
- <dubbo-version>2.6.5</dubbo-version>
- <curator.version>2.12.0</curator.version>
- <zk.version>3.4.14</zk.version>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>1.7.25</version>
- </dependency>
-
- <dependency>
- <groupId>com.alibaba</groupId>
- <artifactId>dubbo</artifactId>
- <version>${dubbo-version}</version>
- <exclusions>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>io.netty</groupId>
- <artifactId>netty-all</artifactId>
- <version>4.1.25.Final</version>
- </dependency>
- <dependency>
- <groupId>org.apache.curator</groupId>
- <artifactId>curator-framework</artifactId>
- <version>${curator.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>jetty</artifactId>
- <version>6.1.26</version>
- </dependency>
-
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-core</artifactId>
- <version>2.10.0</version>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-databind</artifactId>
- <version>2.10.0</version>
- </dependency>
-
- <dependency>
- <groupId>com.github.sgroschupf</groupId>
- <artifactId>zkclient</artifactId>
- <version>0.1</version>
- <exclusions>
- <exclusion>
- <artifactId>org.apache.zookeeper</artifactId>
- <groupId>zookeeper</groupId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.apache.zookeeper</groupId>
- <artifactId>zookeeper</artifactId>
- <version>${zk.version}</version>
- </dependency>
- </dependencies>
-</project>
\ No newline at end of file
diff --git a/generic/default/java-server/2.6/src/main/java/org/apache/dubbo/Provider.java b/generic/default/java-server/2.6/src/main/java/org/apache/dubbo/Provider.java
deleted file mode 100644
index 6545977..0000000
--- a/generic/default/java-server/2.6/src/main/java/org/apache/dubbo/Provider.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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;
-
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-public class Provider {
-
- /**
- * To get ipv6 address to work, add
- * System.setProperty("java.net.preferIPv6Addresses", "true");
- * before running your application.
- */
- public static void main(String[] args) throws Exception {
- ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"META-INF/spring/dubbo.provider.xml"});
- context.start();
- System.in.read(); // press any key to exit
- }
-}
diff --git a/generic/default/java-server/2.6/src/main/java/org/apache/dubbo/Response.java b/generic/default/java-server/2.6/src/main/java/org/apache/dubbo/Response.java
deleted file mode 100644
index a8196c6..0000000
--- a/generic/default/java-server/2.6/src/main/java/org/apache/dubbo/Response.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * 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;
-
-import java.io.Serializable;
-
-public final class Response<T> implements Serializable {
- private static final long serialVersionUID = 3727205004706510648L;
- public static final Integer OK = 200;
- public static final Integer ERR = 500;
- private Integer Status;
- private String Err;
- private T Data;
-
- public Response() {
- }
-
- public static <T> Response<T> ok() {
- Response r = new Response();
- r.Status = OK;
- return r;
- }
-
- public static <T> Response<T> ok(Object Data) {
- Response r = new Response();
- r.Status = OK;
- r.Data = Data;
- return r;
- }
-
- public static <T> Response<T> notOk(String Err) {
- Response r = new Response();
- r.Status = ERR;
- r.Err = Err;
- return r;
- }
-
- public static <T> Response<T> notOk(Integer Status, String Err) {
- Response r = new Response();
- r.Status = Status;
- r.Err = Err;
- return r;
- }
-
-// public Boolean isSuccess() {
-// return Objects.equals(this.Status, OK);
-// }
-
- public Integer getStatus() {
- return this.Status;
- }
-
- public void setStatus(Integer Status) {
- this.Status = Status;
- }
-
- public String getErr() {
- return this.Err;
- }
-
- public void setErr(String Err) {
- this.Err = Err;
- }
-
- public T getData() {
- return this.Data;
- }
-
- public void setData(T Data) {
- this.Status = OK;
- this.Data = Data;
- }
-
- public String toString() {
- return "Response{Status=" + this.Status + ", Err='" + this.Err + '\'' + ", Data=" + this.Data + '}';
- }
-}
\ No newline at end of file
diff --git a/generic/default/java-server/2.6/src/main/java/org/apache/dubbo/User.java b/generic/default/java-server/2.6/src/main/java/org/apache/dubbo/User.java
deleted file mode 100644
index 7fcfa38..0000000
--- a/generic/default/java-server/2.6/src/main/java/org/apache/dubbo/User.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * 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;
-
-import java.io.Serializable;
-import java.util.Date;
-
-public class User implements Serializable {
-
- private String id;
-
- private String name;
-
- private int age;
-
- private Date time = new Date();
-
- private Gender sex = Gender.MAN;
-
- public User() {
- }
-
- public User(String id, String name, int age) {
- this.id = id;
- this.name = name;
- this.age = age;
- }
-
- public User(String id, String name, int age, Date time, Gender sex) {
- this.id = id;
- this.name = name;
- this.age = age;
- this.time = time;
- this.sex = sex;
- }
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public int getAge() {
- return age;
- }
-
- public void setAge(int age) {
- this.age = age;
- }
-
- public Date getTime() {
- return time;
- }
-
- public void setTime(Date time) {
- this.time = time;
- }
-
- public Gender getSex() {
- return sex;
- }
-
- public void setSex(Gender sex) {
- this.sex = sex;
- }
-
- public String toString() {
- return "User{id:" + id + ", name:" + name + ", age:" + age + ", time:" + time + ", gender:" + sex + "}";
- }
-}
diff --git a/generic/default/java-server/2.6/src/main/java/org/apache/dubbo/UserProviderAnotherImpl.java b/generic/default/java-server/2.6/src/main/java/org/apache/dubbo/UserProviderAnotherImpl.java
deleted file mode 100644
index cc6170e..0000000
--- a/generic/default/java-server/2.6/src/main/java/org/apache/dubbo/UserProviderAnotherImpl.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * 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;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.*;
-
-public class UserProviderAnotherImpl implements UserProvider {
- // private static final Logger logger = LoggerFactory.getLogger(getClass()); // Only output to dubbo's log(logs/server.log)
- private static final Logger logger = LoggerFactory.getLogger("userLogger"); // Output to com.dubbogo.user-server.log
-
- private Map<String, User> userMap = new HashMap<String, User>();
-
- public UserProviderAnotherImpl() {
- // userMap.put("001", new User("001", "other-zhangsan", 18, new Date(1998-1900, 1, 2, 3, 4, 5), Gender.MAN));
- userMap.put("001", new User("001", "other-zhangsan", 18, new Date(0x12345678), Gender.MAN));
- userMap.put("002", new User("002", "other-lisi", 20, new Date(1996-1900, 1, 2, 3, 4, 5), Gender.MAN));
- userMap.put("003", new User("003", "other-lily", 23, new Date(1993-1900, 1, 2, 3, 4, 5), Gender.WOMAN));
- userMap.put("004", new User("004", "other-lisa", 32, new Date(1985-1900, 1, 2, 3, 4, 5), Gender.WOMAN));
- }
-
- public boolean isLimit(Gender gender, String name) {
- logger.info(String.format("input gender=%sand name=%s", gender, name));
- return Gender.MAN == gender;
- }
-
- public User GetUser(String userId) {
- logger.info("input userId = " + userId);
- return new User(userId, "Joe", 48);
- }
-
- public User GetUser0(String userId, String name) {
- return new User(userId, name, 48);
- }
-
- public void GetUser3() {
- logger.info("this is GetUser3 of another");
- }
-
- public User GetErr(String userId) throws Exception {
- throw new Exception("exception");
- }
-
- public List<User> GetUsers(ArrayList<String> userIdList) {
- Iterator it = userIdList.iterator();
- List<User> userList = new ArrayList<User>();
- logger.warn("@userIdList size:" + userIdList.size());
-
- while(it.hasNext()) {
- String id = (String)(it.next());
- logger.info("GetUsers(@uid:" + id + ")");
- if (userMap.containsKey(id)) {
- userList.add(userMap.get(id));
- logger.info("id:" + id + ", com.dubbogo.user:" + userMap.get(id));
- }
- }
-
- return userList;
- }
-
- public Map<String, User> GetUserMap(List<String> userIdList) {
- Iterator it = userIdList.iterator();
- Map<String, User> map = new HashMap<String, User>();
- logger.warn("@userIdList size:" + userIdList.size());
-
- while(it.hasNext()) {
- String id = (String)(it.next());
- logger.info("GetUsers(@uid:" + id + ")");
- if (userMap.containsKey(id)) {
- map.put(id, userMap.get(id));
- logger.info("id:" + id + ", com.dubbogo.user:" + userMap.get(id));
- }
- }
-
- return map;
- }
-
- public List<User> GetUsers(List<String> userIdList) {
- Iterator it = userIdList.iterator();
- List<User> userList = new ArrayList<User>();
- logger.warn("@userIdList size:" + userIdList.size());
-
- while(it.hasNext()) {
- String id = (String)(it.next());
- logger.info("GetUsers(@uid:" + id + ")");
- if (userMap.containsKey(id)) {
- userList.add(userMap.get(id));
- logger.info("id:" + id + ", com.dubbogo.user:" + userMap.get(id));
- }
- }
-
- return userList;
- }
-
- // @Override
- public User getUser(int userCode) {
- logger.info("input userCode = " + userCode);
- return new User(String.valueOf(userCode), "userCode get", 48);
- }
-
- public User getUser(int usercode, String name) {
- return new User(String.valueOf(usercode), name, 18);
- }
-
- public User queryUser(User user) {
- logger.info("input com.dubbogo.user = " + user);
- return new User(user.getId(), "get:" + user.getName(), user.getAge() + 18);
- }
-
- public Map<String, User> queryAll() {
- logger.info("input");
- Map<String, User> map = new HashMap<String, User>();
- map.put("001", new User("001", "Joe", 18));
- map.put("002", new User("002", "Wen", 20));
-
- return map;
- }
-
- public int Calc(int a,int b) {
- return a + b + 100;
- }
-
- public Response<Integer> Sum(int a,int b) {
- return Response.ok(a+b);
- }
-}
diff --git a/generic/default/java-server/2.6/src/main/java/org/apache/dubbo/UserProviderImpl.java b/generic/default/java-server/2.6/src/main/java/org/apache/dubbo/UserProviderImpl.java
deleted file mode 100644
index bdb9651..0000000
--- a/generic/default/java-server/2.6/src/main/java/org/apache/dubbo/UserProviderImpl.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * 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;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.*;
-
-public class UserProviderImpl implements UserProvider {
- // private static final Logger logger = LoggerFactory.getLogger(getClass()); // Only output to dubbo's log(logs/server.log)
- private static final Logger LOG = LoggerFactory.getLogger("UserLogger"); // Output to com.dubbogo.user-server.log
- Map<String, User> userMap = new HashMap<String, User>();
-
- public UserProviderImpl() {
- userMap.put("A001", new User("A001", "demo-zhangsan", 18));
- userMap.put("A002", new User("A002", "demo-lisi", 20));
- userMap.put("A003", new User("A003", "demo-lily", 23));
- userMap.put("A004", new User("A004", "demo-lisa", 32));
- }
-
- public boolean isLimit(Gender gender, String name) {
- return Gender.WOMAN == gender;
- }
-
- public User GetUser(String userId) {
- return new User(userId, "zhangsan", 18);
- }
-
- public User GetErr(String userId) throws Exception {
- throw new Exception("exception");
- }
-
- public User GetUser0(String userId, String name) {
- return new User(userId, name, 18);
- }
-
- public List<User> GetUsers(List<String> userIdList) {
- Iterator it = userIdList.iterator();
- List<User> userList = new ArrayList<User>();
- LOG.warn("@userIdList size:" + userIdList.size());
-
- while(it.hasNext()) {
- String id = (String)(it.next());
- LOG.info("GetUsers(@uid:" + id + ")");
- if (userMap.containsKey(id)) {
- userList.add(userMap.get(id));
- LOG.info("id:" + id + ", com.dubbogo.user:" + userMap.get(id));
- }
- }
-
- return userList;
- }
-
- public void GetUser3() {
- LOG.info("this is GetUser3 of impl");
- }
-
- public Map<String, User> GetUserMap(List<String> userIdList) {
- Iterator it = userIdList.iterator();
- Map<String, User> map = new HashMap<String, User>();
- LOG.warn("@userIdList size:" + userIdList.size());
-
- while(it.hasNext()) {
- String id = (String)(it.next());
- LOG.info("GetUsers(@uid:" + id + ")");
- if (userMap.containsKey(id)) {
- map.put(id, userMap.get(id));
- LOG.info("id:" + id + ", com.dubbogo.user:" + userMap.get(id));
- }
- }
-
- return map;
- }
-
- public User queryUser(User user) {
- return new User(user.getId(), "hello:" +user.getName(), user.getAge() + 18);
- }
-
- public Map<String, User> queryAll() {
- return userMap;
- }
-
-
- public User getUser(int userCode) {
- return new User(String.valueOf(userCode), "userCode get", 48);
- }
-
- public User getUser(int usercode, String name) {
- return new User(String.valueOf(usercode), name, 38);
- }
-
- public int Calc(int a,int b) {
- return a + b;
- }
-
- public Response<Integer> Sum(int a,int b) {
- return Response.ok(a+b);
- }
-}
diff --git a/generic/default/java-server/2.6/src/main/resources/META-INF/spring/dubbo.provider.xml b/generic/default/java-server/2.6/src/main/resources/META-INF/spring/dubbo.provider.xml
deleted file mode 100644
index cd63653..0000000
--- a/generic/default/java-server/2.6/src/main/resources/META-INF/spring/dubbo.provider.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed 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.
--->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
- http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
-
- <!-- 应用名 -->
- <dubbo:application name="user-info-server"/>
- <!-- 连接到哪个本地注册中心 -->
- <dubbo:registry id="dubbogo" address="zookeeper://127.0.0.1:2181" />
- <!-- 用dubbo协议在20880端口暴露服务 -->
- <dubbo:protocol id="dubbo" name="dubbo" host="127.0.0.1" port="20010" />
- <!-- 声明需要暴露的服务接口 -->
- <dubbo:service id="aaa" registry="dubbogo" timeout="3000" interface="org.apache.dubbo.UserProvider" ref="demoService"/>
- <dubbo:service id="bbb" registry="dubbogo" timeout="3000" interface="org.apache.dubbo.UserProvider" ref="otherService" version="2.0"/>
- <dubbo:service id="ccc" registry="dubbogo" timeout="3000" interface="org.apache.dubbo.UserProvider" ref="otherService" group="as" version="2.0"/>
-
- <bean id="demoService" class="org.apache.dubbo.UserProviderImpl" />
- <bean id="otherService" class="org.apache.dubbo.UserProviderAnotherImpl"/>
-
-</beans>
diff --git a/generic/default/java-server/2.6/src/main/resources/log4j.properties b/generic/default/java-server/2.6/src/main/resources/log4j.properties
deleted file mode 100644
index 13c8049..0000000
--- a/generic/default/java-server/2.6/src/main/resources/log4j.properties
+++ /dev/null
@@ -1,20 +0,0 @@
-## Logger configure file for myproject
-log.dir=logs/
-datestamp=yyyy-MM-dd/HH:mm:ss.SSS
-
-log4j.rootLogger=DEBUG, file, console
-
-log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
-log4j.appender.file.threshold=DEBUG
-log4j.appender.file.File=${log.dir}/log4j.log
-log4j.appender.file.DatePattern=-yyyyMMddHH
-log4j.appender.file.ImmediateFlush=true
-log4j.appender.file.Append=true
-log4j.appender.file.layout=org.apache.log4j.PatternLayout
-log4j.appender.file.layout.ConversionPattern=%d{${datestamp}} %5p: %l - %m%n
-
-log4j.appender.console=org.apache.log4j.ConsoleAppender
-log4j.appender.console.Threshold=DEBUG
-log4j.appender.console.layout=org.apache.log4j.PatternLayout
-log4j.appender.console.layout.ConversionPattern=%d{${datestamp}} %5p: %l - %m%n
-
diff --git a/generic/default/java-server/2.7/pom.xml b/generic/default/java-server/2.7/pom.xml
deleted file mode 100644
index 50dd888..0000000
--- a/generic/default/java-server/2.7/pom.xml
+++ /dev/null
@@ -1,126 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<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/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>org.apache.dubbo</groupId>
- <artifactId>2.7</artifactId>
- <version>0.0.1</version>
-
- <properties>
- <skip_maven_deploy>false</skip_maven_deploy>
- <dubbo-version>2.7.7</dubbo-version>
- <curator.version>2.12.0</curator.version>
- <zk.version>3.4.14</zk.version>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>1.7.25</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo</artifactId>
- <version>${dubbo-version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-spring-boot-starter</artifactId>
- <version>${dubbo-version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.curator</groupId>
- <artifactId>curator-framework</artifactId>
- <version>${curator.version}</version>
- <exclusions>
- <exclusion>
- <artifactId>zookeeper</artifactId>
- <groupId>org.apache.zookeeper</groupId>
- </exclusion>
- <exclusion>
- <artifactId>slf4j-api</artifactId>
- <groupId>org.slf4j</groupId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.curator</groupId>
- <artifactId>curator-recipes</artifactId>
- <version>2.8.0</version>
- <exclusions>
- <exclusion>
- <artifactId>zookeeper</artifactId>
- <groupId>org.apache.zookeeper</groupId>
- </exclusion>
- <exclusion>
- <artifactId>curator-framework</artifactId>
- <groupId>org.apache.curator</groupId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>io.netty</groupId>
- <artifactId>netty-all</artifactId>
- <version>4.1.25.Final</version>
- </dependency>
-
- <dependency>
- <groupId>jetty</groupId>
- <artifactId>org.mortbay.jetty</artifactId>
- <version>6.0.0alpha3</version>
- </dependency>
- <dependency>
- <groupId>jetty</groupId>
- <artifactId>jetty-util</artifactId>
- <version>6.0.0</version>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>javax.servlet-api</artifactId>
- <version>4.0.0</version>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-core</artifactId>
- <version>2.10.0</version>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-databind</artifactId>
- <version>2.10.0</version>
- </dependency>
-
- <dependency>
- <groupId>com.github.sgroschupf</groupId>
- <artifactId>zkclient</artifactId>
- <version>0.1</version>
- <exclusions>
- <exclusion>
- <artifactId>org.apache.zookeeper</artifactId>
- <groupId>zookeeper</groupId>
- </exclusion>
- <exclusion>
- <artifactId>log4j</artifactId>
- <groupId>log4j</groupId>
- </exclusion>
- <exclusion>
- <artifactId>zookeeper</artifactId>
- <groupId>org.apache.zookeeper</groupId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.apache.zookeeper</groupId>
- <artifactId>zookeeper</artifactId>
- <version>${zk.version}</version>
- </dependency>
-
- </dependencies>
-</project>
\ No newline at end of file
diff --git a/generic/default/java-server/2.7/src/main/java/org/apache/dubbo/Gender.java b/generic/default/java-server/2.7/src/main/java/org/apache/dubbo/Gender.java
deleted file mode 100644
index 7b503cc..0000000
--- a/generic/default/java-server/2.7/src/main/java/org/apache/dubbo/Gender.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * 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;
-
-public enum Gender {
- MAN,
- WOMAN
-}
diff --git a/generic/default/java-server/2.7/src/main/java/org/apache/dubbo/Provider.java b/generic/default/java-server/2.7/src/main/java/org/apache/dubbo/Provider.java
deleted file mode 100644
index 6545977..0000000
--- a/generic/default/java-server/2.7/src/main/java/org/apache/dubbo/Provider.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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;
-
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-public class Provider {
-
- /**
- * To get ipv6 address to work, add
- * System.setProperty("java.net.preferIPv6Addresses", "true");
- * before running your application.
- */
- public static void main(String[] args) throws Exception {
- ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"META-INF/spring/dubbo.provider.xml"});
- context.start();
- System.in.read(); // press any key to exit
- }
-}
diff --git a/generic/default/java-server/2.7/src/main/java/org/apache/dubbo/UserProvider.java b/generic/default/java-server/2.7/src/main/java/org/apache/dubbo/UserProvider.java
deleted file mode 100644
index 1c13f05..0000000
--- a/generic/default/java-server/2.7/src/main/java/org/apache/dubbo/UserProvider.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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;
-
-import java.util.List;
-import java.util.Map;
-
-public interface UserProvider {
-
- boolean isLimit(Gender gender, String name);
-
- User GetUser(String userId); // the first alpha is Upper case to compatible with golang.
-
- List<User> GetUsers(List<String> userIdList);
-
- void GetUser3();
-
- User GetUser0(String userId, String name);
-
- User GetErr(String userId) throws Exception;
-
- Map<String, User> GetUserMap(List<String> userIdList);
-
- User getUser(int usercode);
-
- User getUser(int usercode, String name);
-
- User queryUser(User user);
-
- Map<String, User> queryAll();
-
- int Calc(int a, int b);
-
- Response<Integer> Sum(int a, int b);
-}
diff --git a/generic/default/java-server/2.7/src/main/java/org/apache/dubbo/UserProviderImpl.java b/generic/default/java-server/2.7/src/main/java/org/apache/dubbo/UserProviderImpl.java
deleted file mode 100644
index bdb9651..0000000
--- a/generic/default/java-server/2.7/src/main/java/org/apache/dubbo/UserProviderImpl.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * 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;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.*;
-
-public class UserProviderImpl implements UserProvider {
- // private static final Logger logger = LoggerFactory.getLogger(getClass()); // Only output to dubbo's log(logs/server.log)
- private static final Logger LOG = LoggerFactory.getLogger("UserLogger"); // Output to com.dubbogo.user-server.log
- Map<String, User> userMap = new HashMap<String, User>();
-
- public UserProviderImpl() {
- userMap.put("A001", new User("A001", "demo-zhangsan", 18));
- userMap.put("A002", new User("A002", "demo-lisi", 20));
- userMap.put("A003", new User("A003", "demo-lily", 23));
- userMap.put("A004", new User("A004", "demo-lisa", 32));
- }
-
- public boolean isLimit(Gender gender, String name) {
- return Gender.WOMAN == gender;
- }
-
- public User GetUser(String userId) {
- return new User(userId, "zhangsan", 18);
- }
-
- public User GetErr(String userId) throws Exception {
- throw new Exception("exception");
- }
-
- public User GetUser0(String userId, String name) {
- return new User(userId, name, 18);
- }
-
- public List<User> GetUsers(List<String> userIdList) {
- Iterator it = userIdList.iterator();
- List<User> userList = new ArrayList<User>();
- LOG.warn("@userIdList size:" + userIdList.size());
-
- while(it.hasNext()) {
- String id = (String)(it.next());
- LOG.info("GetUsers(@uid:" + id + ")");
- if (userMap.containsKey(id)) {
- userList.add(userMap.get(id));
- LOG.info("id:" + id + ", com.dubbogo.user:" + userMap.get(id));
- }
- }
-
- return userList;
- }
-
- public void GetUser3() {
- LOG.info("this is GetUser3 of impl");
- }
-
- public Map<String, User> GetUserMap(List<String> userIdList) {
- Iterator it = userIdList.iterator();
- Map<String, User> map = new HashMap<String, User>();
- LOG.warn("@userIdList size:" + userIdList.size());
-
- while(it.hasNext()) {
- String id = (String)(it.next());
- LOG.info("GetUsers(@uid:" + id + ")");
- if (userMap.containsKey(id)) {
- map.put(id, userMap.get(id));
- LOG.info("id:" + id + ", com.dubbogo.user:" + userMap.get(id));
- }
- }
-
- return map;
- }
-
- public User queryUser(User user) {
- return new User(user.getId(), "hello:" +user.getName(), user.getAge() + 18);
- }
-
- public Map<String, User> queryAll() {
- return userMap;
- }
-
-
- public User getUser(int userCode) {
- return new User(String.valueOf(userCode), "userCode get", 48);
- }
-
- public User getUser(int usercode, String name) {
- return new User(String.valueOf(usercode), name, 38);
- }
-
- public int Calc(int a,int b) {
- return a + b;
- }
-
- public Response<Integer> Sum(int a,int b) {
- return Response.ok(a+b);
- }
-}
diff --git a/generic/default/java-server/2.7/src/main/resources/META-INF/spring/dubbo.provider.xml b/generic/default/java-server/2.7/src/main/resources/META-INF/spring/dubbo.provider.xml
deleted file mode 100644
index cd63653..0000000
--- a/generic/default/java-server/2.7/src/main/resources/META-INF/spring/dubbo.provider.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed 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.
--->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
- http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
-
- <!-- 应用名 -->
- <dubbo:application name="user-info-server"/>
- <!-- 连接到哪个本地注册中心 -->
- <dubbo:registry id="dubbogo" address="zookeeper://127.0.0.1:2181" />
- <!-- 用dubbo协议在20880端口暴露服务 -->
- <dubbo:protocol id="dubbo" name="dubbo" host="127.0.0.1" port="20010" />
- <!-- 声明需要暴露的服务接口 -->
- <dubbo:service id="aaa" registry="dubbogo" timeout="3000" interface="org.apache.dubbo.UserProvider" ref="demoService"/>
- <dubbo:service id="bbb" registry="dubbogo" timeout="3000" interface="org.apache.dubbo.UserProvider" ref="otherService" version="2.0"/>
- <dubbo:service id="ccc" registry="dubbogo" timeout="3000" interface="org.apache.dubbo.UserProvider" ref="otherService" group="as" version="2.0"/>
-
- <bean id="demoService" class="org.apache.dubbo.UserProviderImpl" />
- <bean id="otherService" class="org.apache.dubbo.UserProviderAnotherImpl"/>
-
-</beans>
diff --git a/generic/default/java-server/2.7/src/main/resources/log4j.properties b/generic/default/java-server/2.7/src/main/resources/log4j.properties
deleted file mode 100644
index 13c8049..0000000
--- a/generic/default/java-server/2.7/src/main/resources/log4j.properties
+++ /dev/null
@@ -1,20 +0,0 @@
-## Logger configure file for myproject
-log.dir=logs/
-datestamp=yyyy-MM-dd/HH:mm:ss.SSS
-
-log4j.rootLogger=DEBUG, file, console
-
-log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
-log4j.appender.file.threshold=DEBUG
-log4j.appender.file.File=${log.dir}/log4j.log
-log4j.appender.file.DatePattern=-yyyyMMddHH
-log4j.appender.file.ImmediateFlush=true
-log4j.appender.file.Append=true
-log4j.appender.file.layout=org.apache.log4j.PatternLayout
-log4j.appender.file.layout.ConversionPattern=%d{${datestamp}} %5p: %l - %m%n
-
-log4j.appender.console=org.apache.log4j.ConsoleAppender
-log4j.appender.console.Threshold=DEBUG
-log4j.appender.console.layout=org.apache.log4j.PatternLayout
-log4j.appender.console.layout.ConversionPattern=%d{${datestamp}} %5p: %l - %m%n
-
diff --git a/generic/default/java-server/pom.xml b/generic/default/java-server/pom.xml
new file mode 100644
index 0000000..2981f31
--- /dev/null
+++ b/generic/default/java-server/pom.xml
@@ -0,0 +1,164 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.dubbo</groupId>
+ <version>1.0-SNAPSHOT</version>
+ <artifactId>generic-dubbo-java-server</artifactId>
+
+ <properties>
+ <source.level>1.8</source.level>
+ <target.level>1.8</target.level>
+ <dubbo.version>3.0.2</dubbo.version>
+ <junit.version>4.12</junit.version>
+ <spring-test.version>4.3.16.RELEASE</spring-test.version>
+ <maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
+ <maven-failsafe-plugin.version>2.21.0</maven-failsafe-plugin.version>
+ <spring-boot.version>1.5.13.RELEASE</spring-boot.version>
+ <grpc.version>1.19.0</grpc.version>
+ <protoc.version>3.7.1</protoc.version>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo</artifactId>
+ <version>${dubbo.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.protobuf</groupId>
+ <artifactId>protobuf-java</artifactId>
+ <version>3.14.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-dependencies-zookeeper</artifactId>
+ <version>${dubbo.version}</version>
+ <type>pom</type>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.zookeeper</groupId>
+ <artifactId>zookeeper</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.zookeeper</groupId>
+ <artifactId>zookeeper</artifactId>
+ <version>3.4.8</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${junit.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <version>${spring-test.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.testcontainers</groupId>
+ <artifactId>testcontainers</artifactId>
+ <version>1.12.3</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <profiles>
+ <!-- For jdk 11 above JavaEE annotation -->
+ <profile>
+ <id>javax.annotation</id>
+ <activation>
+ <jdk>[1.11,)</jdk>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>javax.annotation-api</artifactId>
+ <version>1.3.2</version>
+ </dependency>
+ </dependencies>
+ </profile>
+ </profiles>
+
+ <build>
+ <defaultGoal>package</defaultGoal>
+ <extensions>
+ <extension>
+ <groupId>kr.motd.maven</groupId>
+ <artifactId>os-maven-plugin</artifactId>
+ <version>1.6.1</version>
+ </extension>
+ </extensions>
+
+ <plugins>
+ <plugin>
+ <groupId>org.xolstice.maven.plugins</groupId>
+ <artifactId>protobuf-maven-plugin</artifactId>
+ <version>0.6.1</version>
+ <configuration>
+ <protocArtifact>com.google.protobuf:protoc:3.17.3:exe:${os.detected.classifier}</protocArtifact>
+ <pluginId>triple-java</pluginId>
+ <outputDirectory>build/generated/source/proto/main/java</outputDirectory>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>compile</goal>
+ <goal>test-compile</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>${maven-compiler-plugin.version}</version>
+ <configuration>
+ <source>${source.level}</source>
+ <target>${target.level}</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>build/generated/source/proto/main/java</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
\ No newline at end of file
diff --git a/generic/default/java-server/run.sh b/generic/default/java-server/run.sh
new file mode 100644
index 0000000..6a421b1
--- /dev/null
+++ b/generic/default/java-server/run.sh
@@ -0,0 +1,2 @@
+mvn install -DSkipTests
+mvn exec:java -Dexec.mainClass="org.apache.dubbo.ApiProvider"
\ No newline at end of file
diff --git a/generic/default/java-server/src/main/java/org/apache/dubbo/ApiProvider.java b/generic/default/java-server/src/main/java/org/apache/dubbo/ApiProvider.java
new file mode 100644
index 0000000..1d620a4
--- /dev/null
+++ b/generic/default/java-server/src/main/java/org/apache/dubbo/ApiProvider.java
@@ -0,0 +1,40 @@
+/*
+ * 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;
+
+import org.apache.dubbo.common.constants.CommonConstants;
+import org.apache.dubbo.config.ApplicationConfig;
+import org.apache.dubbo.config.ProtocolConfig;
+import org.apache.dubbo.config.RegistryConfig;
+import org.apache.dubbo.config.ServiceConfig;
+
+import java.util.concurrent.CountDownLatch;
+
+public class ApiProvider {
+ public static void main(String[] args) throws InterruptedException {
+ ServiceConfig<UserProvider> service = new ServiceConfig<UserProvider>();
+ service.setInterface(UserProvider.class);
+ service.setRef(new UserProviderImpl());
+ service.setProtocol(new ProtocolConfig(CommonConstants.DUBBO, 20010));
+ service.setApplication(new ApplicationConfig("user-info-server"));
+ service.setRegistry(new RegistryConfig("zookeeper://127.0.0.1:2181"));
+ service.export();
+ System.out.println("dubbo service started");
+ new CountDownLatch(1).await();
+ }
+}
diff --git a/generic/default/java-server/2.6/src/main/java/org/apache/dubbo/Gender.java b/generic/default/java-server/src/main/java/org/apache/dubbo/Gender.java
similarity index 94%
rename from generic/default/java-server/2.6/src/main/java/org/apache/dubbo/Gender.java
rename to generic/default/java-server/src/main/java/org/apache/dubbo/Gender.java
index 7b503cc..71b6df0 100644
--- a/generic/default/java-server/2.6/src/main/java/org/apache/dubbo/Gender.java
+++ b/generic/default/java-server/src/main/java/org/apache/dubbo/Gender.java
@@ -1,23 +1,23 @@
-/*
- * 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;
-
-public enum Gender {
- MAN,
- WOMAN
-}
+/*
+ * 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;
+
+public enum Gender {
+ MAN,
+ WOMAN
+}
diff --git a/generic/default/java-server/2.7/src/main/java/org/apache/dubbo/Response.java b/generic/default/java-server/src/main/java/org/apache/dubbo/Response.java
similarity index 100%
rename from generic/default/java-server/2.7/src/main/java/org/apache/dubbo/Response.java
rename to generic/default/java-server/src/main/java/org/apache/dubbo/Response.java
diff --git a/generic/default/java-server/2.7/src/main/java/org/apache/dubbo/User.java b/generic/default/java-server/src/main/java/org/apache/dubbo/User.java
similarity index 93%
rename from generic/default/java-server/2.7/src/main/java/org/apache/dubbo/User.java
rename to generic/default/java-server/src/main/java/org/apache/dubbo/User.java
index 7fcfa38..8844eec 100644
--- a/generic/default/java-server/2.7/src/main/java/org/apache/dubbo/User.java
+++ b/generic/default/java-server/src/main/java/org/apache/dubbo/User.java
@@ -1,95 +1,95 @@
-/*
- * 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;
-
-import java.io.Serializable;
-import java.util.Date;
-
-public class User implements Serializable {
-
- private String id;
-
- private String name;
-
- private int age;
-
- private Date time = new Date();
-
- private Gender sex = Gender.MAN;
-
- public User() {
- }
-
- public User(String id, String name, int age) {
- this.id = id;
- this.name = name;
- this.age = age;
- }
-
- public User(String id, String name, int age, Date time, Gender sex) {
- this.id = id;
- this.name = name;
- this.age = age;
- this.time = time;
- this.sex = sex;
- }
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public int getAge() {
- return age;
- }
-
- public void setAge(int age) {
- this.age = age;
- }
-
- public Date getTime() {
- return time;
- }
-
- public void setTime(Date time) {
- this.time = time;
- }
-
- public Gender getSex() {
- return sex;
- }
-
- public void setSex(Gender sex) {
- this.sex = sex;
- }
-
- public String toString() {
- return "User{id:" + id + ", name:" + name + ", age:" + age + ", time:" + time + ", gender:" + sex + "}";
- }
-}
+/*
+ * 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;
+
+import java.io.Serializable;
+import java.util.Date;
+
+public class User implements Serializable {
+
+ private String id;
+
+ private String name;
+
+ private int age;
+
+ private Date time = new Date();
+
+ private Gender sex = Gender.MAN;
+
+ public User() {
+ }
+
+ public User(String id, String name, int age) {
+ this.id = id;
+ this.name = name;
+ this.age = age;
+ }
+
+ public User(String id, String name, int age, Date time, Gender sex) {
+ this.id = id;
+ this.name = name;
+ this.age = age;
+ this.time = time;
+ this.sex = sex;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+
+ public Date getTime() {
+ return time;
+ }
+
+ public void setTime(Date time) {
+ this.time = time;
+ }
+
+ public Gender getSex() {
+ return sex;
+ }
+
+ public void setSex(Gender sex) {
+ this.sex = sex;
+ }
+
+ public String toString() {
+ return "User{id:" + id + ", name:" + name + ", age:" + age + ", time:" + time + ", gender:" + sex + "}";
+ }
+}
diff --git a/generic/default/java-server/2.6/src/main/java/org/apache/dubbo/UserProvider.java b/generic/default/java-server/src/main/java/org/apache/dubbo/UserProvider.java
similarity index 70%
rename from generic/default/java-server/2.6/src/main/java/org/apache/dubbo/UserProvider.java
rename to generic/default/java-server/src/main/java/org/apache/dubbo/UserProvider.java
index 1c13f05..d23475b 100644
--- a/generic/default/java-server/2.6/src/main/java/org/apache/dubbo/UserProvider.java
+++ b/generic/default/java-server/src/main/java/org/apache/dubbo/UserProvider.java
@@ -1,50 +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;
-
-import java.util.List;
-import java.util.Map;
-
-public interface UserProvider {
-
- boolean isLimit(Gender gender, String name);
-
- User GetUser(String userId); // the first alpha is Upper case to compatible with golang.
-
- List<User> GetUsers(List<String> userIdList);
-
- void GetUser3();
-
- User GetUser0(String userId, String name);
-
- User GetErr(String userId) throws Exception;
-
- Map<String, User> GetUserMap(List<String> userIdList);
-
- User getUser(int usercode);
-
- User getUser(int usercode, String name);
-
- User queryUser(User user);
-
- Map<String, User> queryAll();
-
- int Calc(int a, int b);
-
- Response<Integer> Sum(int a, int b);
-}
+/*
+ * 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;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+//import org.apache.dubbo.rpc.filter.GenericFilter;
+
+public interface UserProvider {
+
+ boolean isLimit(Gender gender, String name);
+
+ User GetUser1(String userId); // the first alpha is Upper case to compatible with golang.
+
+ User GetUser2(String userId, String name);
+
+ User GetUser3(int userCode);
+
+ User GetUser4(int userCode, String name);
+
+ User GetOneUser();
+
+ List<User> GetUsers(List<String> userIdList);
+
+ Map<String, User> GetUsersMap(List<String> userIdList);
+
+ User queryUser(User user);
+
+ List<User> queryUsers(ArrayList<User> userObjectList);
+
+ Map<String, User> queryAll();
+
+ User GetErr(String userId) throws Exception;
+
+ int Calc(int a, int b);
+
+ Response<Integer> Sum(int a, int b);
+}
diff --git a/generic/default/java-server/2.7/src/main/java/org/apache/dubbo/UserProviderAnotherImpl.java b/generic/default/java-server/src/main/java/org/apache/dubbo/UserProviderImpl.java
similarity index 51%
rename from generic/default/java-server/2.7/src/main/java/org/apache/dubbo/UserProviderAnotherImpl.java
rename to generic/default/java-server/src/main/java/org/apache/dubbo/UserProviderImpl.java
index cc6170e..e50074b 100644
--- a/generic/default/java-server/2.7/src/main/java/org/apache/dubbo/UserProviderAnotherImpl.java
+++ b/generic/default/java-server/src/main/java/org/apache/dubbo/UserProviderImpl.java
@@ -1,143 +1,135 @@
-/*
- * 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;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.*;
-
-public class UserProviderAnotherImpl implements UserProvider {
- // private static final Logger logger = LoggerFactory.getLogger(getClass()); // Only output to dubbo's log(logs/server.log)
- private static final Logger logger = LoggerFactory.getLogger("userLogger"); // Output to com.dubbogo.user-server.log
-
- private Map<String, User> userMap = new HashMap<String, User>();
-
- public UserProviderAnotherImpl() {
- // userMap.put("001", new User("001", "other-zhangsan", 18, new Date(1998-1900, 1, 2, 3, 4, 5), Gender.MAN));
- userMap.put("001", new User("001", "other-zhangsan", 18, new Date(0x12345678), Gender.MAN));
- userMap.put("002", new User("002", "other-lisi", 20, new Date(1996-1900, 1, 2, 3, 4, 5), Gender.MAN));
- userMap.put("003", new User("003", "other-lily", 23, new Date(1993-1900, 1, 2, 3, 4, 5), Gender.WOMAN));
- userMap.put("004", new User("004", "other-lisa", 32, new Date(1985-1900, 1, 2, 3, 4, 5), Gender.WOMAN));
- }
-
- public boolean isLimit(Gender gender, String name) {
- logger.info(String.format("input gender=%sand name=%s", gender, name));
- return Gender.MAN == gender;
- }
-
- public User GetUser(String userId) {
- logger.info("input userId = " + userId);
- return new User(userId, "Joe", 48);
- }
-
- public User GetUser0(String userId, String name) {
- return new User(userId, name, 48);
- }
-
- public void GetUser3() {
- logger.info("this is GetUser3 of another");
- }
-
- public User GetErr(String userId) throws Exception {
- throw new Exception("exception");
- }
-
- public List<User> GetUsers(ArrayList<String> userIdList) {
- Iterator it = userIdList.iterator();
- List<User> userList = new ArrayList<User>();
- logger.warn("@userIdList size:" + userIdList.size());
-
- while(it.hasNext()) {
- String id = (String)(it.next());
- logger.info("GetUsers(@uid:" + id + ")");
- if (userMap.containsKey(id)) {
- userList.add(userMap.get(id));
- logger.info("id:" + id + ", com.dubbogo.user:" + userMap.get(id));
- }
- }
-
- return userList;
- }
-
- public Map<String, User> GetUserMap(List<String> userIdList) {
- Iterator it = userIdList.iterator();
- Map<String, User> map = new HashMap<String, User>();
- logger.warn("@userIdList size:" + userIdList.size());
-
- while(it.hasNext()) {
- String id = (String)(it.next());
- logger.info("GetUsers(@uid:" + id + ")");
- if (userMap.containsKey(id)) {
- map.put(id, userMap.get(id));
- logger.info("id:" + id + ", com.dubbogo.user:" + userMap.get(id));
- }
- }
-
- return map;
- }
-
- public List<User> GetUsers(List<String> userIdList) {
- Iterator it = userIdList.iterator();
- List<User> userList = new ArrayList<User>();
- logger.warn("@userIdList size:" + userIdList.size());
-
- while(it.hasNext()) {
- String id = (String)(it.next());
- logger.info("GetUsers(@uid:" + id + ")");
- if (userMap.containsKey(id)) {
- userList.add(userMap.get(id));
- logger.info("id:" + id + ", com.dubbogo.user:" + userMap.get(id));
- }
- }
-
- return userList;
- }
-
- // @Override
- public User getUser(int userCode) {
- logger.info("input userCode = " + userCode);
- return new User(String.valueOf(userCode), "userCode get", 48);
- }
-
- public User getUser(int usercode, String name) {
- return new User(String.valueOf(usercode), name, 18);
- }
-
- public User queryUser(User user) {
- logger.info("input com.dubbogo.user = " + user);
- return new User(user.getId(), "get:" + user.getName(), user.getAge() + 18);
- }
-
- public Map<String, User> queryAll() {
- logger.info("input");
- Map<String, User> map = new HashMap<String, User>();
- map.put("001", new User("001", "Joe", 18));
- map.put("002", new User("002", "Wen", 20));
-
- return map;
- }
-
- public int Calc(int a,int b) {
- return a + b + 100;
- }
-
- public Response<Integer> Sum(int a,int b) {
- return Response.ok(a+b);
- }
-}
+/*
+ * 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;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.*;
+
+public class UserProviderImpl implements UserProvider {
+ // private static final Logger logger = LoggerFactory.getLogger(getClass()); // Only output to dubbo's log(logs/server.log)
+ private static final Logger LOG = LoggerFactory.getLogger("userLogger"); // Output to com.dubbogo.user-server.log
+ private Map<String, User> userMap = new HashMap<String, User>();
+
+ UserProviderImpl() {
+ userMap.put("001", new User("001", "other-zhangsan", 18, new Date(1998, 1, 2, 3, 4, 5), Gender.MAN));
+ userMap.put("002", new User("002", "other-lisi", 20, new Date(1996, 1, 2, 3, 4, 5), Gender.MAN));
+ userMap.put("003", new User("003", "other-lily", 23, new Date(1993, 1, 2, 3, 4, 5), Gender.WOMAN));
+ userMap.put("004", new User("004", "other-lisa", 32, new Date(1985, 1, 2, 3, 4, 5), Gender.WOMAN));
+ }
+
+ public boolean isLimit(Gender gender, String name) {
+ LOG.info(String.format("input gender=%sand name=%s", gender, name));
+ return Gender.MAN == gender;
+ }
+
+ public User GetUser1(String userId) {
+ LOG.info("input userId = " + userId);
+ return new User(userId, "Joe", 48);
+ }
+
+ public User GetUser2(String userId, String name) {
+ LOG.info(String.format("input userId=%s and name=%s", userId, name));
+ return new User(userId, name, 48);
+ }
+
+ public User GetUser3(int userCode) {
+ LOG.info("input userCode = " + userCode);
+ return new User(String.valueOf(userCode), "Alex Stocks", 18);
+ }
+
+ public User GetUser4(int userCode, String name) {
+ LOG.info(String.format("input userCode=%s and name=%s", userCode, name));
+ return new User(String.valueOf(userCode), name, 18);
+ }
+
+ public User GetOneUser() {
+ return new User("1000", "xavierniu", 24);
+ }
+
+ public List<User> GetUsers(List<String> userIdList) {
+ Iterator it = userIdList.iterator();
+ List<User> userList = new ArrayList<User>();
+ LOG.warn("@userIdList size:" + userIdList.size());
+
+ while (it.hasNext()) {
+ String id = (String) (it.next());
+ LOG.info("GetUsers(@uid:" + id + ")");
+ if (userMap.containsKey(id)) {
+ userList.add(userMap.get(id));
+ LOG.info("id:" + id + ", com.dubbogo.user:" + userMap.get(id));
+ }
+ }
+
+ return userList;
+ }
+
+ public Map<String, User> GetUsersMap(List<String> userIdList) {
+ Iterator it = userIdList.iterator();
+ Map<String, User> map = new HashMap<String, User>();
+ LOG.warn("@userIdList size:" + userIdList.size());
+
+ while (it.hasNext()) {
+ String id = (String) (it.next());
+ LOG.info("GetUsers(@uid:" + id + ")");
+ if (userMap.containsKey(id)) {
+ map.put(id, userMap.get(id));
+ LOG.info("id:" + id + ", com.dubbogo.user:" + userMap.get(id));
+ }
+ }
+
+ return map;
+ }
+
+ public User queryUser(User user) {
+ LOG.info("input com.dubbogo.user = " + user);
+ return new User(user.getId(), "get:" + user.getName(), user.getAge() + 18);
+ }
+
+ public List<User> queryUsers(ArrayList<User> userObjectList) {
+ LOG.info("input com.dubbogo.userList = " + userObjectList);
+ List<User> userList = new ArrayList<User>();
+ for (User user : userObjectList) {
+ userList.add(new User(user.getId(), "get:" + user.getName(), user.getAge() + 18));
+ }
+
+ return userList;
+ }
+
+ public Map<String, User> queryAll() {
+ LOG.info("input");
+ Map<String, User> map = new HashMap<String, User>();
+ map.put("001", new User("001", "Joe", 18));
+ map.put("002", new User("002", "Wen", 20));
+
+ return map;
+ }
+
+ public User GetErr(String userId) throws Exception {
+ throw new Exception("exception");
+ }
+
+ public int Calc(int a, int b) {
+ return a + b + 100;
+ }
+
+ public Response<Integer> Sum(int a, int b) {
+ return Response.ok(a + b);
+ }
+}
diff --git a/generic/default/java-client/2.6/src/main/resources/log4j.properties b/generic/default/java-server/src/main/resources/log4j.properties
similarity index 99%
rename from generic/default/java-client/2.6/src/main/resources/log4j.properties
rename to generic/default/java-server/src/main/resources/log4j.properties
index 06bcb34..806e33d 100644
--- a/generic/default/java-client/2.6/src/main/resources/log4j.properties
+++ b/generic/default/java-server/src/main/resources/log4j.properties
@@ -17,3 +17,4 @@ log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.Threshold=DEBUG
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d{${datestamp}} %5p: %l - %m%n
+
diff --git a/generic/protobufjson/go-client/cmd/client.go b/generic/protobufjson/go-client/cmd/client.go
deleted file mode 100644
index 146cbb4..0000000
--- a/generic/protobufjson/go-client/cmd/client.go
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * 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 main
-
-import (
- "context"
- "fmt"
- "os"
- "os/signal"
- "syscall"
- "time"
-)
-
-import (
- _ "dubbo.apache.org/dubbo-go/v3/cluster/cluster_impl"
- _ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance"
- "dubbo.apache.org/dubbo-go/v3/common/logger"
- _ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory"
- "dubbo.apache.org/dubbo-go/v3/config"
- _ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl"
- "dubbo.apache.org/dubbo-go/v3/protocol/dubbo"
- _ "dubbo.apache.org/dubbo-go/v3/registry/protocol"
- _ "dubbo.apache.org/dubbo-go/v3/registry/zookeeper"
-
- hessian "github.com/apache/dubbo-go-hessian2"
-
- "github.com/dubbogo/gost/log"
-)
-
-var (
- appName = "UserConsumer"
- referenceConfig = config.ReferenceConfig{
- InterfaceName: "org.apache.dubbo.UserProvider",
- Cluster: "failover",
- Registry: "demoZk",
- Protocol: dubbo.DUBBO,
- Generic: "protobuf-json",
- }
-)
-
-func init() {
- config.Load()
- referenceConfig.GenericLoad(appName) //appName is the unique identification of RPCService
- time.Sleep(3 * time.Second)
-}
-
-// need to setup environment variable "CONF_CONSUMER_FILE_PATH" to "conf/client.yml" before run
-func main() {
- gxlog.CInfo("\n\ncall getUser")
- callGetUser()
-
- initSignal()
-}
-
-func initSignal() {
- signals := make(chan os.Signal, 1)
- // It is not possible to block SIGKILL or syscall.SIGSTOP
- signal.Notify(signals, os.Interrupt, os.Kill, syscall.SIGHUP,
- syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
- for {
- sig := <-signals
- logger.Infof("get signal %s", sig.String())
- switch sig {
- case syscall.SIGHUP:
- // reload()
- default:
- time.AfterFunc(10*time.Second, func() {
- logger.Warnf("app exit now by force...")
- os.Exit(1)
- })
-
- // The program exits normally or timeout forcibly exits.
- fmt.Println("app exit now...")
- return
- }
- }
-}
-
-func callGetUser() {
- gxlog.CInfo("\n\n\nstart to generic invoke")
- resp, err := referenceConfig.GetRPCService().(*config.GenericService).Invoke(
- context.TODO(),
- []interface{}{
- "GetUser",
- []string{},
- // "{\"id\":1}" is a JSON string that represents an UserRequestType object shown in the below:
- // &UserRequestType{
- // Id: 1
- // }
- []hessian.Object{"{\"id\":1}"},
- },
- )
- if err != nil {
- panic(err)
- }
- gxlog.CInfo("res: %+v\n", resp)
- gxlog.CInfo("success!")
-
-}
diff --git a/generic/protobufjson/go-client/conf/client.yml b/generic/protobufjson/go-client/conf/client.yml
deleted file mode 100644
index 047d367..0000000
--- a/generic/protobufjson/go-client/conf/client.yml
+++ /dev/null
@@ -1,59 +0,0 @@
-# dubbo client yaml configure file
-
-check: true
-# client
-request_timeout : "3s"
-# connect timeout
-connect_timeout : "3s"
-
-# application config
-application:
- organization : "dubbo.io"
- name : "UserConsumer"
- module : "dubbo-go user-info client"
- version : "0.0.1"
- environment : "dev"
-
-# registry config
-registries :
- "demoZk":
- protocol: "zookeeper"
- timeout : "3s"
- address: "127.0.0.1:2181"
- username: ""
- password: ""
-
-# reference config
-references:
- "UserProvider":
- registry: "demoZk"
- protocol : "dubbo"
- interface : "org.apache.dubbo.UserProvider"
- cluster: "failover"
- methods :
- - name: "GetUser"
- retries: 3
-
-# protocol config
-protocol_conf:
- dubbo:
- reconnect_interval: 0
- connection_number: 1
- heartbeat_period: "5s"
- session_timeout: "180s"
- pool_size: 64
- pool_ttl: 600
- getty_session_param:
- compress_encoding: false
- tcp_no_delay: true
- tcp_keep_alive: true
- keep_alive_period: "120s"
- tcp_r_buf_size: 262144
- tcp_w_buf_size: 65536
- pkg_rq_size: 1024
- pkg_wq_size: 512
- tcp_read_timeout: "1s"
- tcp_write_timeout: "5s"
- wait_timeout: "1s"
- max_msg_len: 1024000
- session_name: "client"
diff --git a/generic/protobufjson/go-client/conf/log.yml b/generic/protobufjson/go-client/conf/log.yml
deleted file mode 100644
index d19d907..0000000
--- a/generic/protobufjson/go-client/conf/log.yml
+++ /dev/null
@@ -1,28 +0,0 @@
-
-level: "warn"
-development: true
-disableCaller: false
-disableStacktrace: false
-sampling:
-encoding: "console"
-
-# encoder
-encoderConfig:
- messageKey: "message"
- levelKey: "level"
- timeKey: "time"
- nameKey: "logger"
- callerKey: "caller"
- stacktraceKey: "stacktrace"
- lineEnding: ""
- levelEncoder: "capital"
- timeEncoder: "iso8601"
- durationEncoder: "seconds"
- callerEncoder: "short"
- nameEncoder: ""
-
-outputPaths:
- - "stderr"
-errorOutputPaths:
- - "stderr"
-initialFields:
diff --git a/generic/protobufjson/go-client/pkg/user.go b/generic/protobufjson/go-client/pkg/user.go
deleted file mode 100644
index 185b851..0000000
--- a/generic/protobufjson/go-client/pkg/user.go
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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 pkg
-
-import (
- "time"
-)
-
-type User struct {
- ID string
- Name string
- Age int32
- Time time.Time
-}
-
-func (User) JavaClassName() string {
- return "org.apache.dubbo.User"
-}
diff --git a/generic/protobufjson/go-server/cmd/server.go b/generic/protobufjson/go-server/cmd/server.go
deleted file mode 100644
index 5d78ee0..0000000
--- a/generic/protobufjson/go-server/cmd/server.go
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * 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 main
-
-import (
- "fmt"
- "os"
- "os/signal"
- "syscall"
- "time"
-)
-
-import (
- _ "dubbo.apache.org/dubbo-go/v3/cluster/cluster_impl"
- _ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance"
- "dubbo.apache.org/dubbo-go/v3/common/logger"
- _ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory"
- "dubbo.apache.org/dubbo-go/v3/config"
- _ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl"
- _ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo"
- _ "dubbo.apache.org/dubbo-go/v3/registry/protocol"
- _ "dubbo.apache.org/dubbo-go/v3/registry/zookeeper"
-)
-
-import (
- "github.com/apache/dubbo-go-samples/generic/protobufjson/go-server/pkg"
-)
-
-func init() {
- config.SetProviderService(new(pkg.UserProvider))
-}
-
-var (
- survivalTimeout = int(3e9)
-)
-
-// need to setup environment variable "CONF_PROVIDER_FILE_PATH" to "conf/server.yml" before run
-func main() {
- config.Load()
-
- initSignal()
-}
-
-func initSignal() {
- signals := make(chan os.Signal, 1)
- // It is not possible to block SIGKILL or syscall.SIGSTOP
- signal.Notify(signals, os.Interrupt, os.Kill, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
- for {
- sig := <-signals
- logger.Infof("get signal %s", sig.String())
- switch sig {
- case syscall.SIGHUP:
- // reload()
- default:
- time.AfterFunc(time.Duration(survivalTimeout), func() {
- logger.Warnf("app exit now by force...")
- os.Exit(1)
- })
-
- // The program exits normally or timeout forcibly exits.
- fmt.Println("provider app exit now...")
- return
- }
- }
-}
diff --git a/generic/protobufjson/go-server/conf/client.yml b/generic/protobufjson/go-server/conf/client.yml
deleted file mode 100644
index 047d367..0000000
--- a/generic/protobufjson/go-server/conf/client.yml
+++ /dev/null
@@ -1,59 +0,0 @@
-# dubbo client yaml configure file
-
-check: true
-# client
-request_timeout : "3s"
-# connect timeout
-connect_timeout : "3s"
-
-# application config
-application:
- organization : "dubbo.io"
- name : "UserConsumer"
- module : "dubbo-go user-info client"
- version : "0.0.1"
- environment : "dev"
-
-# registry config
-registries :
- "demoZk":
- protocol: "zookeeper"
- timeout : "3s"
- address: "127.0.0.1:2181"
- username: ""
- password: ""
-
-# reference config
-references:
- "UserProvider":
- registry: "demoZk"
- protocol : "dubbo"
- interface : "org.apache.dubbo.UserProvider"
- cluster: "failover"
- methods :
- - name: "GetUser"
- retries: 3
-
-# protocol config
-protocol_conf:
- dubbo:
- reconnect_interval: 0
- connection_number: 1
- heartbeat_period: "5s"
- session_timeout: "180s"
- pool_size: 64
- pool_ttl: 600
- getty_session_param:
- compress_encoding: false
- tcp_no_delay: true
- tcp_keep_alive: true
- keep_alive_period: "120s"
- tcp_r_buf_size: 262144
- tcp_w_buf_size: 65536
- pkg_rq_size: 1024
- pkg_wq_size: 512
- tcp_read_timeout: "1s"
- tcp_write_timeout: "5s"
- wait_timeout: "1s"
- max_msg_len: 1024000
- session_name: "client"
diff --git a/generic/protobufjson/go-server/conf/log.yml b/generic/protobufjson/go-server/conf/log.yml
deleted file mode 100644
index a75bccb..0000000
--- a/generic/protobufjson/go-server/conf/log.yml
+++ /dev/null
@@ -1,28 +0,0 @@
-
-level: "error"
-development: true
-disableCaller: false
-disableStacktrace: false
-sampling:
-encoding: "console"
-
-# encoder
-encoderConfig:
- messageKey: "message"
- levelKey: "level"
- timeKey: "time"
- nameKey: "logger"
- callerKey: "caller"
- stacktraceKey: "stacktrace"
- lineEnding: ""
- levelEncoder: "capital"
- timeEncoder: "iso8601"
- durationEncoder: "seconds"
- callerEncoder: "short"
- nameEncoder: ""
-
-outputPaths:
- - "stderr"
-errorOutputPaths:
- - "stderr"
-initialFields:
diff --git a/generic/protobufjson/go-server/conf/server.yml b/generic/protobufjson/go-server/conf/server.yml
deleted file mode 100644
index 6e8970c..0000000
--- a/generic/protobufjson/go-server/conf/server.yml
+++ /dev/null
@@ -1,55 +0,0 @@
-# dubbo server yaml configure file
-
-# application config
-application:
- organization : "dubbo.io"
- name : "UserInfoServer"
- module : "dubbo-go user-info server"
- version : "0.0.1"
- environment : "dev"
-
-# registry config
-registries :
- "demoZk":
- protocol: "zookeeper"
- timeout : "3s"
- address: "127.0.0.1:2181"
-
-# service config
-services:
- "UserProvider":
- registry: "demoZk"
- protocol : "dubbo"
- interface : "org.apache.dubbo.UserProvider"
- loadbalance: "random"
- warmup: "100"
- cluster: "failover"
- methods:
- - name: "GetUser"
- retries: 1
- loadbalance: "random"
-
-# protocol config
-protocols:
- "dubbo":
- name: "dubbo"
- port: 20000
-
-protocol_conf:
- dubbo:
- session_number: 700
- session_timeout: "180s"
- getty_session_param:
- compress_encoding: false
- tcp_no_delay: true
- tcp_keep_alive: true
- keep_alive_period: "120s"
- tcp_r_buf_size: 262144
- tcp_w_buf_size: 65536
- pkg_rq_size: 1024
- pkg_wq_size: 512
- tcp_read_timeout: "1s"
- tcp_write_timeout: "5s"
- wait_timeout: "1s"
- max_msg_len: 1024000
- session_name: "server"
diff --git a/generic/protobufjson/go-server/pkg/user.go b/generic/protobufjson/go-server/pkg/user.go
deleted file mode 100644
index 6871451..0000000
--- a/generic/protobufjson/go-server/pkg/user.go
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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 pkg
-
-import (
- "context"
-)
-
-import (
- "github.com/dubbogo/gost/log"
-)
-
-type UserProvider struct {
-}
-
-func (u *UserProvider) GetUser(ctx context.Context, user *UserRequestType) (*UserResponseType, error) {
- gxlog.CInfo("req:%#v", int(user.GetId()))
- rsp := &UserResponseType{
- Name: "XavierNiu",
- Age: 20,
- }
- gxlog.CInfo("rsp:%#v", rsp)
- return rsp, nil
-}
-
-func (u *UserProvider) Reference() string {
- return "UserProvider"
-}
diff --git a/generic/protobufjson/go-server/pkg/user.pb.go b/generic/protobufjson/go-server/pkg/user.pb.go
deleted file mode 100644
index 1166267..0000000
--- a/generic/protobufjson/go-server/pkg/user.pb.go
+++ /dev/null
@@ -1,219 +0,0 @@
-// Code generated by protoc-gen-go. DO NOT EDIT.
-// versions:
-// protoc-gen-go v1.26.0
-// protoc v3.17.3
-// source: user.proto
-
-package pkg
-
-import (
- reflect "reflect"
- sync "sync"
-)
-
-import (
- protoreflect "google.golang.org/protobuf/reflect/protoreflect"
-
- protoimpl "google.golang.org/protobuf/runtime/protoimpl"
-)
-
-const (
- // Verify that this generated code is sufficiently up-to-date.
- _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
- // Verify that runtime/protoimpl is sufficiently up-to-date.
- _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
-)
-
-type UserRequestType struct {
- state protoimpl.MessageState
- sizeCache protoimpl.SizeCache
- unknownFields protoimpl.UnknownFields
-
- Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
-}
-
-func (x *UserRequestType) Reset() {
- *x = UserRequestType{}
- if protoimpl.UnsafeEnabled {
- mi := &file_user_proto_msgTypes[0]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
- }
-}
-
-func (x *UserRequestType) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*UserRequestType) ProtoMessage() {}
-
-func (x *UserRequestType) ProtoReflect() protoreflect.Message {
- mi := &file_user_proto_msgTypes[0]
- if protoimpl.UnsafeEnabled && x != nil {
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- if ms.LoadMessageInfo() == nil {
- ms.StoreMessageInfo(mi)
- }
- return ms
- }
- return mi.MessageOf(x)
-}
-
-// Deprecated: Use UserRequestType.ProtoReflect.Descriptor instead.
-func (*UserRequestType) Descriptor() ([]byte, []int) {
- return file_user_proto_rawDescGZIP(), []int{0}
-}
-
-func (x *UserRequestType) GetId() int64 {
- if x != nil {
- return x.Id
- }
- return 0
-}
-
-type UserResponseType struct {
- state protoimpl.MessageState
- sizeCache protoimpl.SizeCache
- unknownFields protoimpl.UnknownFields
-
- Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
- Age int64 `protobuf:"varint,2,opt,name=age,proto3" json:"age,omitempty"`
-}
-
-func (x *UserResponseType) Reset() {
- *x = UserResponseType{}
- if protoimpl.UnsafeEnabled {
- mi := &file_user_proto_msgTypes[1]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
- }
-}
-
-func (x *UserResponseType) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*UserResponseType) ProtoMessage() {}
-
-func (x *UserResponseType) ProtoReflect() protoreflect.Message {
- mi := &file_user_proto_msgTypes[1]
- if protoimpl.UnsafeEnabled && x != nil {
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- if ms.LoadMessageInfo() == nil {
- ms.StoreMessageInfo(mi)
- }
- return ms
- }
- return mi.MessageOf(x)
-}
-
-// Deprecated: Use UserResponseType.ProtoReflect.Descriptor instead.
-func (*UserResponseType) Descriptor() ([]byte, []int) {
- return file_user_proto_rawDescGZIP(), []int{1}
-}
-
-func (x *UserResponseType) GetName() string {
- if x != nil {
- return x.Name
- }
- return ""
-}
-
-func (x *UserResponseType) GetAge() int64 {
- if x != nil {
- return x.Age
- }
- return 0
-}
-
-var File_user_proto protoreflect.FileDescriptor
-
-var file_user_proto_rawDesc = []byte{
- 0x0a, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x2a, 0x6f, 0x72,
- 0x67, 0x2e, 0x61, 0x70, 0x61, 0x63, 0x68, 0x65, 0x2e, 0x64, 0x75, 0x62, 0x62, 0x6f, 0x2e, 0x67,
- 0x65, 0x6e, 0x65, 0x72, 0x69, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x6a,
- 0x73, 0x6f, 0x6e, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x22, 0x21, 0x0a, 0x0f, 0x55, 0x73, 0x65, 0x72,
- 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69,
- 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x22, 0x38, 0x0a, 0x10, 0x55,
- 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12,
- 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e,
- 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03,
- 0x52, 0x03, 0x61, 0x67, 0x65, 0x42, 0x08, 0x5a, 0x06, 0x2e, 0x2f, 0x3b, 0x70, 0x6b, 0x67, 0x62,
- 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
-}
-
-var (
- file_user_proto_rawDescOnce sync.Once
- file_user_proto_rawDescData = file_user_proto_rawDesc
-)
-
-func file_user_proto_rawDescGZIP() []byte {
- file_user_proto_rawDescOnce.Do(func() {
- file_user_proto_rawDescData = protoimpl.X.CompressGZIP(file_user_proto_rawDescData)
- })
- return file_user_proto_rawDescData
-}
-
-var file_user_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
-var file_user_proto_goTypes = []interface{}{
- (*UserRequestType)(nil), // 0: org.apache.dubbo.generic.protobufjson.user.UserRequestType
- (*UserResponseType)(nil), // 1: org.apache.dubbo.generic.protobufjson.user.UserResponseType
-}
-var file_user_proto_depIdxs = []int32{
- 0, // [0:0] is the sub-list for method output_type
- 0, // [0:0] is the sub-list for method input_type
- 0, // [0:0] is the sub-list for extension type_name
- 0, // [0:0] is the sub-list for extension extendee
- 0, // [0:0] is the sub-list for field type_name
-}
-
-func init() { file_user_proto_init() }
-func file_user_proto_init() {
- if File_user_proto != nil {
- return
- }
- if !protoimpl.UnsafeEnabled {
- file_user_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
- switch v := v.(*UserRequestType); i {
- case 0:
- return &v.state
- case 1:
- return &v.sizeCache
- case 2:
- return &v.unknownFields
- default:
- return nil
- }
- }
- file_user_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
- switch v := v.(*UserResponseType); i {
- case 0:
- return &v.state
- case 1:
- return &v.sizeCache
- case 2:
- return &v.unknownFields
- default:
- return nil
- }
- }
- }
- type x struct{}
- out := protoimpl.TypeBuilder{
- File: protoimpl.DescBuilder{
- GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
- RawDescriptor: file_user_proto_rawDesc,
- NumEnums: 0,
- NumMessages: 2,
- NumExtensions: 0,
- NumServices: 0,
- },
- GoTypes: file_user_proto_goTypes,
- DependencyIndexes: file_user_proto_depIdxs,
- MessageInfos: file_user_proto_msgTypes,
- }.Build()
- File_user_proto = out.File
- file_user_proto_rawDesc = nil
- file_user_proto_goTypes = nil
- file_user_proto_depIdxs = nil
-}
diff --git a/generic/protobufjson/go-server/tests/integration/main_test.go b/generic/protobufjson/go-server/tests/integration/main_test.go
deleted file mode 100644
index 44153bd..0000000
--- a/generic/protobufjson/go-server/tests/integration/main_test.go
+++ /dev/null
@@ -1,55 +0,0 @@
-// +build integration
-
-/*
- * 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 integration
-
-import (
- "os"
- "testing"
- "time"
-)
-
-import (
- _ "dubbo.apache.org/dubbo-go/v3/cluster/cluster_impl"
- _ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance"
- _ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory"
- "dubbo.apache.org/dubbo-go/v3/config"
- _ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl"
- "dubbo.apache.org/dubbo-go/v3/protocol/dubbo"
- _ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo"
- _ "dubbo.apache.org/dubbo-go/v3/registry/protocol"
- _ "dubbo.apache.org/dubbo-go/v3/registry/zookeeper"
-)
-
-var appName = "UserConsumerTest"
-var referenceConfig = config.ReferenceConfig{
- InterfaceName: "org.apache.dubbo.UserProvider",
- Cluster: "failover",
- Registry: "demoZk",
- Protocol: dubbo.DUBBO,
- Generic: "protobuf-json",
-}
-
-func TestMain(m *testing.M) {
- config.Load()
- referenceConfig.GenericLoad(appName)
- time.Sleep(3 * time.Second)
-
- os.Exit(m.Run())
-}
diff --git a/generic/protobufjson/go-server/tests/integration/userprovider_test.go b/generic/protobufjson/go-server/tests/integration/userprovider_test.go
deleted file mode 100644
index 0ad6d74..0000000
--- a/generic/protobufjson/go-server/tests/integration/userprovider_test.go
+++ /dev/null
@@ -1,47 +0,0 @@
-// +build integration
-
-/*
- * 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 integration
-
-import (
- "context"
- "testing"
-)
-
-import (
- "dubbo.apache.org/dubbo-go/v3/config"
-
- hessian "github.com/apache/dubbo-go-hessian2"
-
- "github.com/stretchr/testify/assert"
-)
-
-func TestGetUser(t *testing.T) {
- o, err := referenceConfig.GetRPCService().(*config.GenericService).Invoke(
- context.TODO(),
- []interface{}{
- "GetUser",
- []string{},
- []hessian.Object{"{\"id\":1}"},
- },
- )
- assert.Nil(t, err)
- resp := o.(string)
- assert.Equal(t, `{"name":"XavierNiu","age":"20"}`, resp)
-}
diff --git a/generic/protobufjson/user.proto b/generic/protobufjson/user.proto
deleted file mode 100644
index 22cc3dd..0000000
--- a/generic/protobufjson/user.proto
+++ /dev/null
@@ -1,14 +0,0 @@
-syntax = "proto3";
-
-package org.apache.dubbo.generic.protobufjson.user;
-
-option go_package = "./;pkg";
-
-message UserRequestType {
- int64 id = 1;
-}
-
-message UserResponseType {
- string name = 1;
- int64 age = 2;
-}
diff --git a/generic/protobufjson/go-server/docker/docker-compose.yml b/integrate_test/generic/default/docker/docker-compose.yml
similarity index 100%
rename from generic/protobufjson/go-server/docker/docker-compose.yml
rename to integrate_test/generic/default/docker/docker-compose.yml
diff --git a/generic/protobufjson/go-server/docker/docker-health-check.sh b/integrate_test/generic/default/docker/docker-health-check.sh
similarity index 100%
rename from generic/protobufjson/go-server/docker/docker-health-check.sh
rename to integrate_test/generic/default/docker/docker-health-check.sh
diff --git a/generic/default/go-server/tests/integration/main_test.go b/integrate_test/generic/default/tests/integration/main_test.go
similarity index 65%
rename from generic/default/go-server/tests/integration/main_test.go
rename to integrate_test/generic/default/tests/integration/main_test.go
index 2f167fc..fcf47c7 100644
--- a/generic/default/go-server/tests/integration/main_test.go
+++ b/integrate_test/generic/default/tests/integration/main_test.go
@@ -1,5 +1,3 @@
-// +build integration
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -22,7 +20,6 @@ package integration
import (
"os"
"testing"
- "time"
)
import (
@@ -35,32 +32,43 @@ import (
_ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo"
_ "dubbo.apache.org/dubbo-go/v3/registry/protocol"
_ "dubbo.apache.org/dubbo-go/v3/registry/zookeeper"
+
+ hessian "github.com/apache/dubbo-go-hessian2"
+)
+
+import (
+ pkg "github.com/apache/dubbo-go-samples/generic/default/go-server/pkg"
+)
+
+var (
+ appName = "dubbo.io"
+ referenceConfig config.ReferenceConfig
)
-var appName = "UserConsumerTest"
-var referenceConfig = config.ReferenceConfig{
- InterfaceName: "org.apache.dubbo.UserProvider",
- Cluster: "failover",
- Registry: "demoZk",
- Protocol: dubbo.DUBBO,
- Generic: "true",
+func init() {
+ registryConfig := &config.RegistryConfig{
+ Protocol: "zookeeper",
+ Address: "127.0.0.1:2181",
+ }
+
+ referenceConfig = config.ReferenceConfig{
+ InterfaceName: "org.apache.dubbo.UserProvider",
+ Cluster: "failover",
+ Registry: []string{"zk"},
+ Protocol: dubbo.DUBBO,
+ Generic: "true",
+ }
+
+ rootConfig := config.NewRootConfig(config.WithRootRegistryConfig("zk", registryConfig))
+ _ = rootConfig.Init()
+ _ = referenceConfig.Init(rootConfig)
+ referenceConfig.GenericLoad(appName)
}
func TestMain(m *testing.M) {
+ hessian.RegisterPOJO(&pkg.User{})
+ config.SetProviderService(&pkg.User{})
config.Load()
- referenceConfig.GenericLoad(appName)
- time.Sleep(3 * time.Second)
os.Exit(m.Run())
}
-
-type User struct {
- ID string
- Name string
- Age int32
- Time time.Time
-}
-
-func (User) JavaClassName() string {
- return "org.apache.dubbo.User"
-}
diff --git a/integrate_test/generic/default/tests/integration/userprovider_test.go b/integrate_test/generic/default/tests/integration/userprovider_test.go
new file mode 100644
index 0000000..ad7104d
--- /dev/null
+++ b/integrate_test/generic/default/tests/integration/userprovider_test.go
@@ -0,0 +1,216 @@
+/*
+ * 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 integration
+
+import (
+ "context"
+ "testing"
+ "time"
+)
+
+import (
+ "dubbo.apache.org/dubbo-go/v3/config/generic"
+
+ hessian "github.com/apache/dubbo-go-hessian2"
+
+ "github.com/stretchr/testify/assert"
+)
+
+//import (
+// pkg "github.com/apache/dubbo-go-samples/generic/default/go-server/pkg"
+//)
+
+func TestGetUser1(t *testing.T) {
+ o, err := referenceConfig.GetRPCService().(*generic.GenericService).Invoke(
+ context.TODO(),
+ []interface{}{
+ "GetUser1",
+ []string{"java.lang.String"},
+ []hessian.Object{"A003"},
+ },
+ )
+ assert.Nil(t, err)
+ assert.IsType(t, make(map[interface{}]interface{}, 0), o)
+ resp := o.(map[interface{}]interface{})
+ assert.Equal(t, "Joe", resp["name"])
+ assert.Equal(t, int32(48), resp["age"])
+ assert.Equal(t, "A003", resp["iD"])
+}
+
+func TestGetUser2(t *testing.T) {
+ o, err := referenceConfig.GetRPCService().(*generic.GenericService).Invoke(
+ context.TODO(),
+ []interface{}{
+ "GetUser2",
+ []string{"java.lang.String", "java.lang.String"},
+ []hessian.Object{"A003", "lily"},
+ },
+ )
+ assert.Nil(t, err)
+ assert.IsType(t, make(map[interface{}]interface{}, 0), o)
+ resp := o.(map[interface{}]interface{})
+ assert.Equal(t, "lily", resp["name"])
+ assert.Equal(t, int32(48), resp["age"])
+ assert.Equal(t, "A003", resp["iD"])
+}
+
+func TestGetUser3(t *testing.T) {
+ o, err := referenceConfig.GetRPCService().(*generic.GenericService).Invoke(
+ context.TODO(),
+ []interface{}{
+ "GetUser3",
+ []string{"int"},
+ []hessian.Object{1},
+ },
+ )
+ assert.Nil(t, err)
+ assert.IsType(t, make(map[interface{}]interface{}, 0), o)
+ resp := o.(map[interface{}]interface{})
+ assert.Equal(t, "Alex Stocks", resp["name"])
+ assert.Equal(t, int32(18), resp["age"])
+ assert.Equal(t, "1", resp["iD"])
+}
+
+func TestGetUser4(t *testing.T) {
+ o, err := referenceConfig.GetRPCService().(*generic.GenericService).Invoke(
+ context.TODO(),
+ []interface{}{
+ "GetUser4",
+ []string{"int", "java.lang.String"},
+ []hessian.Object{1, "zhangsan"},
+ },
+ )
+ assert.Nil(t, err)
+ assert.IsType(t, make(map[interface{}]interface{}, 0), o)
+ resp := o.(map[interface{}]interface{})
+ assert.Equal(t, "zhangsan", resp["name"])
+ assert.Equal(t, int32(18), resp["age"])
+ assert.Equal(t, "1", resp["iD"])
+}
+
+func TestGetOneUser(t *testing.T) {
+ o, err := referenceConfig.GetRPCService().(*generic.GenericService).Invoke(
+ context.TODO(),
+ []interface{}{
+ "GetOneUser",
+ []hessian.Object{},
+ []hessian.Object{},
+ },
+ )
+ assert.Nil(t, err)
+ assert.IsType(t, make(map[interface{}]interface{}, 0), o)
+ resp := o.(map[interface{}]interface{})
+ assert.Equal(t, "xavierniu", resp["name"])
+ assert.Equal(t, int32(24), resp["age"])
+ assert.Equal(t, "1000", resp["iD"])
+}
+
+func TestGetUsers(t *testing.T) {
+ o, err := referenceConfig.GetRPCService().(*generic.GenericService).Invoke(
+ context.TODO(),
+ []interface{}{
+ "GetUsers",
+ []string{"java.util.List"},
+ []hessian.Object{
+ []hessian.Object{
+ "001", "002", "003", "004",
+ },
+ },
+ },
+ )
+ assert.Nil(t, err)
+ assert.IsType(t, make(map[interface{}]interface{}, 0), o)
+ //resp := o.(map[interface{}]interface{})
+ //assert.Equal(t, "other-zhangsan", resp[0].(*pkg.User).Name)
+ //assert.Equal(t, "other-lisi", resp[1].(*pkg.User).Name)
+ //assert.Equal(t, "other-lily", resp[2].(*pkg.User).Name)
+ //assert.Equal(t, "other-lisa", resp[3].(*pkg.User).Name)
+}
+
+func TestQueryUser(t *testing.T) {
+ o, err := referenceConfig.GetRPCService().(*generic.GenericService).Invoke(
+ context.TODO(),
+ []interface{}{
+ "queryUser",
+ []string{"org.apache.dubbo.User"},
+ []hessian.Object{map[string]hessian.Object{
+ "iD": "3213",
+ "name": "panty",
+ "age": 25,
+ "time": time.Now(),
+ }},
+ },
+ )
+
+ assert.Nil(t, err)
+ assert.IsType(t, make(map[interface{}]interface{}, 0), o)
+ resp := o.(map[interface{}]interface{})
+ assert.Equal(t, "panty", resp["name"])
+ assert.Equal(t, int32(25), resp["age"])
+ assert.Equal(t, "3213", resp["iD"])
+}
+
+//
+//func TestQueryUsers(t *testing.T) {
+// o, err := referenceConfig.GetRPCService().(*generic.GenericService).Invoke(
+// context.TODO(),
+// []interface{}{
+// "queryUsers",
+// []string{"org.apache.dubbo.User"},
+// []hessian.Object{
+// map[string]hessian.Object{
+// "id": "3212",
+// "name": "XavierNiu",
+// "age": 24,
+// "time": time.Now().Add(4),
+// "class": "org.apache.dubbo.User",
+// },
+// map[string]hessian.Object{
+// "iD": "3213",
+// "name": "zhangsan",
+// "age": 21,
+// "time": time.Now().Add(4),
+// "class": "org.apache.dubbo.User",
+// },
+// },
+// },
+// )
+//
+// assert.Nil(t, err)
+// assert.IsType(t, make(map[interface{}]interface{}, 0), o)
+// resp := o.(map[interface{}]interface{})
+// assert.Equal(t, "XavierNiu", resp[0].(*pkg.User).Name)
+// assert.Equal(t, "zhangsan", resp[1].(*pkg.User).Name)
+//}
+//
+//func TestQueryAll(t *testing.T) {
+// o, err := referenceConfig.GetRPCService().(*generic.GenericService).Invoke(
+// context.TODO(),
+// []interface{}{
+// "queryAll",
+// []hessian.Object{},
+// []hessian.Object{},
+// },
+// )
+//
+// assert.Nil(t, err)
+// assert.IsType(t, make(map[interface{}]interface{}, 0), o)
+// resp := o.(map[interface{}]interface{})
+// assert.Equal(t, "Joe", resp[0].(*pkg.User).Name)
+// assert.Equal(t, "Wen", resp[1].(*pkg.User).Name)
+//}
diff --git a/start_integrate_test.sh b/start_integrate_test.sh
index 0116807..6dec14f 100755
--- a/start_integrate_test.sh
+++ b/start_integrate_test.sh
@@ -91,6 +91,8 @@ array+=("context/dubbo/go-server")
# config api
array=("config-api/configcenter/nacos")
+# generic
+array+=("generic/default")
array+=("config-api/configcenter/zookeeper")
# unclassified