Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 40 additions & 17 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.tencent.trpc</groupId>
<artifactId>trpc-parent</artifactId>
<version>1.4.0-SNAPSHOT</version>
<version>2.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<description>Trpc Parent Project ${project.version}</description>
<name>trpc</name>
Expand Down Expand Up @@ -89,12 +89,12 @@
<maven.source.version>3.0.1</maven.source.version>
<maven.exec.version>3.0.1</maven.exec.version>
<maven.jar.version>3.1.2</maven.jar.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.version>3.7.0</maven.compiler.version>
<maven.gpg.version>3.1.0</maven.gpg.version>
<maven.ignore.testfailure>false</maven.ignore.testfailure>
<maven.surefire.version>2.22.0</maven.surefire.version>
<maven.surefire.version>3.1.2</maven.surefire.version>
<maven.javadoc.version>3.0.1</maven.javadoc.version>
<central-publishing-maven-plugin.version>0.7.0</central-publishing-maven-plugin.version>
<exec.maven.version>3.1.0</exec.maven.version>
Expand Down Expand Up @@ -122,29 +122,48 @@

<dependencies>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.9.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.9.3</version>
<scope>test</scope>
</dependency>
<!-- 保留 JUnit 4 测试 -->
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-support</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4-rule</artifactId>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.powermock</groupId>-->
<!-- <artifactId>powermock-module-junit4</artifactId>-->
<!-- <scope>test</scope>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.powermock</groupId>-->
<!-- <artifactId>powermock-api-mockito2</artifactId>-->
<!-- <scope>test</scope>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.powermock</groupId>-->
<!-- <artifactId>powermock-api-support</artifactId>-->
<!-- <scope>test</scope>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.powermock</groupId>-->
<!-- <artifactId>powermock-module-junit4-rule</artifactId>-->
<!-- <scope>test</scope>-->
<!-- </dependency>-->
<dependency>
<groupId>org.jacoco</groupId>
<artifactId>org.jacoco.agent</artifactId>
<version>0.8.6</version>
<version>0.8.11</version>
<classifier>runtime</classifier>
<scope>test</scope>
</dependency>
Expand Down Expand Up @@ -177,6 +196,10 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.version}</version>
<configuration>
<argLine>
--add-opens java.base/java.lang=ALL-UNNAMED
--add-opens java.base/java.util=ALL-UNNAMED
</argLine>
<testFailureIgnore>${maven.ignore.testfailure}</testFailureIgnore>
<skipTests>false</skipTests>
<systemPropertyVariables>
Expand Down Expand Up @@ -249,7 +272,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.6</version>
<version>0.8.8</version>
<configuration>
<skip>false</skip>
</configuration>
Expand Down
2 changes: 1 addition & 1 deletion trpc-admin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.tencent.trpc</groupId>
<artifactId>trpc-parent</artifactId>
<version>1.4.0-SNAPSHOT</version>
<version>2.0.1-SNAPSHOT</version>
</parent>

<artifactId>trpc-admin</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion trpc-admin/trpc-admin-default/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>com.tencent.trpc</groupId>
<artifactId>trpc-admin</artifactId>
<version>1.4.0-SNAPSHOT</version>
<version>2.0.1-SNAPSHOT</version>
</parent>

<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion trpc-bootstrap/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.tencent.trpc</groupId>
<artifactId>trpc-parent</artifactId>
<version>1.4.0-SNAPSHOT</version>
<version>2.0.1-SNAPSHOT</version>
</parent>

<artifactId>trpc-bootstrap</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion trpc-bootstrap/trpc-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.tencent.trpc</groupId>
<artifactId>trpc-bootstrap</artifactId>
<version>1.4.0-SNAPSHOT</version>
<version>2.0.1-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion trpc-code-generator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<artifactId>trpc-parent</artifactId>
<groupId>com.tencent.trpc</groupId>
<version>1.4.0-SNAPSHOT</version>
<version>2.0.1-SNAPSHOT</version>
</parent>

<artifactId>trpc-code-generator</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion trpc-configcenter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>trpc-parent</artifactId>
<groupId>com.tencent.trpc</groupId>
<version>1.4.0-SNAPSHOT</version>
<version>2.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion trpc-configcenter/trpc-configcenter-nacos/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.tencent.trpc</groupId>
<artifactId>trpc-configcenter</artifactId>
<version>1.4.0-SNAPSHOT</version>
<version>2.0.1-SNAPSHOT</version>
</parent>
<packaging>jar</packaging>
<name>${project.artifactId}</name>
Expand Down
2 changes: 1 addition & 1 deletion trpc-configcenter/trpc-configcenter-open-polaris/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.tencent.trpc</groupId>
<artifactId>trpc-configcenter</artifactId>
<version>1.4.0-SNAPSHOT</version>
<version>2.0.1-SNAPSHOT</version>
</parent>
<packaging>jar</packaging>
<name>${project.artifactId}</name>
Expand Down
2 changes: 1 addition & 1 deletion trpc-container/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.tencent.trpc</groupId>
<artifactId>trpc-parent</artifactId>
<version>1.4.0-SNAPSHOT</version>
<version>2.0.1-SNAPSHOT</version>
</parent>

<artifactId>trpc-container</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion trpc-container/trpc-container-default/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>com.tencent.trpc</groupId>
<artifactId>trpc-container</artifactId>
<version>1.4.0-SNAPSHOT</version>
<version>2.0.1-SNAPSHOT</version>
</parent>

<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion trpc-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>com.tencent.trpc</groupId>
<artifactId>trpc-parent</artifactId>
<version>1.4.0-SNAPSHOT</version>
<version>2.0.1-SNAPSHOT</version>
</parent>

<packaging>jar</packaging>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class Version {
* VERSION: Do not modify the line number of this line. If you want to modify it, be sure to change deploy.sh at
* the same time.
*/
public static final String VERSION = "v1.4.0";
public static final String VERSION = "v2.0.1";
public static final String SNAPSHOT_VERSION = VERSION + VERSION_SUFFIX;
/**
* IS_FORMAL_VERSION: Do not modify the line number of this line. If you want to modify it, be sure to change
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Tencent is pleased to support the open source community by making tRPC available.
*
* Copyright (C) 2023 THL A29 Limited, a Tencent company.
* Copyright (C) 2023 THL A29 Limited, a Tencent company.
* All rights reserved.
*
* If you have downloaded a copy of the tRPC source code from Tencent,
Expand All @@ -23,6 +23,7 @@
import com.tencent.trpc.core.logger.LoggerFactory;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Type;

/**
* JSON utility.
Expand Down Expand Up @@ -71,6 +72,26 @@ public static <T> T fromInputStream(InputStream is, Class<T> clz) {
}
}

/**
* json to Type
*
* @param is JSON input stream
* @param type the class of the Type to deserialize
* @param <T> the type of the deserialized object
* @return the deserialized object
*/
public static <T> T fromInputStream(InputStream is, Type type) {
try {
return objectMapper
.readValue(is, objectMapper.getTypeFactory().constructType(type));
} catch (Exception e) {
logger.error("object mapper readValue error:", e);
throw TRpcException.newException(ErrorCode.JSON_DESERIALIZATION_ERR, 0,
"object mapper readValue to Type error, jsonStream:%s, type:%s",
is, type.getTypeName());
}
}

/**
* JSON to Object.
*
Expand Down Expand Up @@ -126,6 +147,26 @@ public static <T> T fromJson(String json, TypeReference<T> typeReference) {
}
}

/**
* json to Type
*
* @param json JSON string
* @param type the type reference of the object to deserialize
* @param <T> the type of the deserialized object
* @return the deserialized object
*/
public static <T> T fromJson(String json, Type type) {
try {
return objectMapper
.readValue(json, objectMapper.getTypeFactory().constructType(type));
} catch (Exception e) {
logger.error("object mapper readValue error:", e);
throw TRpcException.newException(ErrorCode.JSON_DESERIALIZATION_ERR, 0,
"object mapper readValue to Type error, json:%s, type:%s", json,
type.getTypeName());
}
}

/**
* Byte arrays to Object.
*
Expand Down
2 changes: 1 addition & 1 deletion trpc-demo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.tencent.trpc</groupId>
<artifactId>trpc-parent</artifactId>
<version>1.4.0-SNAPSHOT</version>
<version>2.0.1-SNAPSHOT</version>
</parent>

<artifactId>trpc-demo</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions trpc-demo/trpc-java-demo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.tencent.trpc</groupId>
<artifactId>trpc-demo</artifactId>
<version>1.4.0-SNAPSHOT</version>
<version>2.0.1-SNAPSHOT</version>
</parent>
<name>trpc-demo</name>
<description>Demo project for Spring Boot</description>
Expand Down Expand Up @@ -49,7 +49,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.6</version>
<version>0.8.8</version>
<configuration>
<skip>true</skip>
</configuration>
Expand Down
3 changes: 2 additions & 1 deletion trpc-demo/trpc-spring-demo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
<modules>
<module>trpc-spring-server-demo</module>
<module>trpc-spring-client-demo</module>
<module>trpc-spring-demo-api</module>
</modules>
<packaging>pom</packaging>

<parent>
<groupId>com.tencent.trpc</groupId>
<artifactId>trpc-demo</artifactId>
<version>1.4.0-SNAPSHOT</version>
<version>2.0.1-SNAPSHOT</version>
</parent>

<name>trpc-spring-demo Maven Webapp</name>
Expand Down
7 changes: 6 additions & 1 deletion trpc-demo/trpc-spring-demo/trpc-spring-client-demo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>trpc-spring-demo</artifactId>
<groupId>com.tencent.trpc</groupId>
<version>1.4.0-SNAPSHOT</version>
<version>2.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -17,6 +17,11 @@
<groupId>com.tencent.trpc</groupId>
<artifactId>trpc-proto-http</artifactId>
</dependency>
<dependency>
<groupId>com.tencent.trpc</groupId>
<artifactId>trpc-spring-demo-api</artifactId>
<version>${parent.version}</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Tencent is pleased to support the open source community by making tRPC available.
*
* Copyright (C) 2023 THL A29 Limited, a Tencent company.
* Copyright (C) 2023 THL A29 Limited, a Tencent company.
* All rights reserved.
*
* If you have downloaded a copy of the tRPC source code from Tencent,
Expand All @@ -12,6 +12,8 @@
package com.tencent.trpc.spring.demo;

import com.google.protobuf.Message;
import com.tencent.trpc.GreeterService3API;
import com.tencent.trpc.GreeterService3API.RequestParameterizedBean;
import com.tencent.trpc.core.rpc.RpcClientContext;
import com.tencent.trpc.core.rpc.RpcContext;
import com.tencent.trpc.demo.proto.GreeterService2AsyncAPI;
Expand Down Expand Up @@ -39,20 +41,26 @@ public static void main(String[] args) throws Exception {
GreeterService2AsyncAPI service2 = context.getBean(ProxyService.SERVICE_NAME2,
GreeterService2AsyncAPI.class);

GreeterService3API service3 = context.getBean(ProxyService.SERVICE_NAME3,
GreeterService3API.class);

RpcContext ctx = new RpcClientContext();
HelloRequestProtocol.HelloRequest request = HelloRequestProtocol.HelloRequest.newBuilder()
.setMessage("tRPC-Java")
.build();
RequestParameterizedBean<String> parameterizedBean = RequestParameterizedBean.of("message",
"hello parameterizedBean");

int times = 5;

for (int i = 0; i < times; i++) {
System.out.println("service1>>>>" + syncGetMessage(service1.sayHello(ctx, request)));
System.out.println("service2>>>>" + syncGetMessage(service2.sayHi(ctx, request)));
System.out.println("demo service1>>>>" +
syncGetMessage(demoService.getGreeterService().sayHello(ctx, request)));
System.out.println("demo service2>>>>" +
syncGetMessage(demoService.getGreeterService2().sayHi(ctx, request)));
System.out.println("service3>>>>" + service3.sayHelloParameterized(ctx, parameterizedBean));
System.out.println("demo service1>>>>"
+ syncGetMessage(demoService.getGreeterService().sayHello(ctx, request)));
System.out.println("demo service2>>>>"
+ syncGetMessage(demoService.getGreeterService2().sayHi(ctx, request)));
TimeUnit.SECONDS.sleep(1);
}

Expand Down
Loading
Loading