From c8865ba00c45f1fd78dd1a1609c4b8136610cac6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=9A=E4=B9=8B?= Date: Mon, 6 Nov 2023 12:48:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9Edubbo2=E7=9A=84samples?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rpc/dubbo26/dubbo26base/pom.xml | 16 ++- ...ation.java => Dubbo26BaseApplication.java} | 8 +- .../dubbo26/base/service/BaseDemoService.java | 24 +++++ .../src/main/resources/log4j2-spring.xml | 102 ++++++++++++++++++ .../src/main/resources/provider.xml | 18 ++++ .../dubbo26/biz/controller/BizController.java | 11 ++ .../src/main/resources/provider.xml | 1 + .../src/main/resources/log4j2-spring.xml | 8 +- samples/dubbo-samples/rpc/dubbo3/pom.xml | 2 +- .../rpc/dubbo3/triplebiz/pom.xml | 1 - 10 files changed, 181 insertions(+), 10 deletions(-) rename samples/dubbo-samples/rpc/dubbo26/dubbo26base/src/main/java/com/alipay/sofa/rpc/dubbo26/base/{BaseApplication.java => Dubbo26BaseApplication.java} (85%) create mode 100644 samples/dubbo-samples/rpc/dubbo26/dubbo26base/src/main/java/com/alipay/sofa/rpc/dubbo26/base/service/BaseDemoService.java create mode 100644 samples/dubbo-samples/rpc/dubbo26/dubbo26base/src/main/resources/log4j2-spring.xml create mode 100644 samples/dubbo-samples/rpc/dubbo26/dubbo26base/src/main/resources/provider.xml diff --git a/samples/dubbo-samples/rpc/dubbo26/dubbo26base/pom.xml b/samples/dubbo-samples/rpc/dubbo26/dubbo26base/pom.xml index 261a3c84a..3682fda15 100644 --- a/samples/dubbo-samples/rpc/dubbo26/dubbo26base/pom.xml +++ b/samples/dubbo-samples/rpc/dubbo26/dubbo26base/pom.xml @@ -20,6 +20,20 @@ org.springframework.boot spring-boot-starter-test test + + + logback-classic + ch.qos.logback + + + ch.qos.logback + logback-core + + + log4j-to-slf4j + org.apache.logging.log4j + + @@ -99,7 +113,7 @@ spring-boot-maven-plugin ${spring.boot.version} - com.alipay.sofa.rpc.dubbo26.base.BaseApplication + com.alipay.sofa.rpc.dubbo26.base.Dubbo26BaseApplication true diff --git a/samples/dubbo-samples/rpc/dubbo26/dubbo26base/src/main/java/com/alipay/sofa/rpc/dubbo26/base/BaseApplication.java b/samples/dubbo-samples/rpc/dubbo26/dubbo26base/src/main/java/com/alipay/sofa/rpc/dubbo26/base/Dubbo26BaseApplication.java similarity index 85% rename from samples/dubbo-samples/rpc/dubbo26/dubbo26base/src/main/java/com/alipay/sofa/rpc/dubbo26/base/BaseApplication.java rename to samples/dubbo-samples/rpc/dubbo26/dubbo26base/src/main/java/com/alipay/sofa/rpc/dubbo26/base/Dubbo26BaseApplication.java index 40aee9e3c..bbdcac0c2 100644 --- a/samples/dubbo-samples/rpc/dubbo26/dubbo26base/src/main/java/com/alipay/sofa/rpc/dubbo26/base/BaseApplication.java +++ b/samples/dubbo-samples/rpc/dubbo26/dubbo26base/src/main/java/com/alipay/sofa/rpc/dubbo26/base/Dubbo26BaseApplication.java @@ -13,6 +13,7 @@ import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ImportResource; /** * @@ -21,8 +22,9 @@ */ @SpringBootApplication -public class BaseApplication implements CommandLineRunner { - private static Logger LOGGER = LoggerFactory.getLogger(BaseApplication.class); +@ImportResource("classpath:provider.xml") +public class Dubbo26BaseApplication implements CommandLineRunner { + private static Logger LOGGER = LoggerFactory.getLogger(Dubbo26BaseApplication.class); public static void main(String[] args) { @@ -34,7 +36,7 @@ public static void main(String[] args) { System.setProperty("sofa.ark.embed.enable", "true"); System.setProperty("sofa.ark.plugin.export.class.enable", "true"); - SpringApplication.run(BaseApplication.class, args); + SpringApplication.run(Dubbo26BaseApplication.class, args); } /** diff --git a/samples/dubbo-samples/rpc/dubbo26/dubbo26base/src/main/java/com/alipay/sofa/rpc/dubbo26/base/service/BaseDemoService.java b/samples/dubbo-samples/rpc/dubbo26/dubbo26base/src/main/java/com/alipay/sofa/rpc/dubbo26/base/service/BaseDemoService.java new file mode 100644 index 000000000..cb2a5f1cc --- /dev/null +++ b/samples/dubbo-samples/rpc/dubbo26/dubbo26base/src/main/java/com/alipay/sofa/rpc/dubbo26/base/service/BaseDemoService.java @@ -0,0 +1,24 @@ +/* + * Ant Group + * Copyright (c) 2004-2023 All Rights Reserved. + */ +package com.alipay.sofa.rpc.dubbo26.base.service; + +import com.alipay.sofa.rpc.dubbo26.model.DemoRequest; +import com.alipay.sofa.rpc.dubbo26.model.DemoResponse; +import com.alipay.sofa.rpc.dubbo26.model.DemoService; + +/** + * + * @author syd + * @version BaseDemoService.java, v 0.1 2023年11月06日 12:21 syd + */ +public class BaseDemoService implements DemoService { + + @Override + public DemoResponse handle(DemoRequest demoRequest) { + DemoResponse response = new DemoResponse(); + response.setResult(demoRequest.getBiz() + "->" + getClass().getName()); + return response; + } +} \ No newline at end of file diff --git a/samples/dubbo-samples/rpc/dubbo26/dubbo26base/src/main/resources/log4j2-spring.xml b/samples/dubbo-samples/rpc/dubbo26/dubbo26base/src/main/resources/log4j2-spring.xml new file mode 100644 index 000000000..4ceab3d84 --- /dev/null +++ b/samples/dubbo-samples/rpc/dubbo26/dubbo26base/src/main/resources/log4j2-spring.xml @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/dubbo-samples/rpc/dubbo26/dubbo26base/src/main/resources/provider.xml b/samples/dubbo-samples/rpc/dubbo26/dubbo26base/src/main/resources/provider.xml new file mode 100644 index 000000000..440779af6 --- /dev/null +++ b/samples/dubbo-samples/rpc/dubbo26/dubbo26base/src/main/resources/provider.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/dubbo-samples/rpc/dubbo26/dubbo26biz/src/main/java/com/alipay/sofa/rpc/dubbo26/biz/controller/BizController.java b/samples/dubbo-samples/rpc/dubbo26/dubbo26biz/src/main/java/com/alipay/sofa/rpc/dubbo26/biz/controller/BizController.java index 2f5a19ddc..ca8907ae4 100644 --- a/samples/dubbo-samples/rpc/dubbo26/dubbo26biz/src/main/java/com/alipay/sofa/rpc/dubbo26/biz/controller/BizController.java +++ b/samples/dubbo-samples/rpc/dubbo26/dubbo26biz/src/main/java/com/alipay/sofa/rpc/dubbo26/biz/controller/BizController.java @@ -37,6 +37,8 @@ public class BizController { @Resource private HelloService helloServiceRef; + @Resource + private DemoService baseDemoServiceRef; @Autowired private ApplicationContext applicationContext; @@ -62,6 +64,15 @@ public HelloResponse hello(String name) { return helloServiceRef.sayHello(helloRequest); } + @RequestMapping(value = "/base", method = RequestMethod.GET) + @ResponseBody + public DemoResponse base(String ref) { + String appName = applicationContext.getId(); + DemoRequest demoRequest = new DemoRequest(); + demoRequest.setBiz(appName); + return baseDemoServiceRef.handle(demoRequest); + } + public void setDemoServiceRef(DemoService demoServiceRef) { this.demoServiceRef = demoServiceRef; } diff --git a/samples/dubbo-samples/rpc/dubbo26/dubbo26biz/src/main/resources/provider.xml b/samples/dubbo-samples/rpc/dubbo26/dubbo26biz/src/main/resources/provider.xml index 5784d211d..f6853f3ba 100644 --- a/samples/dubbo-samples/rpc/dubbo26/dubbo26biz/src/main/resources/provider.xml +++ b/samples/dubbo-samples/rpc/dubbo26/dubbo26biz/src/main/resources/provider.xml @@ -25,4 +25,5 @@ + \ No newline at end of file diff --git a/samples/dubbo-samples/rpc/dubbo3/dubbo3base/src/main/resources/log4j2-spring.xml b/samples/dubbo-samples/rpc/dubbo3/dubbo3base/src/main/resources/log4j2-spring.xml index 184475ebd..1359dd4ce 100644 --- a/samples/dubbo-samples/rpc/dubbo3/dubbo3base/src/main/resources/log4j2-spring.xml +++ b/samples/dubbo-samples/rpc/dubbo3/dubbo3base/src/main/resources/log4j2-spring.xml @@ -73,11 +73,11 @@ - + - + @@ -85,14 +85,14 @@ + level="${ctx:logging.level.com.alipay.sofa.rpc.dubbo3}"> - + diff --git a/samples/dubbo-samples/rpc/dubbo3/pom.xml b/samples/dubbo-samples/rpc/dubbo3/pom.xml index 10dd53df1..4c65df83b 100644 --- a/samples/dubbo-samples/rpc/dubbo3/pom.xml +++ b/samples/dubbo-samples/rpc/dubbo3/pom.xml @@ -23,7 +23,7 @@ 2.6.4 2.7.16 2.2.4-SNAPSHOT - 0.5.0 + 0.5.1 3.4.2 3.8.1 3.1.11 diff --git a/samples/dubbo-samples/rpc/dubbo3/triplebiz/pom.xml b/samples/dubbo-samples/rpc/dubbo3/triplebiz/pom.xml index 26e671563..4b845bca1 100644 --- a/samples/dubbo-samples/rpc/dubbo3/triplebiz/pom.xml +++ b/samples/dubbo-samples/rpc/dubbo3/triplebiz/pom.xml @@ -20,7 +20,6 @@ com.alipay.sofa common-model 0.0.1-SNAPSHOT - provided