You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by li...@apache.org on 2021/07/15 08:20:16 UTC
[dubbo-samples] branch master updated: refactor protobuf sample as
quick start demo
This is an automated email from the ASF dual-hosted git repository.
liujun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-samples.git
The following commit(s) were added to refs/heads/master by this push:
new 417d88a refactor protobuf sample as quick start demo
new b6d089f Merge remote-tracking branch 'origin/master'
417d88a is described below
commit 417d88ae89455bd07938321c53bbe81b9bf8aa62
Author: ken.lj <ke...@gmail.com>
AuthorDate: Thu Jul 15 16:15:16 2021 +0800
refactor protobuf sample as quick start demo
---
dubbo-samples-protobuf/pom.xml | 3 +-
dubbo-samples-protobuf/protobuf-consumer/pom.xml | 39 ++++++++++++++++++++++
.../dubbo/demo/consumer/ConsumerApplication.java | 4 +--
.../src/main/proto/DemoService.proto | 13 --------
.../src/main/resources/spring/dubbo-consumer.xml | 2 +-
dubbo-samples-protobuf/protobuf-provider/pom.xml | 39 ++++++++++++++++++++++
.../dubbo/demo/provider/DemoServiceImpl.java | 4 +--
.../src/main/proto/DemoService.proto | 13 --------
.../src/main/resources/spring/dubbo-provider.xml | 2 +-
.../org/apache/dubbo/samples/DubboProtobufIT.java | 5 ++-
.../src/test/resources/spring/dubbo-consumer.xml | 2 +-
11 files changed, 88 insertions(+), 38 deletions(-)
diff --git a/dubbo-samples-protobuf/pom.xml b/dubbo-samples-protobuf/pom.xml
index 6d388ee..2a388b2 100644
--- a/dubbo-samples-protobuf/pom.xml
+++ b/dubbo-samples-protobuf/pom.xml
@@ -110,7 +110,6 @@
<target>${target.level}</target>
</configuration>
</plugin>
-
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
@@ -125,7 +124,7 @@
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-compiler</artifactId>
<version>${dubbo.compiler.version}</version>
- <mainClass>org.apache.dubbo.gen.dubbo.DubboGenerator</mainClass>
+ <mainClass>org.apache.dubbo.gen.dubbo.Dubbo3Generator</mainClass>
</protocPlugin>
</protocPlugins>
</configuration>
diff --git a/dubbo-samples-protobuf/protobuf-consumer/pom.xml b/dubbo-samples-protobuf/protobuf-consumer/pom.xml
index d10d97e..2f69492 100644
--- a/dubbo-samples-protobuf/protobuf-consumer/pom.xml
+++ b/dubbo-samples-protobuf/protobuf-consumer/pom.xml
@@ -47,4 +47,43 @@
<type>pom</type>
</dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>3.2.0</version>
+ <executions>
+ <execution>
+ <id>copy-dependencies</id>
+ <phase>prepare-package</phase>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>
+ ${project.build.directory}/lib
+ </outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <!-- Build an executable JAR -->
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>3.1.0</version>
+ <configuration>
+ <archive>
+ <manifest>
+ <addClasspath>true</addClasspath>
+ <classpathPrefix>lib/</classpathPrefix>
+ <mainClass>org.apache.dubbo.demo.consumer.ConsumerApplication</mainClass>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
diff --git a/dubbo-samples-protobuf/protobuf-consumer/src/main/java/org/apache/dubbo/demo/consumer/ConsumerApplication.java b/dubbo-samples-protobuf/protobuf-consumer/src/main/java/org/apache/dubbo/demo/consumer/ConsumerApplication.java
index c3bb6e3..22223d7 100644
--- a/dubbo-samples-protobuf/protobuf-consumer/src/main/java/org/apache/dubbo/demo/consumer/ConsumerApplication.java
+++ b/dubbo-samples-protobuf/protobuf-consumer/src/main/java/org/apache/dubbo/demo/consumer/ConsumerApplication.java
@@ -16,7 +16,7 @@
*/
package org.apache.dubbo.demo.consumer;
-import org.apache.dubbo.demo.DemoServiceDubbo.IDemoService;
+import org.apache.dubbo.demo.DemoService;
import org.apache.dubbo.demo.HelloReply;
import org.apache.dubbo.demo.HelloRequest;
@@ -26,7 +26,7 @@ public class ConsumerApplication {
public static void main(String[] args) throws Exception {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/dubbo-consumer.xml");
context.start();
- IDemoService demoService = context.getBean("demoService", IDemoService.class);
+ DemoService demoService = context.getBean("demoService", DemoService.class);
HelloRequest request = HelloRequest.newBuilder().setName("Hello").build();
HelloReply reply = demoService.sayHello(request);
System.out.println("result: " + reply.getMessage());
diff --git a/dubbo-samples-protobuf/protobuf-consumer/src/main/proto/DemoService.proto b/dubbo-samples-protobuf/protobuf-consumer/src/main/proto/DemoService.proto
index 1429e06..c55a5ca 100644
--- a/dubbo-samples-protobuf/protobuf-consumer/src/main/proto/DemoService.proto
+++ b/dubbo-samples-protobuf/protobuf-consumer/src/main/proto/DemoService.proto
@@ -1,16 +1,3 @@
-// Copyright 2015 The gRPC Authors
-//
-// 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.
syntax = "proto3";
option java_multiple_files = true;
diff --git a/dubbo-samples-protobuf/protobuf-consumer/src/main/resources/spring/dubbo-consumer.xml b/dubbo-samples-protobuf/protobuf-consumer/src/main/resources/spring/dubbo-consumer.xml
index 4fad785..be867b0 100644
--- a/dubbo-samples-protobuf/protobuf-consumer/src/main/resources/spring/dubbo-consumer.xml
+++ b/dubbo-samples-protobuf/protobuf-consumer/src/main/resources/spring/dubbo-consumer.xml
@@ -25,6 +25,6 @@
<dubbo:registry address="zookeeper://${zookeeper.address:127.0.0.1}:2181"/>
- <dubbo:reference id="demoService" check="false" interface="org.apache.dubbo.demo.DemoServiceDubbo$IDemoService"/>
+ <dubbo:reference id="demoService" check="false" interface="org.apache.dubbo.demo.DemoService"/>
</beans>
diff --git a/dubbo-samples-protobuf/protobuf-provider/pom.xml b/dubbo-samples-protobuf/protobuf-provider/pom.xml
index 63f82e4..ba8fae3 100644
--- a/dubbo-samples-protobuf/protobuf-provider/pom.xml
+++ b/dubbo-samples-protobuf/protobuf-provider/pom.xml
@@ -61,4 +61,43 @@
<scope>test</scope>
</dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>3.2.0</version>
+ <executions>
+ <execution>
+ <id>copy-dependencies</id>
+ <phase>prepare-package</phase>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>
+ ${project.build.directory}/lib
+ </outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <!-- Build an executable JAR -->
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>3.1.0</version>
+ <configuration>
+ <archive>
+ <manifest>
+ <addClasspath>true</addClasspath>
+ <classpathPrefix>lib/</classpathPrefix>
+ <mainClass>org.apache.dubbo.demo.provider.Application</mainClass>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
diff --git a/dubbo-samples-protobuf/protobuf-provider/src/main/java/org/apache/dubbo/demo/provider/DemoServiceImpl.java b/dubbo-samples-protobuf/protobuf-provider/src/main/java/org/apache/dubbo/demo/provider/DemoServiceImpl.java
index 2af506a..5dd5b7e 100644
--- a/dubbo-samples-protobuf/protobuf-provider/src/main/java/org/apache/dubbo/demo/provider/DemoServiceImpl.java
+++ b/dubbo-samples-protobuf/protobuf-provider/src/main/java/org/apache/dubbo/demo/provider/DemoServiceImpl.java
@@ -16,7 +16,7 @@
*/
package org.apache.dubbo.demo.provider;
-import org.apache.dubbo.demo.DemoServiceDubbo;
+import org.apache.dubbo.demo.DemoService;
import org.apache.dubbo.demo.HelloReply;
import org.apache.dubbo.demo.HelloRequest;
import org.apache.dubbo.rpc.RpcContext;
@@ -26,7 +26,7 @@ import org.slf4j.LoggerFactory;
import java.util.concurrent.CompletableFuture;
-public class DemoServiceImpl implements DemoServiceDubbo.IDemoService {
+public class DemoServiceImpl implements DemoService {
private static final Logger logger = LoggerFactory.getLogger(DemoServiceImpl.class);
@Override
diff --git a/dubbo-samples-protobuf/protobuf-provider/src/main/proto/DemoService.proto b/dubbo-samples-protobuf/protobuf-provider/src/main/proto/DemoService.proto
index 1429e06..c55a5ca 100644
--- a/dubbo-samples-protobuf/protobuf-provider/src/main/proto/DemoService.proto
+++ b/dubbo-samples-protobuf/protobuf-provider/src/main/proto/DemoService.proto
@@ -1,16 +1,3 @@
-// Copyright 2015 The gRPC Authors
-//
-// 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.
syntax = "proto3";
option java_multiple_files = true;
diff --git a/dubbo-samples-protobuf/protobuf-provider/src/main/resources/spring/dubbo-provider.xml b/dubbo-samples-protobuf/protobuf-provider/src/main/resources/spring/dubbo-provider.xml
index f61dc95..229cbde 100644
--- a/dubbo-samples-protobuf/protobuf-provider/src/main/resources/spring/dubbo-provider.xml
+++ b/dubbo-samples-protobuf/protobuf-provider/src/main/resources/spring/dubbo-provider.xml
@@ -29,7 +29,7 @@
<bean id="demoServiceImpl" class="org.apache.dubbo.demo.provider.DemoServiceImpl"/>
- <dubbo:service serialization="protobuf" interface="org.apache.dubbo.demo.DemoServiceDubbo$IDemoService"
+ <dubbo:service serialization="protobuf" interface="org.apache.dubbo.demo.DemoService"
ref="demoServiceImpl"/>
</beans>
diff --git a/dubbo-samples-protobuf/protobuf-provider/src/test/java/org/apache/dubbo/samples/DubboProtobufIT.java b/dubbo-samples-protobuf/protobuf-provider/src/test/java/org/apache/dubbo/samples/DubboProtobufIT.java
index 700dcec..5d5ed26 100644
--- a/dubbo-samples-protobuf/protobuf-provider/src/test/java/org/apache/dubbo/samples/DubboProtobufIT.java
+++ b/dubbo-samples-protobuf/protobuf-provider/src/test/java/org/apache/dubbo/samples/DubboProtobufIT.java
@@ -17,12 +17,11 @@
package org.apache.dubbo.samples;
-import org.apache.dubbo.demo.DemoServiceDubbo;
+import org.apache.dubbo.demo.DemoService;
import org.apache.dubbo.demo.HelloReply;
import org.apache.dubbo.demo.HelloRequest;
import org.junit.Assert;
-import org.junit.ClassRule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
@@ -36,7 +35,7 @@ public class DubboProtobufIT {
@Autowired
@Qualifier("demoService")
- private DemoServiceDubbo.IDemoService demoService;
+ private DemoService demoService;
@Test
public void testGreeting() throws Exception {
diff --git a/dubbo-samples-protobuf/protobuf-provider/src/test/resources/spring/dubbo-consumer.xml b/dubbo-samples-protobuf/protobuf-provider/src/test/resources/spring/dubbo-consumer.xml
index d4c6745..3504272 100644
--- a/dubbo-samples-protobuf/protobuf-provider/src/test/resources/spring/dubbo-consumer.xml
+++ b/dubbo-samples-protobuf/protobuf-provider/src/test/resources/spring/dubbo-consumer.xml
@@ -25,6 +25,6 @@
<dubbo:registry address="zookeeper://${zookeeper.address:127.0.0.1}:2181"/>
- <dubbo:reference scope="remote" id="demoService" check="false" interface="org.apache.dubbo.demo.DemoServiceDubbo$IDemoService"/>
+ <dubbo:reference scope="remote" id="demoService" check="false" interface="org.apache.dubbo.demo.DemoService"/>
</beans>
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org