diff --git a/.github/workflows/build-and-test-pr.yml b/.github/workflows/build-and-test-pr.yml index f9cfd151fdb..5455362ebee 100644 --- a/.github/workflows/build-and-test-pr.yml +++ b/.github/workflows/build-and-test-pr.yml @@ -524,7 +524,7 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} path: dubbo/ - name: "Upload coverage to Codecov" - uses: codecov/codecov-action@v4 + uses: codecov/codecov-action@v3 with: token: ${{ secrets.CODECOV_TOKEN }} version: v0.6.0 @@ -584,7 +584,7 @@ jobs: - uses: actions/checkout@v4 with: path: "./dubbo" - - name: "Setup GraalVM environment" + - name: "Set up GraalVM environment" uses: graalvm/setup-graalvm@v1 with: version: '22.3.0' @@ -592,7 +592,7 @@ jobs: components: 'native-image' github-token: ${{ secrets.GITHUB_TOKEN }} native-image-job-reports: 'true' - - name: "Setup Zookeeper environment" + - name: "Set up Zookeeper environment" run: | wget https://dlcdn.apache.org/zookeeper/zookeeper-3.8.4/apache-zookeeper-3.8.4-bin.tar.gz tar -zxvf apache-zookeeper-3.8.4-bin.tar.gz @@ -604,7 +604,7 @@ jobs: native-image --version - name: "Set current date as env variable" run: echo "TODAY=$(date +'%Y%m%d')" >> $GITHUB_ENV - - name: "Restore local maven repository cache" + - name: "Restore local Maven repository cache" uses: actions/cache/restore@v4 with: path: ~/.m2/repository @@ -616,14 +616,21 @@ jobs: run: | cd ${{ github.workspace }}/dubbo ./mvnw ${{ env.MAVEN_ARGS }} -T 2C clean install -P '!demo',skip-spotless -Dmaven.test.skip=true -Dcheckstyle.skip=true -Dcheckstyle_unix.skip=true -Drat.skip=true - - name: "Compile and run Dubbo demo for native (Linux)" + - name: "Checkout dubbo-samples repository" + uses: actions/checkout@v4 + with: + repository: 'apache/dubbo-samples' + ref: master + path: "./dubbo-samples" + - name: "Compile and run Dubbo native image demo" run: | - cd ${{ github.workspace }}/dubbo/dubbo-demo/dubbo-demo-native/dubbo-demo-native-interface - MVNW="${{ github.workspace }}/dubbo/mvnw ${{ env.MAVEN_ARGS }} -T 2C -Dmaven.test.skip=true" - $MVNW clean install - cd ../dubbo-demo-native-provider - $MVNW clean package -P native native:compile - nohup ./target/dubbo-demo-native-provider & - cd ../dubbo-demo-native-consumer + MVNW="${{ github.workspace }}/dubbo-samples/mvnw ${{ env.MAVEN_ARGS }} -Dmaven.test.skip=true" + cd ${{ github.workspace }}/dubbo-samples/2-advanced/dubbo-samples-native-image/dubbo-samples-native-image-provider $MVNW clean package -P native native:compile - ./target/dubbo-demo-native-consumer + nohup ./target/dubbo-samples-native-image-provider & + sleep 10 + curl \ + --header "Content-Type: application/json" \ + --data '{"name":"Dubbo"}' \ + http://localhost:50052/org.apache.dubbo.nativeimage.DemoService/sayHello/ + diff --git a/.github/workflows/build-and-test-scheduled-3.3.yml b/.github/workflows/build-and-test-scheduled-3.3.yml index 7bf6a993bbf..32aed500718 100644 --- a/.github/workflows/build-and-test-scheduled-3.3.yml +++ b/.github/workflows/build-and-test-scheduled-3.3.yml @@ -463,10 +463,8 @@ jobs: steps: - uses: actions/checkout@v4 with: - ref: "3.3" path: "./dubbo" - - - name: "Setup GraalVM environment" + - name: "Set up GraalVM environment" uses: graalvm/setup-graalvm@v1 with: version: '22.3.0' @@ -474,32 +472,44 @@ jobs: components: 'native-image' github-token: ${{ secrets.GITHUB_TOKEN }} native-image-job-reports: 'true' - - - name: "Setup Zookeeper environment" + - name: "Set up Zookeeper environment" run: | wget https://dlcdn.apache.org/zookeeper/zookeeper-3.8.4/apache-zookeeper-3.8.4-bin.tar.gz tar -zxvf apache-zookeeper-3.8.4-bin.tar.gz mv apache-zookeeper-3.8.4-bin/conf/zoo_sample.cfg apache-zookeeper-3.8.4-bin/conf/zoo.cfg apache-zookeeper-3.8.4-bin/bin/zkServer.sh start - - name: "Check environment" run: | java --version native-image --version - + - name: "Set current date as env variable" + run: echo "TODAY=$(date +'%Y%m%d')" >> $GITHUB_ENV + - name: "Restore local Maven repository cache" + uses: actions/cache/restore@v4 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}-${{ env.TODAY }} + restore-keys: | + ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + ${{ runner.os }}-maven- - name: "Compile Dubbo (Linux)" run: | cd ${{ github.workspace }}/dubbo ./mvnw ${{ env.MAVEN_ARGS }} -T 2C clean install -P '!demo',skip-spotless -Dmaven.test.skip=true -Dcheckstyle.skip=true -Dcheckstyle_unix.skip=true -Drat.skip=true - - - name: "Compile and run Dubbo demo for native (Linux)" + - name: "Checkout dubbo-samples repository" + uses: actions/checkout@v4 + with: + repository: 'apache/dubbo-samples' + ref: master + path: "./dubbo-samples" + - name: "Compile and run Dubbo native image demo" run: | - cd ${{ github.workspace }}/dubbo/dubbo-demo/dubbo-demo-native/dubbo-demo-native-interface - MVNW="${{ github.workspace }}/dubbo/mvnw ${{ env.MAVEN_ARGS }} -T 2C -Dmaven.test.skip=true" - $MVNW clean install - cd ../dubbo-demo-native-provider - $MVNW clean package -P native native:compile - nohup ./target/dubbo-demo-native-provider & - cd ../dubbo-demo-native-consumer + MVNW="${{ github.workspace }}/dubbo-samples/mvnw ${{ env.MAVEN_ARGS }} -Dmaven.test.skip=true" + cd ${{ github.workspace }}/dubbo-samples/2-advanced/dubbo-samples-native-image/dubbo-samples-native-image-provider $MVNW clean package -P native native:compile - ./target/dubbo-demo-native-consumer + nohup ./target/dubbo-samples-native-image-provider & + sleep 10 + curl \ + --header "Content-Type: application/json" \ + --data '{"name":"Dubbo"}' \ + http://localhost:50052/org.apache.dubbo.nativeimage.DemoService/sayHello/ diff --git a/.github/workflows/release-test.yml b/.github/workflows/release-test.yml index 17c4b46b98f..0b8f55e5290 100644 --- a/.github/workflows/release-test.yml +++ b/.github/workflows/release-test.yml @@ -460,8 +460,7 @@ jobs: - uses: actions/checkout@v4 with: path: "./dubbo" - - - name: "Setup GraalVM environment" + - name: "Set up GraalVM environment" uses: graalvm/setup-graalvm@v1 with: version: '22.3.0' @@ -469,32 +468,44 @@ jobs: components: 'native-image' github-token: ${{ secrets.GITHUB_TOKEN }} native-image-job-reports: 'true' - - - name: "Setup Zookeeper environment" + - name: "Set up Zookeeper environment" run: | wget https://dlcdn.apache.org/zookeeper/zookeeper-3.8.4/apache-zookeeper-3.8.4-bin.tar.gz tar -zxvf apache-zookeeper-3.8.4-bin.tar.gz mv apache-zookeeper-3.8.4-bin/conf/zoo_sample.cfg apache-zookeeper-3.8.4-bin/conf/zoo.cfg apache-zookeeper-3.8.4-bin/bin/zkServer.sh start - - name: "Check environment" run: | java --version native-image --version - + - name: "Set current date as env variable" + run: echo "TODAY=$(date +'%Y%m%d')" >> $GITHUB_ENV + - name: "Restore local Maven repository cache" + uses: actions/cache/restore@v4 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}-${{ env.TODAY }} + restore-keys: | + ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + ${{ runner.os }}-maven- - name: "Compile Dubbo (Linux)" run: | cd ${{ github.workspace }}/dubbo ./mvnw ${{ env.MAVEN_ARGS }} -T 2C clean install -P '!demo',skip-spotless -Dmaven.test.skip=true -Dcheckstyle.skip=true -Dcheckstyle_unix.skip=true -Drat.skip=true - - - name: "Compile and run Dubbo demo for native (Linux)" + - name: "Checkout dubbo-samples repository" + uses: actions/checkout@v4 + with: + repository: 'apache/dubbo-samples' + ref: master + path: "./dubbo-samples" + - name: "Compile and run Dubbo native image demo" run: | - cd ${{ github.workspace }}/dubbo/dubbo-demo/dubbo-demo-native/dubbo-demo-native-interface - MVNW="${{ github.workspace }}/dubbo/mvnw ${{ env.MAVEN_ARGS }} -T 2C -Dmaven.test.skip=true" - $MVNW clean install - cd ../dubbo-demo-native-provider - $MVNW clean package -P native native:compile - nohup ./target/dubbo-demo-native-provider & - cd ../dubbo-demo-native-consumer + MVNW="${{ github.workspace }}/dubbo-samples/mvnw ${{ env.MAVEN_ARGS }} -Dmaven.test.skip=true" + cd ${{ github.workspace }}/dubbo-samples/2-advanced/dubbo-samples-native-image/dubbo-samples-native-image-provider $MVNW clean package -P native native:compile - ./target/dubbo-demo-native-consumer + nohup ./target/dubbo-samples-native-image-provider & + sleep 10 + curl \ + --header "Content-Type: application/json" \ + --data '{"name":"Dubbo"}' \ + http://localhost:50052/org.apache.dubbo.nativeimage.DemoService/sayHello/ diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/extension/AdaptiveClassCodeGenerator.java b/dubbo-common/src/main/java/org/apache/dubbo/common/extension/AdaptiveClassCodeGenerator.java index fd51fa15cc5..75977379de3 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/common/extension/AdaptiveClassCodeGenerator.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/extension/AdaptiveClassCodeGenerator.java @@ -224,37 +224,36 @@ private String generateUrlNullCheck(int index) { */ private String generateMethodContent(Method method) { Adaptive adaptiveAnnotation = method.getAnnotation(Adaptive.class); - StringBuilder code = new StringBuilder(512); if (adaptiveAnnotation == null) { return generateUnsupported(method); - } else { - int urlTypeIndex = getUrlTypeIndex(method); + } + StringBuilder code = new StringBuilder(512); + int urlTypeIndex = getUrlTypeIndex(method); - // found parameter in URL type - if (urlTypeIndex != -1) { - // Null Point check - code.append(generateUrlNullCheck(urlTypeIndex)); - } else { - // did not find parameter in URL type - code.append(generateUrlAssignmentIndirectly(method)); - } + // found parameter in URL type + if (urlTypeIndex != -1) { + // Null Point check + code.append(generateUrlNullCheck(urlTypeIndex)); + } else { + // did not find parameter in URL type + code.append(generateUrlAssignmentIndirectly(method)); + } - String[] value = getMethodAdaptiveValue(adaptiveAnnotation); + String[] value = getMethodAdaptiveValue(adaptiveAnnotation); - boolean hasInvocation = hasInvocationArgument(method); + boolean hasInvocation = hasInvocationArgument(method); - code.append(generateInvocationArgumentNullCheck(method)); + code.append(generateInvocationArgumentNullCheck(method)); - code.append(generateExtNameAssignment(value, hasInvocation)); - // check extName == null? - code.append(generateExtNameNullCheck(value)); + code.append(generateExtNameAssignment(value, hasInvocation)); + // check extName == null? + code.append(generateExtNameNullCheck(value)); - code.append(generateScopeModelAssignment()); - code.append(generateExtensionAssignment()); + code.append(generateScopeModelAssignment()); + code.append(generateExtensionAssignment()); - // return statement - code.append(generateReturnAndInvocation(method)); - } + // return statement + code.append(generateReturnAndInvocation(method)); return code.toString(); } diff --git a/dubbo-common/src/test/java/org/apache/dubbo/common/threadpool/support/eager/TaskQueueTest.java b/dubbo-common/src/test/java/org/apache/dubbo/common/threadpool/support/eager/TaskQueueTest.java index a61e59a2184..13575605831 100644 --- a/dubbo-common/src/test/java/org/apache/dubbo/common/threadpool/support/eager/TaskQueueTest.java +++ b/dubbo-common/src/test/java/org/apache/dubbo/common/threadpool/support/eager/TaskQueueTest.java @@ -20,6 +20,7 @@ import java.util.concurrent.TimeUnit; import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.Mockito; @@ -29,6 +30,16 @@ class TaskQueueTest { + private TaskQueue queue; + private EagerThreadPoolExecutor executor; + + @BeforeEach + void setup() { + queue = new TaskQueue(1); + executor = mock(EagerThreadPoolExecutor.class); + queue.setExecutor(executor); + } + @Test void testOffer1() throws Exception { Assertions.assertThrows(RejectedExecutionException.class, () -> { @@ -39,53 +50,38 @@ void testOffer1() throws Exception { @Test void testOffer2() throws Exception { - TaskQueue queue = new TaskQueue(1); - EagerThreadPoolExecutor executor = mock(EagerThreadPoolExecutor.class); Mockito.when(executor.getPoolSize()).thenReturn(2); Mockito.when(executor.getActiveCount()).thenReturn(1); - queue.setExecutor(executor); assertThat(queue.offer(mock(Runnable.class)), is(true)); } @Test void testOffer3() throws Exception { - TaskQueue queue = new TaskQueue(1); - EagerThreadPoolExecutor executor = mock(EagerThreadPoolExecutor.class); Mockito.when(executor.getPoolSize()).thenReturn(2); Mockito.when(executor.getActiveCount()).thenReturn(2); Mockito.when(executor.getMaximumPoolSize()).thenReturn(4); - queue.setExecutor(executor); assertThat(queue.offer(mock(Runnable.class)), is(false)); } @Test void testOffer4() throws Exception { - TaskQueue queue = new TaskQueue(1); - EagerThreadPoolExecutor executor = mock(EagerThreadPoolExecutor.class); Mockito.when(executor.getPoolSize()).thenReturn(4); Mockito.when(executor.getActiveCount()).thenReturn(4); Mockito.when(executor.getMaximumPoolSize()).thenReturn(4); - queue.setExecutor(executor); assertThat(queue.offer(mock(Runnable.class)), is(true)); } @Test void testRetryOffer1() throws Exception { Assertions.assertThrows(RejectedExecutionException.class, () -> { - TaskQueue queue = new TaskQueue(1); - EagerThreadPoolExecutor executor = mock(EagerThreadPoolExecutor.class); Mockito.when(executor.isShutdown()).thenReturn(true); - queue.setExecutor(executor); queue.retryOffer(mock(Runnable.class), 1000, TimeUnit.MILLISECONDS); }); } @Test void testRetryOffer2() throws Exception { - TaskQueue queue = new TaskQueue(1); - EagerThreadPoolExecutor executor = mock(EagerThreadPoolExecutor.class); Mockito.when(executor.isShutdown()).thenReturn(false); - queue.setExecutor(executor); assertThat(queue.retryOffer(mock(Runnable.class), 1000, TimeUnit.MILLISECONDS), is(true)); } } diff --git a/dubbo-common/src/test/java/org/apache/dubbo/common/utils/DubboAppenderTest.java b/dubbo-common/src/test/java/org/apache/dubbo/common/utils/DubboAppenderTest.java index 2607ff877cc..9e68dab2764 100644 --- a/dubbo-common/src/test/java/org/apache/dubbo/common/utils/DubboAppenderTest.java +++ b/dubbo-common/src/test/java/org/apache/dubbo/common/utils/DubboAppenderTest.java @@ -27,8 +27,6 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.is; -import static org.junit.jupiter.api.Assumptions.assumeFalse; -import static org.junit.jupiter.api.Assumptions.assumeTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -42,6 +40,9 @@ public void setUp() throws Exception { when(event.getLevel()).thenReturn(Level.INFO); when(event.getThreadName()).thenReturn("thread-name"); when(event.getMessage()).thenReturn(new SimpleMessage("message")); + + DubboAppender.clear(); + DubboAppender.doStop(); } @AfterEach @@ -52,7 +53,7 @@ public void tearDown() throws Exception { @Test void testAvailable() { - assumeFalse(DubboAppender.available); + assertThat(DubboAppender.available, is(false)); DubboAppender.doStart(); assertThat(DubboAppender.available, is(true)); DubboAppender.doStop(); @@ -62,8 +63,9 @@ void testAvailable() { @Test void testAppend() { DubboAppender appender = new DubboAppender(); + assertThat(DubboAppender.logList, hasSize(0)); appender.append(event); - assumeTrue(DubboAppender.logList.isEmpty()); + assertThat(DubboAppender.logList, hasSize(0)); DubboAppender.doStart(); appender.append(event); assertThat(DubboAppender.logList, hasSize(1)); @@ -75,7 +77,7 @@ void testClear() { DubboAppender.doStart(); DubboAppender appender = new DubboAppender(); appender.append(event); - assumeTrue(1 == DubboAppender.logList.size()); + assertThat(DubboAppender.logList, hasSize(1)); DubboAppender.clear(); assertThat(DubboAppender.logList, hasSize(0)); } diff --git a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java index 363eccd8b5e..33c9a581ab7 100644 --- a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java +++ b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java @@ -395,7 +395,7 @@ protected void exported() { exported = true; List exportedURLs = this.getExportedUrls(); exportedURLs.forEach(url -> { - if (url.getParameters().containsKey(SERVICE_NAME_MAPPING_KEY)) { + if (url.getParameter(SERVICE_NAME_MAPPING_KEY, false)) { ServiceNameMapping serviceNameMapping = ServiceNameMapping.getDefaultExtension(getScopeModel()); ScheduledExecutorService scheduledExecutor = getScopeModel() .getBeanFactory() diff --git a/dubbo-demo/README.md b/dubbo-demo/README.md new file mode 100644 index 00000000000..b406bab414c --- /dev/null +++ b/dubbo-demo/README.md @@ -0,0 +1,13 @@ +# Dubbo Demo + +This directory contains basic Dubbo usages to help Dubbo developers with debugging and smoke test purposes. Check [dubbo-samples](https://github.com/apache/dubbo-samples) repository for more examples that showcase Dubbo's rich features. + +## Brief introduction + +1. **`dubbo-demo-api`** + This demo demonstrates the basic usage of Dubbo's RPC protocol, serving as a fundamental example. It showcases how to define and implement a simple RPC service using Dubbo, how to start a server that serves at a specified port and then a consumer that consumes the service. +2. **`dubbo-demo-springboot`** + This demo illustrates the integration of Dubbo with Spring Boot, showing how Dubbo services can be utilized and configured within a Spring Boot application. It demonstrates how to configure and manage Dubbo services seamlessly through Spring Boot, making it ideal for developers leveraging the popular Spring Boot framework. +3. **`dubbo-demo-springboot-idl`** + This demo focuses on showcasing how to use Dubbo with Spring Boot when IDL (Interface Definition Language) files such as Proto files are available. It illustrates how developers can work with Dubbo services defined through IDL, integrating them into a Spring Boot application. + diff --git a/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-consumer/pom.xml b/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-consumer/pom.xml deleted file mode 100644 index 85b651833c1..00000000000 --- a/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-consumer/pom.xml +++ /dev/null @@ -1,109 +0,0 @@ - - - - 4.0.0 - - org.apache.dubbo - dubbo-demo-annotation - ${revision} - ../pom.xml - - - dubbo-demo-annotation-consumer - - - true - - - - - org.apache.dubbo - dubbo-demo-interface - ${project.version} - - - org.apache.dubbo - dubbo-registry-multicast - ${project.version} - - - org.apache.dubbo - dubbo-registry-zookeeper - ${project.version} - - - org.apache.dubbo - dubbo-registry-nacos - ${project.version} - - - com.alibaba.nacos - nacos-client - - - org.apache.dubbo - dubbo-configcenter-zookeeper - ${project.version} - - - org.apache.dubbo - dubbo-configcenter-nacos - ${project.version} - - - org.apache.dubbo - dubbo-metadata-report-zookeeper - ${project.version} - - - org.apache.dubbo - dubbo-metadata-report-nacos - ${project.version} - - - org.apache.dubbo - dubbo-rpc-dubbo - ${project.version} - - - org.apache.dubbo - dubbo-config-spring - ${project.version} - - - org.apache.dubbo - dubbo-remoting-netty4 - ${project.version} - - - org.apache.dubbo - dubbo-serialization-hessian2 - ${project.version} - - - org.apache.dubbo - dubbo-serialization-fastjson2 - ${project.version} - - - org.apache.logging.log4j - log4j-slf4j-impl - - - - diff --git a/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-consumer/src/main/java/org/apache/dubbo/demo/consumer/Application.java b/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-consumer/src/main/java/org/apache/dubbo/demo/consumer/Application.java deleted file mode 100644 index 8f6d2e9c7dc..00000000000 --- a/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-consumer/src/main/java/org/apache/dubbo/demo/consumer/Application.java +++ /dev/null @@ -1,47 +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.demo.consumer; - -import org.apache.dubbo.config.spring.context.annotation.EnableDubbo; -import org.apache.dubbo.demo.DemoService; -import org.apache.dubbo.demo.consumer.comp.DemoServiceComponent; - -import org.springframework.context.annotation.AnnotationConfigApplicationContext; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; - -public class Application { - /** - * In order to make sure multicast registry works, need to specify '-Djava.net.preferIPv4Stack=true' before - * launch the application - */ - public static void main(String[] args) { - AnnotationConfigApplicationContext context = - new AnnotationConfigApplicationContext(ConsumerConfiguration.class); - context.start(); - DemoService service = context.getBean("demoServiceComponent", DemoServiceComponent.class); - String hello = service.sayHello("world"); - System.out.println("result :" + hello); - } - - @Configuration - @EnableDubbo(scanBasePackages = "org.apache.dubbo.demo.consumer.comp") - @PropertySource("classpath:/spring/dubbo-consumer.properties") - @ComponentScan(value = {"org.apache.dubbo.demo.consumer.comp"}) - static class ConsumerConfiguration {} -} diff --git a/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-consumer/src/main/java/org/apache/dubbo/demo/consumer/comp/DemoServiceComponent.java b/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-consumer/src/main/java/org/apache/dubbo/demo/consumer/comp/DemoServiceComponent.java deleted file mode 100644 index 93d1eca356e..00000000000 --- a/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-consumer/src/main/java/org/apache/dubbo/demo/consumer/comp/DemoServiceComponent.java +++ /dev/null @@ -1,40 +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.demo.consumer.comp; - -import org.apache.dubbo.config.annotation.DubboReference; -import org.apache.dubbo.demo.DemoService; - -import java.util.concurrent.CompletableFuture; - -import org.springframework.stereotype.Component; - -@Component("demoServiceComponent") -public class DemoServiceComponent implements DemoService { - @DubboReference - private DemoService demoService; - - @Override - public String sayHello(String name) { - return demoService.sayHello(name); - } - - @Override - public CompletableFuture sayHelloAsync(String name) { - return null; - } -} diff --git a/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-consumer/src/main/resources/log4j2.xml b/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-consumer/src/main/resources/log4j2.xml deleted file mode 100644 index 69e1321d220..00000000000 --- a/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-consumer/src/main/resources/log4j2.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - diff --git a/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-consumer/src/main/resources/spring/dubbo-consumer.properties b/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-consumer/src/main/resources/spring/dubbo-consumer.properties deleted file mode 100644 index 151fc038a07..00000000000 --- a/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-consumer/src/main/resources/spring/dubbo-consumer.properties +++ /dev/null @@ -1,22 +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. -# - -dubbo.application.name=dubbo-demo-annotation-consumer -dubbo.registry.address=zookeeper://127.0.0.1:2181 -dubbo.protocol.port=-1 diff --git a/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-provider/pom.xml b/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-provider/pom.xml deleted file mode 100644 index 720724073b0..00000000000 --- a/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-provider/pom.xml +++ /dev/null @@ -1,111 +0,0 @@ - - - - 4.0.0 - - org.apache.dubbo - dubbo-demo-annotation - ${revision} - ../pom.xml - - - dubbo-demo-annotation-provider - - - true - - - - - org.apache.dubbo - dubbo-demo-interface - ${project.parent.version} - - - org.apache.dubbo - dubbo-registry-multicast - ${project.version} - - - org.apache.dubbo - dubbo-registry-nacos - ${project.version} - - - com.alibaba.nacos - nacos-client - - - org.apache.dubbo - dubbo-registry-zookeeper - ${project.version} - - - org.apache.dubbo - dubbo-configcenter-zookeeper - ${project.version} - - - org.apache.dubbo - dubbo-configcenter-nacos - ${project.version} - - - org.apache.dubbo - dubbo-metadata-report-zookeeper - ${project.version} - - - org.apache.dubbo - dubbo-metadata-report-nacos - ${project.version} - - - org.apache.dubbo - dubbo-rpc-dubbo - ${project.version} - - - org.apache.dubbo - dubbo-config-spring - ${project.version} - - - org.apache.dubbo - dubbo-remoting-netty4 - ${project.version} - - - org.apache.dubbo - dubbo-serialization-hessian2 - ${project.version} - - - org.apache.dubbo - dubbo-serialization-fastjson2 - ${project.version} - - - org.apache.logging.log4j - log4j-slf4j-impl - - - - diff --git a/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-provider/src/main/java/org/apache/dubbo/demo/provider/Application.java b/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-provider/src/main/java/org/apache/dubbo/demo/provider/Application.java deleted file mode 100644 index 56fe623cc90..00000000000 --- a/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-provider/src/main/java/org/apache/dubbo/demo/provider/Application.java +++ /dev/null @@ -1,46 +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.demo.provider; - -import org.apache.dubbo.config.RegistryConfig; -import org.apache.dubbo.config.spring.context.annotation.EnableDubbo; - -import org.springframework.context.annotation.AnnotationConfigApplicationContext; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; - -public class Application { - public static void main(String[] args) throws Exception { - AnnotationConfigApplicationContext context = - new AnnotationConfigApplicationContext(ProviderConfiguration.class); - context.start(); - System.in.read(); - } - - @Configuration - @EnableDubbo(scanBasePackages = "org.apache.dubbo.demo.provider") - @PropertySource("classpath:/spring/dubbo-provider.properties") - static class ProviderConfiguration { - @Bean - public RegistryConfig registryConfig() { - RegistryConfig registryConfig = new RegistryConfig(); - registryConfig.setAddress("zookeeper://127.0.0.1:2181"); - return registryConfig; - } - } -} diff --git a/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-provider/src/main/java/org/apache/dubbo/demo/provider/DemoServiceImpl.java b/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-provider/src/main/java/org/apache/dubbo/demo/provider/DemoServiceImpl.java deleted file mode 100644 index 8b4f9446500..00000000000 --- a/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-provider/src/main/java/org/apache/dubbo/demo/provider/DemoServiceImpl.java +++ /dev/null @@ -1,44 +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.demo.provider; - -import org.apache.dubbo.config.annotation.DubboService; -import org.apache.dubbo.demo.DemoService; -import org.apache.dubbo.rpc.RpcContext; - -import java.util.concurrent.CompletableFuture; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@DubboService -public class DemoServiceImpl implements DemoService { - private static final Logger logger = LoggerFactory.getLogger(DemoServiceImpl.class); - - @Override - public String sayHello(String name) { - logger.info("Hello " + name + ", request from consumer: " - + RpcContext.getServiceContext().getRemoteAddress()); - return "Hello " + name + ", response from provider: " - + RpcContext.getServiceContext().getLocalAddress(); - } - - @Override - public CompletableFuture sayHelloAsync(String name) { - return null; - } -} diff --git a/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-provider/src/main/resources/spring/dubbo-provider.properties b/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-provider/src/main/resources/spring/dubbo-provider.properties deleted file mode 100644 index 4b4913e0251..00000000000 --- a/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-provider/src/main/resources/spring/dubbo-provider.properties +++ /dev/null @@ -1,22 +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. -# -# - -dubbo.application.name=dubbo-demo-annotation-provider -dubbo.protocol.name=dubbo -dubbo.protocol.port=-1 diff --git a/dubbo-demo/dubbo-demo-api/dubbo-demo-api-consumer/pom.xml b/dubbo-demo/dubbo-demo-api/dubbo-demo-api-consumer/pom.xml index ce9ef312488..b7a69efaba8 100644 --- a/dubbo-demo/dubbo-demo-api/dubbo-demo-api-consumer/pom.xml +++ b/dubbo-demo/dubbo-demo-api/dubbo-demo-api-consumer/pom.xml @@ -33,7 +33,7 @@ org.apache.dubbo - dubbo-demo-interface + dubbo-demo-api-interface ${project.parent.version} diff --git a/dubbo-demo/dubbo-demo-api/dubbo-demo-api-consumer/src/main/java/org/apache/dubbo/demo/consumer/Application.java b/dubbo-demo/dubbo-demo-api/dubbo-demo-api-consumer/src/main/java/org/apache/dubbo/demo/consumer/Application.java index 07cbefed293..05087147ba7 100644 --- a/dubbo-demo/dubbo-demo-api/dubbo-demo-api-consumer/src/main/java/org/apache/dubbo/demo/consumer/Application.java +++ b/dubbo-demo/dubbo-demo-api/dubbo-demo-api-consumer/src/main/java/org/apache/dubbo/demo/consumer/Application.java @@ -16,13 +16,13 @@ */ package org.apache.dubbo.demo.consumer; +import org.apache.dubbo.api.demo.DemoService; import org.apache.dubbo.common.constants.CommonConstants; import org.apache.dubbo.config.ApplicationConfig; import org.apache.dubbo.config.ProtocolConfig; import org.apache.dubbo.config.ReferenceConfig; import org.apache.dubbo.config.RegistryConfig; import org.apache.dubbo.config.bootstrap.DubboBootstrap; -import org.apache.dubbo.demo.DemoService; import org.apache.dubbo.rpc.service.GenericService; public class Application { @@ -42,7 +42,7 @@ private static void runWithBootstrap() { bootstrap .application(new ApplicationConfig("dubbo-demo-api-consumer")) .registry(new RegistryConfig(REGISTRY_URL)) - .protocol(new ProtocolConfig(CommonConstants.DUBBO, -1)) + .protocol(new ProtocolConfig(CommonConstants.TRIPLE, -1)) .reference(reference) .start(); diff --git a/dubbo-demo/dubbo-demo-native/dubbo-demo-native-interface/pom.xml b/dubbo-demo/dubbo-demo-api/dubbo-demo-api-interface/pom.xml similarity index 88% rename from dubbo-demo/dubbo-demo-native/dubbo-demo-native-interface/pom.xml rename to dubbo-demo/dubbo-demo-api/dubbo-demo-api-interface/pom.xml index 2184cc8e123..f81b9113374 100644 --- a/dubbo-demo/dubbo-demo-native/dubbo-demo-native-interface/pom.xml +++ b/dubbo-demo/dubbo-demo-api/dubbo-demo-api-interface/pom.xml @@ -16,18 +16,19 @@ limitations under the License. --> - 4.0.0 org.apache.dubbo - dubbo-demo-native + dubbo-demo-api ${revision} ../pom.xml - dubbo-demo-native-interface + dubbo-demo-api-interface + UTF-8 true + diff --git a/dubbo-demo/dubbo-demo-interface/src/main/java/org/apache/dubbo/demo/DemoService.java b/dubbo-demo/dubbo-demo-api/dubbo-demo-api-interface/src/main/java/org/apache/dubbo/api/demo/DemoService.java similarity index 96% rename from dubbo-demo/dubbo-demo-interface/src/main/java/org/apache/dubbo/demo/DemoService.java rename to dubbo-demo/dubbo-demo-api/dubbo-demo-api-interface/src/main/java/org/apache/dubbo/api/demo/DemoService.java index 26f1ac524aa..c69307f3a21 100644 --- a/dubbo-demo/dubbo-demo-interface/src/main/java/org/apache/dubbo/demo/DemoService.java +++ b/dubbo-demo/dubbo-demo-api/dubbo-demo-api-interface/src/main/java/org/apache/dubbo/api/demo/DemoService.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dubbo.demo; +package org.apache.dubbo.api.demo; import java.util.concurrent.CompletableFuture; diff --git a/dubbo-demo/dubbo-demo-api/dubbo-demo-api-provider/pom.xml b/dubbo-demo/dubbo-demo-api/dubbo-demo-api-provider/pom.xml index c29e4ababfb..74e0ca63ac2 100644 --- a/dubbo-demo/dubbo-demo-api/dubbo-demo-api-provider/pom.xml +++ b/dubbo-demo/dubbo-demo-api/dubbo-demo-api-provider/pom.xml @@ -35,7 +35,7 @@ org.apache.dubbo - dubbo-demo-interface + dubbo-demo-api-interface ${project.parent.version} diff --git a/dubbo-demo/dubbo-demo-api/dubbo-demo-api-provider/src/main/java/org/apache/dubbo/demo/provider/Application.java b/dubbo-demo/dubbo-demo-api/dubbo-demo-api-provider/src/main/java/org/apache/dubbo/demo/provider/Application.java index d6f70a57a1a..e51dda0dfe1 100644 --- a/dubbo-demo/dubbo-demo-api/dubbo-demo-api-provider/src/main/java/org/apache/dubbo/demo/provider/Application.java +++ b/dubbo-demo/dubbo-demo-api/dubbo-demo-api-provider/src/main/java/org/apache/dubbo/demo/provider/Application.java @@ -16,13 +16,13 @@ */ package org.apache.dubbo.demo.provider; +import org.apache.dubbo.api.demo.DemoService; 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 org.apache.dubbo.config.bootstrap.DubboBootstrap; -import org.apache.dubbo.demo.DemoService; public class Application { diff --git a/dubbo-demo/dubbo-demo-api/dubbo-demo-api-provider/src/main/java/org/apache/dubbo/demo/provider/DemoServiceImpl.java b/dubbo-demo/dubbo-demo-api/dubbo-demo-api-provider/src/main/java/org/apache/dubbo/demo/provider/DemoServiceImpl.java index e7760f53a73..1a5b896783b 100644 --- a/dubbo-demo/dubbo-demo-api/dubbo-demo-api-provider/src/main/java/org/apache/dubbo/demo/provider/DemoServiceImpl.java +++ b/dubbo-demo/dubbo-demo-api/dubbo-demo-api-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.DemoService; +import org.apache.dubbo.api.demo.DemoService; import org.apache.dubbo.rpc.RpcContext; import java.util.concurrent.CompletableFuture; diff --git a/dubbo-demo/dubbo-demo-api/pom.xml b/dubbo-demo/dubbo-demo-api/pom.xml index d3d03bb6c63..b44b1263552 100644 --- a/dubbo-demo/dubbo-demo-api/pom.xml +++ b/dubbo-demo/dubbo-demo-api/pom.xml @@ -30,6 +30,7 @@ dubbo-demo-api-provider dubbo-demo-api-consumer + dubbo-demo-api-interface diff --git a/dubbo-demo/dubbo-demo-generic-call/pom.xml b/dubbo-demo/dubbo-demo-generic-call/pom.xml deleted file mode 100644 index 9ea4900e027..00000000000 --- a/dubbo-demo/dubbo-demo-generic-call/pom.xml +++ /dev/null @@ -1,103 +0,0 @@ - - - - 4.0.0 - - org.apache.dubbo - dubbo-parent - ${revision} - ../../pom.xml - - - dubbo-demo-generic-call - - - true - - - - - org.apache.dubbo - dubbo-config-api - ${project.version} - - - org.apache.dubbo - dubbo-registry-multicast - ${project.version} - - - org.apache.dubbo - dubbo-registry-zookeeper - ${project.version} - - - org.apache.dubbo - dubbo-registry-nacos - ${project.version} - - - com.alibaba.nacos - nacos-client - - - org.apache.dubbo - dubbo-configcenter-zookeeper - ${project.version} - - - org.apache.dubbo - dubbo-configcenter-nacos - ${project.version} - - - org.apache.dubbo - dubbo-metadata-report-zookeeper - ${project.version} - - - org.apache.dubbo - dubbo-metadata-report-nacos - ${project.version} - - - org.apache.dubbo - dubbo-rpc-dubbo - ${project.version} - - - org.apache.dubbo - dubbo-remoting-netty4 - ${project.version} - - - org.apache.dubbo - dubbo-serialization-hessian2 - ${project.version} - - - org.apache.dubbo - dubbo-serialization-fastjson2 - ${project.version} - - - org.apache.logging.log4j - log4j-slf4j-impl - - - diff --git a/dubbo-demo/dubbo-demo-generic-call/src/main/java/org/apache/dubbo/demo/consumer/GenericApplication.java b/dubbo-demo/dubbo-demo-generic-call/src/main/java/org/apache/dubbo/demo/consumer/GenericApplication.java deleted file mode 100644 index 9b8a2210cb4..00000000000 --- a/dubbo-demo/dubbo-demo-generic-call/src/main/java/org/apache/dubbo/demo/consumer/GenericApplication.java +++ /dev/null @@ -1,74 +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.demo.consumer; - -import org.apache.dubbo.common.constants.CommonConstants; -import org.apache.dubbo.common.utils.JsonUtils; -import org.apache.dubbo.config.ApplicationConfig; -import org.apache.dubbo.config.MetadataReportConfig; -import org.apache.dubbo.config.ProtocolConfig; -import org.apache.dubbo.config.ReferenceConfig; -import org.apache.dubbo.config.RegistryConfig; -import org.apache.dubbo.config.bootstrap.DubboBootstrap; -import org.apache.dubbo.rpc.service.GenericService; - -public class GenericApplication { - - public static void main(String[] args) { - runWithBootstrap(args); - } - - private static void runWithBootstrap(String[] args) { - ReferenceConfig reference = new ReferenceConfig<>(); - reference.setInterface("org.apache.dubbo.demo.DemoService"); - - String param = "dubbo generic invoke"; - - if (args.length > 0 && CommonConstants.GENERIC_SERIALIZATION_GSON.equals(args[0])) { - reference.setGeneric(CommonConstants.GENERIC_SERIALIZATION_GSON); - param = JsonUtils.toJson(param + " gson"); - } else { - reference.setGeneric("true"); - } - - ApplicationConfig applicationConfig = new ApplicationConfig("demo-consumer"); - - MetadataReportConfig metadataReportConfig = new MetadataReportConfig(); - metadataReportConfig.setAddress("zookeeper://127.0.0.1:2181"); - - DubboBootstrap bootstrap = DubboBootstrap.getInstance(); - bootstrap - .application(applicationConfig) - .registry(new RegistryConfig("zookeeper://127.0.0.1:2181")) - .protocol(new ProtocolConfig(CommonConstants.DUBBO, -1)) - .reference(reference) - .start(); - - // generic invoke - GenericService genericService = bootstrap.getCache().get(reference); - while (true) { - try { - Object genericInvokeResult = - genericService.$invoke("sayHello", new String[] {String.class.getName()}, new Object[] {param}); - System.out.println(genericInvokeResult); - Thread.sleep(1000); - } catch (Exception e) { - e.printStackTrace(); - } - } - } -} diff --git a/dubbo-demo/dubbo-demo-generic-call/src/main/resources/log4j2.xml b/dubbo-demo/dubbo-demo-generic-call/src/main/resources/log4j2.xml deleted file mode 100644 index 69e1321d220..00000000000 --- a/dubbo-demo/dubbo-demo-generic-call/src/main/resources/log4j2.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - diff --git a/dubbo-demo/dubbo-demo-interface/pom.xml b/dubbo-demo/dubbo-demo-interface/pom.xml deleted file mode 100644 index 7a9e840f25d..00000000000 --- a/dubbo-demo/dubbo-demo-interface/pom.xml +++ /dev/null @@ -1,69 +0,0 @@ - - - - 4.0.0 - - org.apache.dubbo - dubbo-parent - ${revision} - ../../pom.xml - - dubbo-demo-interface - jar - ${project.artifactId} - The demo module of dubbo project - - - true - - - - - - javax.ws.rs - javax.ws.rs-api - - - - org.springframework - spring-context - test - - - - org.springframework - spring-web - - - - org.apache.logging.log4j - log4j-slf4j-impl - - - - io.swagger - swagger-jaxrs - - - javax.ws.rs - jsr311-api - - - - - diff --git a/dubbo-demo/dubbo-demo-interface/src/main/java/org/apache/dubbo/demo/GreetingService.java b/dubbo-demo/dubbo-demo-interface/src/main/java/org/apache/dubbo/demo/GreetingService.java deleted file mode 100644 index 38c7a6072d1..00000000000 --- a/dubbo-demo/dubbo-demo-interface/src/main/java/org/apache/dubbo/demo/GreetingService.java +++ /dev/null @@ -1,24 +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.demo; - -/** - * - */ -public interface GreetingService { - String hello(); -} diff --git a/dubbo-demo/dubbo-demo-interface/src/main/java/org/apache/dubbo/demo/RestDemoService.java b/dubbo-demo/dubbo-demo-interface/src/main/java/org/apache/dubbo/demo/RestDemoService.java deleted file mode 100644 index 0405b739f23..00000000000 --- a/dubbo-demo/dubbo-demo-interface/src/main/java/org/apache/dubbo/demo/RestDemoService.java +++ /dev/null @@ -1,89 +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.demo; - -import javax.ws.rs.Consumes; -import javax.ws.rs.FormParam; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.MultivaluedMap; - -import po.TestPO; - -@Path("/demoService") -public interface RestDemoService { - @GET - @Path("/hello") - @Consumes(MediaType.TEXT_PLAIN) - @Produces(MediaType.TEXT_PLAIN) - Integer hello(@QueryParam("a") Integer a, @QueryParam("b") Integer b); - - @GET - @Path("/error") - String error(); - - @POST - @Path("/say") - @Consumes({MediaType.TEXT_PLAIN}) - String sayHello(String name); - - @GET - @Path("/getRemoteApplicationName") - String getRemoteApplicationName(); - - @POST - @Path("/testBody1") - @Consumes({MediaType.TEXT_PLAIN}) - Integer testBody(Integer b); - - @POST - @Path("/testBody2") - @Consumes({MediaType.TEXT_PLAIN}) - String testBody2(String b); - - @POST - @Path("/testBody3") - @Consumes({MediaType.TEXT_PLAIN}) - Boolean testBody2(Boolean b); - - @POST - @Path("/testBody4") - @Consumes({MediaType.TEXT_PLAIN}) - TestPO testBody2(TestPO b); - - @POST - @Path("/testBody5") - @Consumes({MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_JSON}) - TestPO testBody5(TestPO testPO); - - @POST - @Path("/testForm1") - @Consumes(MediaType.APPLICATION_FORM_URLENCODED) - @Produces(MediaType.TEXT_PLAIN) - String testForm1(@FormParam("name") String test); - - @POST - @Path("/testForm2") - @Consumes(MediaType.APPLICATION_FORM_URLENCODED) - @Produces(MediaType.APPLICATION_FORM_URLENCODED) - MultivaluedMap testForm2(MultivaluedMap map); -} diff --git a/dubbo-demo/dubbo-demo-interface/src/main/java/org/apache/dubbo/demo/TripleService.java b/dubbo-demo/dubbo-demo-interface/src/main/java/org/apache/dubbo/demo/TripleService.java deleted file mode 100644 index 8aed07b507a..00000000000 --- a/dubbo-demo/dubbo-demo-interface/src/main/java/org/apache/dubbo/demo/TripleService.java +++ /dev/null @@ -1,21 +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.demo; - -public interface TripleService { - String hello(); -} diff --git a/dubbo-demo/dubbo-demo-interface/src/main/java/org/apache/dubbo/demo/rest/api/CurlService.java b/dubbo-demo/dubbo-demo-interface/src/main/java/org/apache/dubbo/demo/rest/api/CurlService.java deleted file mode 100644 index b77cded2f57..00000000000 --- a/dubbo-demo/dubbo-demo-interface/src/main/java/org/apache/dubbo/demo/rest/api/CurlService.java +++ /dev/null @@ -1,30 +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.demo.rest.api; - -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Path; - -@Path("/curl") -public interface CurlService { - // curl -X GET http://localhost:8888/services/curl - // http://localhost:8888/services/curl - @GET - @Consumes({javax.ws.rs.core.MediaType.TEXT_PLAIN}) - String curl(); -} diff --git a/dubbo-demo/dubbo-demo-interface/src/main/java/org/apache/dubbo/demo/rest/api/DubboServiceAnnotationService.java b/dubbo-demo/dubbo-demo-interface/src/main/java/org/apache/dubbo/demo/rest/api/DubboServiceAnnotationService.java deleted file mode 100644 index 478b3e6dc20..00000000000 --- a/dubbo-demo/dubbo-demo-interface/src/main/java/org/apache/dubbo/demo/rest/api/DubboServiceAnnotationService.java +++ /dev/null @@ -1,28 +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.demo.rest.api; - -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Path; - -@Path("/annotation") -public interface DubboServiceAnnotationService { - @GET - @Consumes({javax.ws.rs.core.MediaType.TEXT_PLAIN}) - String annotation(); -} diff --git a/dubbo-demo/dubbo-demo-interface/src/main/java/org/apache/dubbo/demo/rest/api/ExceptionMapperService.java b/dubbo-demo/dubbo-demo-interface/src/main/java/org/apache/dubbo/demo/rest/api/ExceptionMapperService.java deleted file mode 100644 index 277693d9155..00000000000 --- a/dubbo-demo/dubbo-demo-interface/src/main/java/org/apache/dubbo/demo/rest/api/ExceptionMapperService.java +++ /dev/null @@ -1,28 +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.demo.rest.api; - -import javax.ws.rs.POST; -import javax.ws.rs.Path; - -@Path("/exception/mapper") -public interface ExceptionMapperService { - - @POST - @Path("/exception") - String exception(String message); -} diff --git a/dubbo-demo/dubbo-demo-interface/src/main/java/org/apache/dubbo/demo/rest/api/HttpMethodService.java b/dubbo-demo/dubbo-demo-interface/src/main/java/org/apache/dubbo/demo/rest/api/HttpMethodService.java deleted file mode 100644 index db1a815d46d..00000000000 --- a/dubbo-demo/dubbo-demo-interface/src/main/java/org/apache/dubbo/demo/rest/api/HttpMethodService.java +++ /dev/null @@ -1,68 +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.demo.rest.api; - -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.HEAD; -import javax.ws.rs.OPTIONS; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.QueryParam; - -import io.swagger.jaxrs.PATCH; - -@Path("/demoService") -public interface HttpMethodService { - - @POST - @Path("/sayPost") - @Consumes({javax.ws.rs.core.MediaType.TEXT_PLAIN}) - String sayHelloPost(String hello); - - @DELETE - @Path("/sayDelete") - @Consumes({javax.ws.rs.core.MediaType.TEXT_PLAIN}) - String sayHelloDelete(@QueryParam("name") String hello); - - @HEAD - @Path("/sayHead") - @Consumes({javax.ws.rs.core.MediaType.TEXT_PLAIN}) - String sayHelloHead(@QueryParam("name") String hello); - - @GET - @Path("/sayGet") - @Consumes({javax.ws.rs.core.MediaType.TEXT_PLAIN}) - String sayHelloGet(@QueryParam("name") String hello); - - @PUT - @Path("/sayPut") - @Consumes({javax.ws.rs.core.MediaType.TEXT_PLAIN}) - String sayHelloPut(@QueryParam("name") String hello); - - @PATCH - @Path("/sayPatch") - @Consumes({javax.ws.rs.core.MediaType.TEXT_PLAIN}) - String sayHelloPatch(@QueryParam("name") String hello); - - @OPTIONS - @Path("/sayOptions") - @Consumes({javax.ws.rs.core.MediaType.TEXT_PLAIN}) - String sayHelloOptions(@QueryParam("name") String hello); -} diff --git a/dubbo-demo/dubbo-demo-interface/src/main/java/org/apache/dubbo/demo/rest/api/HttpRequestAndResponseRPCContextService.java b/dubbo-demo/dubbo-demo-interface/src/main/java/org/apache/dubbo/demo/rest/api/HttpRequestAndResponseRPCContextService.java deleted file mode 100644 index 4e925b386d8..00000000000 --- a/dubbo-demo/dubbo-demo-interface/src/main/java/org/apache/dubbo/demo/rest/api/HttpRequestAndResponseRPCContextService.java +++ /dev/null @@ -1,44 +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.demo.rest.api; - -import javax.ws.rs.Consumes; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.QueryParam; - -import java.util.List; - -@Path("/demoService") -public interface HttpRequestAndResponseRPCContextService { - - @POST - @Path("/httpRequestParam") - @Consumes({javax.ws.rs.core.MediaType.TEXT_PLAIN}) - String httpRequestParam(@QueryParam("name") String hello); - - @POST - @Path("/httpRequestHeader") - @Consumes({javax.ws.rs.core.MediaType.TEXT_PLAIN}) - String httpRequestHeader(@HeaderParam("header") String hello); - - @POST - @Path("/httpResponseHeader") - @Consumes({javax.ws.rs.core.MediaType.TEXT_PLAIN}) - List httpResponseHeader(@HeaderParam("response") String hello); -} diff --git a/dubbo-demo/dubbo-demo-interface/src/main/java/org/apache/dubbo/demo/rest/api/JaxRsRestDemoService.java b/dubbo-demo/dubbo-demo-interface/src/main/java/org/apache/dubbo/demo/rest/api/JaxRsRestDemoService.java deleted file mode 100644 index 9b61aa54521..00000000000 --- a/dubbo-demo/dubbo-demo-interface/src/main/java/org/apache/dubbo/demo/rest/api/JaxRsRestDemoService.java +++ /dev/null @@ -1,111 +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.demo.rest.api; - -import javax.ws.rs.Consumes; -import javax.ws.rs.FormParam; -import javax.ws.rs.GET; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.MultivaluedMap; - -import java.util.List; -import java.util.Map; - -import po.User; - -/** - * - * @Consumers & @Produces can be not used ,we will make sure the content-type of request by arg type - * but the Request method is forbidden disappear - * parameters which annotation are not present , it is from the body (jaxrs annotation is different from spring web from param(only request param can ignore annotation)) - * - * Every method only one param from body - * - * the path annotation must present in class & method - */ -@Path("/jaxrs/demo/service") -public interface JaxRsRestDemoService { - @GET - @Path("/hello") - Integer hello(@QueryParam("a") Integer a, @QueryParam("b") Integer b); - - @GET - @Path("/error") - String error(); - - @POST - @Path("/say") - String sayHello(String name); - - @POST - @Path("/testFormBody") - Long testFormBody(@FormParam("number") Long number); - - @POST - @Path("/testJavaBeanBody") - @Consumes({MediaType.APPLICATION_JSON}) - User testJavaBeanBody(User user); - - @GET - @Path("/primitive") - int primitiveInt(@QueryParam("a") int a, @QueryParam("b") int b); - - @GET - @Path("/primitiveLong") - long primitiveLong(@QueryParam("a") long a, @QueryParam("b") Long b); - - @GET - @Path("/primitiveByte") - long primitiveByte(@QueryParam("a") byte a, @QueryParam("b") Long b); - - @POST - @Path("/primitiveShort") - long primitiveShort(@QueryParam("a") short a, @QueryParam("b") Long b, int c); - - @GET - @Path("testMapParam") - @Produces({MediaType.TEXT_PLAIN}) - @Consumes({MediaType.TEXT_PLAIN}) - String testMapParam(@QueryParam("test") Map params); - - @GET - @Path("testMapHeader") - @Produces({MediaType.TEXT_PLAIN}) - @Consumes({MediaType.TEXT_PLAIN}) - String testMapHeader(@HeaderParam("test") Map headers); - - @POST - @Path("testMapForm") - @Produces({MediaType.APPLICATION_JSON}) - @Consumes({MediaType.APPLICATION_FORM_URLENCODED}) - List testMapForm(MultivaluedMap params); - - @POST - @Path("/header") - @Consumes({MediaType.TEXT_PLAIN}) - String header(@HeaderParam("header") String header); - - @POST - @Path("/headerInt") - @Consumes({MediaType.TEXT_PLAIN}) - int headerInt(@HeaderParam("header") int header); -} diff --git a/dubbo-demo/dubbo-demo-interface/src/main/java/org/apache/dubbo/demo/rest/api/SpringRestDemoService.java b/dubbo-demo/dubbo-demo-interface/src/main/java/org/apache/dubbo/demo/rest/api/SpringRestDemoService.java deleted file mode 100644 index ef726b5e2d3..00000000000 --- a/dubbo-demo/dubbo-demo-interface/src/main/java/org/apache/dubbo/demo/rest/api/SpringRestDemoService.java +++ /dev/null @@ -1,81 +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.demo.rest.api; - -import java.util.List; -import java.util.Map; - -import org.springframework.http.MediaType; -import org.springframework.util.MultiValueMap; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import po.User; - -@RequestMapping("/spring/demo/service") -public interface SpringRestDemoService { - - @RequestMapping(method = RequestMethod.GET, value = "/hello") - Integer hello(@RequestParam("a") Integer a, @RequestParam("b") Integer b); - - @RequestMapping(method = RequestMethod.GET, value = "/error") - String error(); - - @RequestMapping(method = RequestMethod.POST, value = "/say") - String sayHello(@RequestBody String name); - - @RequestMapping( - method = RequestMethod.POST, - value = "/testFormBody", - consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE) - Long testFormBody(@RequestBody Long number); - - @RequestMapping( - method = RequestMethod.POST, - value = "/testJavaBeanBody", - consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE) - User testJavaBeanBody(@RequestBody User user); - - @RequestMapping(method = RequestMethod.GET, value = "/primitive") - int primitiveInt(@RequestParam("a") int a, @RequestParam("b") int b); - - @RequestMapping(method = RequestMethod.GET, value = "/primitiveLong") - long primitiveLong(@RequestParam("a") long a, @RequestParam("b") Long b); - - @RequestMapping(method = RequestMethod.GET, value = "/primitiveByte") - long primitiveByte(@RequestParam("a") byte a, @RequestParam("b") Long b); - - @RequestMapping(method = RequestMethod.POST, value = "/primitiveShort") - long primitiveShort(@RequestParam("a") short a, @RequestParam("b") Long b, @RequestBody int c); - - @RequestMapping(method = RequestMethod.GET, value = "/testMapParam") - String testMapParam(@RequestParam Map params); - - @RequestMapping(method = RequestMethod.GET, value = "/testMapHeader") - String testMapHeader(@RequestHeader Map headers); - - @RequestMapping( - method = RequestMethod.POST, - value = "/testMapForm", - consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE) - List testMapForm(MultiValueMap params); - - @RequestMapping(method = RequestMethod.GET, value = "/headerInt") - int headerInt(@RequestHeader("header") int header); -} diff --git a/dubbo-demo/dubbo-demo-interface/src/main/java/po/TestPO.java b/dubbo-demo/dubbo-demo-interface/src/main/java/po/TestPO.java deleted file mode 100644 index 29a139f08ab..00000000000 --- a/dubbo-demo/dubbo-demo-interface/src/main/java/po/TestPO.java +++ /dev/null @@ -1,64 +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 po; - -public class TestPO { - private String name; - private String address; - private int age; - - public TestPO(String name, String address, int age) { - this.name = name; - this.address = address; - this.age = age; - } - - public TestPO() {} - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getAddress() { - return address; - } - - public void setAddress(String address) { - this.address = address; - } - - public int getAge() { - return age; - } - - public void setAge(int age) { - this.age = age; - } - - public static TestPO getInstance() { - return new TestPO("dubbo", "hangzhou", 10); - } - - @Override - public String toString() { - return "TestPO{" + "name='" + name + '\'' + ", address='" + address + '\'' + ", age=" + age + '}'; - } -} diff --git a/dubbo-demo/dubbo-demo-interface/src/main/java/po/User.java b/dubbo-demo/dubbo-demo-interface/src/main/java/po/User.java deleted file mode 100644 index d5a6326c900..00000000000 --- a/dubbo-demo/dubbo-demo-interface/src/main/java/po/User.java +++ /dev/null @@ -1,72 +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 po; - -import java.io.Serializable; -import java.util.Objects; - -public class User implements Serializable { - - private Long id; - - private String name; - - public User() {} - - public User(Long id, String name) { - this.id = id; - this.name = name; - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public static User getInstance() { - return new User(1l, "dubbo-rest"); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - User user = (User) o; - return Objects.equals(id, user.id) && Objects.equals(name, user.name); - } - - @Override - public int hashCode() { - return Objects.hash(id, name); - } - - @Override - public String toString() { - return "User (" + "id=" + id + ", name='" + name + '\'' + ')'; - } -} diff --git a/dubbo-demo/dubbo-demo-native/dubbo-demo-native-consumer/pom.xml b/dubbo-demo/dubbo-demo-native/dubbo-demo-native-consumer/pom.xml deleted file mode 100644 index 42ead1a9ef5..00000000000 --- a/dubbo-demo/dubbo-demo-native/dubbo-demo-native-consumer/pom.xml +++ /dev/null @@ -1,216 +0,0 @@ - - - - - 4.0.0 - - org.apache.dubbo - dubbo-demo-native - ${revision} - ../pom.xml - - - dubbo-demo-native-consumer - - - true - 5.7.1 - 3.8.4 - - - - - org.apache.dubbo - dubbo-demo-native-interface - ${project.version} - - - org.apache.dubbo - dubbo-config-api - ${project.version} - - - org.apache.dubbo - dubbo-registry-multicast - ${project.version} - - - org.apache.curator - curator-x-discovery - ${curator5_version} - - - org.apache.curator - curator-recipes - ${curator5_version} - - - org.apache.curator - curator-framework - ${curator5_version} - - - org.apache.zookeeper - zookeeper - ${zookeeper_version} - - - io.netty - netty-handler - - - io.netty - netty-transport-native-epoll - - - ch.qos.logback - logback-core - - - - - - org.apache.dubbo - dubbo-registry-zookeeper - ${project.version} - - - org.apache.curator - curator-x-discovery - - - org.apache.zookeeper - zookeeper - - - org.apache.curator - curator-recipes - - - org.apache.curator - curator-framework - - - - - org.apache.dubbo - dubbo-rpc-dubbo - ${project.version} - - - org.apache.dubbo - dubbo-remoting-netty4 - ${project.version} - - - org.apache.dubbo - dubbo-serialization-fastjson2 - ${project.version} - - - org.apache.dubbo - dubbo-serialization-hessian2 - ${project.version} - - - - org.apache.dubbo - dubbo-filter-cache - ${project.version} - - - org.apache.dubbo - dubbo-filter-validation - ${project.version} - - - - org.apache.dubbo - dubbo-native - ${project.version} - - - ch.qos.logback - logback-classic - - - - ch.qos.logback - logback-core - 1.5.12 - compile - - - - - - native - - native - - - - - org.apache.dubbo - dubbo-maven-plugin - ${project.version} - - org.apache.dubbo.demo.graalvm.consumer.Application - - - - - dubbo-process-aot - - process-sources - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.13.0 - - 1.8 - 1.8 - true - true - UTF-8 - - ${project.basedir}${file.separator}src${file.separator}main${file.separator}java - - - - - org.graalvm.buildtools - native-maven-plugin - 0.10.3 - - ${project.build.outputDirectory} - - true - - 22.3 - org.apache.dubbo.demo.graalvm.consumer.Application - - - - - - - diff --git a/dubbo-demo/dubbo-demo-native/dubbo-demo-native-consumer/src/main/java/org/apache/dubbo/demo/graalvm/consumer/Application.java b/dubbo-demo/dubbo-demo-native/dubbo-demo-native-consumer/src/main/java/org/apache/dubbo/demo/graalvm/consumer/Application.java deleted file mode 100644 index 1c9ebb64e5e..00000000000 --- a/dubbo-demo/dubbo-demo-native/dubbo-demo-native-consumer/src/main/java/org/apache/dubbo/demo/graalvm/consumer/Application.java +++ /dev/null @@ -1,70 +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.demo.graalvm.consumer; - -import org.apache.dubbo.common.constants.CommonConstants; -import org.apache.dubbo.common.constants.CommonConstants.DubboProperty; -import org.apache.dubbo.common.utils.SystemPropertyConfigUtils; -import org.apache.dubbo.config.ApplicationConfig; -import org.apache.dubbo.config.ProtocolConfig; -import org.apache.dubbo.config.ReferenceConfig; -import org.apache.dubbo.config.RegistryConfig; -import org.apache.dubbo.config.bootstrap.DubboBootstrap; -import org.apache.dubbo.graalvm.demo.DemoService; - -import java.util.HashMap; -import java.util.Map; - -public class Application { - - private static final String REGISTRY_URL = "zookeeper://127.0.0.1:2181"; - - public static void main(String[] args) { - SystemPropertyConfigUtils.setSystemProperty(DubboProperty.DUBBO_APPLICATION_LOGGER, "logback"); - System.setProperty("native", "true"); - SystemPropertyConfigUtils.setSystemProperty(DubboProperty.DUBBO_PREFER_JSON_FRAMEWORK_NAME, "fastjson2"); - runWithBootstrap(); - } - - private static void runWithBootstrap() { - DubboBootstrap bootstrap = DubboBootstrap.getInstance(); - - ApplicationConfig applicationConfig = new ApplicationConfig("dubbo-demo-api-consumer"); - applicationConfig.setQosEnable(false); - applicationConfig.setCompiler("jdk"); - Map m = new HashMap<>(1); - m.put("proxy", "jdk"); - applicationConfig.setParameters(m); - - ReferenceConfig reference = new ReferenceConfig<>(); - reference.setInterface(DemoService.class); - reference.setGeneric("false"); - - ProtocolConfig protocolConfig = new ProtocolConfig(CommonConstants.DUBBO, -1); - protocolConfig.setSerialization("hessian2"); - bootstrap - .application(applicationConfig) - .registry(new RegistryConfig(REGISTRY_URL)) - .protocol(protocolConfig) - .reference(reference) - .start(); - - DemoService demoService = bootstrap.getCache().get(reference); - String message = demoService.sayHello("Native"); - System.out.println(message); - } -} diff --git a/dubbo-demo/dubbo-demo-native/dubbo-demo-native-consumer/src/main/resources/META-INF/native-image/proxy-config.json b/dubbo-demo/dubbo-demo-native/dubbo-demo-native-consumer/src/main/resources/META-INF/native-image/proxy-config.json deleted file mode 100644 index cb73756e52c..00000000000 --- a/dubbo-demo/dubbo-demo-native/dubbo-demo-native-consumer/src/main/resources/META-INF/native-image/proxy-config.json +++ /dev/null @@ -1,7 +0,0 @@ -[ - [ - "org.apache.dubbo.graalvm.demo.DemoService", - "org.apache.dubbo.rpc.service.EchoService", - "org.apache.dubbo.rpc.service.Destroyable" - ] -] diff --git a/dubbo-demo/dubbo-demo-native/dubbo-demo-native-consumer/src/main/resources/META-INF/native-image/reflect-config.json b/dubbo-demo/dubbo-demo-native/dubbo-demo-native-consumer/src/main/resources/META-INF/native-image/reflect-config.json deleted file mode 100644 index eee360499b5..00000000000 --- a/dubbo-demo/dubbo-demo-native/dubbo-demo-native-consumer/src/main/resources/META-INF/native-image/reflect-config.json +++ /dev/null @@ -1,17 +0,0 @@ -[ - { - "name": "org.apache.zookeeper.ClientCnxnSocketNIO", - "methods": [ - { - "name": "", - "parameterTypes": [ - "org.apache.zookeeper.client.ZKClientConfig" - ] - }, - { - "name": "", - "parameterTypes": [] - } - ] - } -] diff --git a/dubbo-demo/dubbo-demo-native/dubbo-demo-native-consumer/src/main/resources/dubbo.properties b/dubbo-demo/dubbo-demo-native/dubbo-demo-native-consumer/src/main/resources/dubbo.properties deleted file mode 100644 index 54015d0adf9..00000000000 --- a/dubbo-demo/dubbo-demo-native/dubbo-demo-native-consumer/src/main/resources/dubbo.properties +++ /dev/null @@ -1 +0,0 @@ -native=true diff --git a/dubbo-demo/dubbo-demo-native/dubbo-demo-native-consumer/src/main/resources/log4j2.xml b/dubbo-demo/dubbo-demo-native/dubbo-demo-native-consumer/src/main/resources/log4j2.xml deleted file mode 100644 index 69e1321d220..00000000000 --- a/dubbo-demo/dubbo-demo-native/dubbo-demo-native-consumer/src/main/resources/log4j2.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - diff --git a/dubbo-demo/dubbo-demo-native/dubbo-demo-native-interface/src/main/java/org/apache/dubbo/graalvm/demo/DemoService.java b/dubbo-demo/dubbo-demo-native/dubbo-demo-native-interface/src/main/java/org/apache/dubbo/graalvm/demo/DemoService.java deleted file mode 100644 index 8e338c4bacb..00000000000 --- a/dubbo-demo/dubbo-demo-native/dubbo-demo-native-interface/src/main/java/org/apache/dubbo/graalvm/demo/DemoService.java +++ /dev/null @@ -1,22 +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.graalvm.demo; - -public interface DemoService { - - String sayHello(String name); -} diff --git a/dubbo-demo/dubbo-demo-native/dubbo-demo-native-provider/pom.xml b/dubbo-demo/dubbo-demo-native/dubbo-demo-native-provider/pom.xml deleted file mode 100644 index 89179809c19..00000000000 --- a/dubbo-demo/dubbo-demo-native/dubbo-demo-native-provider/pom.xml +++ /dev/null @@ -1,216 +0,0 @@ - - - - - 4.0.0 - - org.apache.dubbo - dubbo-demo-native - ${revision} - ../pom.xml - - - dubbo-demo-native-provider - - - true - 5.7.1 - 3.8.4 - - - - - org.apache.dubbo - dubbo-demo-native-interface - ${project.version} - - - org.apache.dubbo - dubbo-config-api - ${project.version} - - - org.apache.dubbo - dubbo-registry-multicast - ${project.version} - - - org.apache.curator - curator-x-discovery - ${curator5_version} - - - org.apache.curator - curator-recipes - ${curator5_version} - - - org.apache.curator - curator-framework - ${curator5_version} - - - org.apache.zookeeper - zookeeper - ${zookeeper_version} - - - io.netty - netty-handler - - - io.netty - netty-transport-native-epoll - - - ch.qos.logback - logback-core - - - - - - org.apache.dubbo - dubbo-registry-zookeeper - ${project.version} - - - org.apache.curator - curator-x-discovery - - - org.apache.zookeeper - zookeeper - - - org.apache.curator - curator-recipes - - - org.apache.curator - curator-framework - - - - - org.apache.dubbo - dubbo-rpc-dubbo - ${project.version} - - - org.apache.dubbo - dubbo-remoting-netty4 - ${project.version} - - - org.apache.dubbo - dubbo-serialization-fastjson2 - ${project.version} - - - org.apache.dubbo - dubbo-serialization-hessian2 - ${project.version} - - - - org.apache.dubbo - dubbo-filter-cache - ${project.version} - - - org.apache.dubbo - dubbo-filter-validation - ${project.version} - - - - org.apache.dubbo - dubbo-native - ${project.version} - - - ch.qos.logback - logback-classic - - - - ch.qos.logback - logback-core - 1.5.12 - compile - - - - - - native - - native - - - - - org.apache.dubbo - dubbo-maven-plugin - ${project.version} - - org.apache.dubbo.demo.graalvm.provider.Application - - - - - dubbo-process-aot - - process-sources - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.13.0 - - 1.8 - 1.8 - true - true - UTF-8 - - ${project.basedir}${file.separator}src${file.separator}main${file.separator}java - - - - - org.graalvm.buildtools - native-maven-plugin - 0.10.3 - - ${project.build.outputDirectory} - - true - - 22.3 - org.apache.dubbo.demo.graalvm.provider.Application - - - - - - - diff --git a/dubbo-demo/dubbo-demo-native/dubbo-demo-native-provider/src/main/java/org/apache/dubbo/demo/graalvm/provider/Application.java b/dubbo-demo/dubbo-demo-native/dubbo-demo-native-provider/src/main/java/org/apache/dubbo/demo/graalvm/provider/Application.java deleted file mode 100644 index c0a4e9e4fd2..00000000000 --- a/dubbo-demo/dubbo-demo-native/dubbo-demo-native-provider/src/main/java/org/apache/dubbo/demo/graalvm/provider/Application.java +++ /dev/null @@ -1,74 +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.demo.graalvm.provider; - -import org.apache.dubbo.common.constants.CommonConstants; -import org.apache.dubbo.common.constants.CommonConstants.DubboProperty; -import org.apache.dubbo.common.utils.SystemPropertyConfigUtils; -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 org.apache.dubbo.config.bootstrap.DubboBootstrap; -import org.apache.dubbo.graalvm.demo.DemoService; - -import java.util.HashMap; -import java.util.Map; - -public class Application { - - private static final String REGISTRY_URL = "zookeeper://127.0.0.1:2181"; - - public static void main(String[] args) throws Exception { - SystemPropertyConfigUtils.setSystemProperty(DubboProperty.DUBBO_APPLICATION_LOGGER, "logback"); - System.setProperty("native", "true"); - SystemPropertyConfigUtils.setSystemProperty(DubboProperty.DUBBO_PREFER_JSON_FRAMEWORK_NAME, "fastjson2"); - startWithBootstrap(); - System.in.read(); - } - - private static boolean isClassic(String[] args) { - return args.length > 0 && "classic".equalsIgnoreCase(args[0]); - } - - private static void startWithBootstrap() { - DubboBootstrap bootstrap = DubboBootstrap.getInstance(); - - ApplicationConfig applicationConfig = new ApplicationConfig("dubbo-demo-api-provider"); - applicationConfig.setQosEnable(false); - applicationConfig.setCompiler("jdk"); - Map m = new HashMap<>(1); - m.put("proxy", "jdk"); - applicationConfig.setParameters(m); - - ServiceConfig service = new ServiceConfig<>(); - service.setInterface(DemoService.class); - service.setRef(new DemoServiceImpl()); - - ProtocolConfig protocolConfig = new ProtocolConfig(CommonConstants.DUBBO, -1); - protocolConfig.setSerialization("hessian2"); - bootstrap - .application(applicationConfig) - .registry(new RegistryConfig(REGISTRY_URL)) - .protocol(protocolConfig) - .service(service) - .start() - .await(); - - System.out.println("dubbo service started"); - } -} diff --git a/dubbo-demo/dubbo-demo-native/dubbo-demo-native-provider/src/main/java/org/apache/dubbo/demo/graalvm/provider/DemoServiceImpl.java b/dubbo-demo/dubbo-demo-native/dubbo-demo-native-provider/src/main/java/org/apache/dubbo/demo/graalvm/provider/DemoServiceImpl.java deleted file mode 100644 index a360f6a5d91..00000000000 --- a/dubbo-demo/dubbo-demo-native/dubbo-demo-native-provider/src/main/java/org/apache/dubbo/demo/graalvm/provider/DemoServiceImpl.java +++ /dev/null @@ -1,30 +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.demo.graalvm.provider; - -import org.apache.dubbo.graalvm.demo.DemoService; -import org.apache.dubbo.rpc.RpcContext; - -public class DemoServiceImpl implements DemoService { - - @Override - public String sayHello(String name) { - System.out.println("Hello " + name + ", request from consumer: " - + RpcContext.getContext().getRemoteAddress()); - return "Hello " + name; - } -} diff --git a/dubbo-demo/dubbo-demo-native/dubbo-demo-native-provider/src/main/resources/META-INF/native-image/reflect-config.json b/dubbo-demo/dubbo-demo-native/dubbo-demo-native-provider/src/main/resources/META-INF/native-image/reflect-config.json deleted file mode 100644 index a0cb4a8a360..00000000000 --- a/dubbo-demo/dubbo-demo-native/dubbo-demo-native-provider/src/main/resources/META-INF/native-image/reflect-config.json +++ /dev/null @@ -1,25 +0,0 @@ -[ - { - "name": "org.apache.dubbo.graalvm.demo.DemoService", - "allPublicMethods": true - }, - { - "name": "org.apache.dubbo.demo.graalvm.provider.DemoServiceImpl", - "allDeclaredMethods": true - }, - { - "name": "org.apache.zookeeper.ClientCnxnSocketNIO", - "methods": [ - { - "name": "", - "parameterTypes": [ - "org.apache.zookeeper.client.ZKClientConfig" - ] - }, - { - "name": "", - "parameterTypes": [] - } - ] - } -] diff --git a/dubbo-demo/dubbo-demo-native/dubbo-demo-native-provider/src/main/resources/META-INF/native-image/resource-config.json b/dubbo-demo/dubbo-demo-native/dubbo-demo-native-provider/src/main/resources/META-INF/native-image/resource-config.json deleted file mode 100644 index 6bc4f4cc3b0..00000000000 --- a/dubbo-demo/dubbo-demo-native/dubbo-demo-native-provider/src/main/resources/META-INF/native-image/resource-config.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "resources": { - "includes": [ - { - "pattern": "\\Qdubbo.properties\\E" - }, - { - "pattern": "\\Qlog4j.properties\\E" - } - ] - }, - "bundles": [] -} diff --git a/dubbo-demo/dubbo-demo-native/dubbo-demo-native-provider/src/main/resources/dubbo.properties b/dubbo-demo/dubbo-demo-native/dubbo-demo-native-provider/src/main/resources/dubbo.properties deleted file mode 100644 index 54015d0adf9..00000000000 --- a/dubbo-demo/dubbo-demo-native/dubbo-demo-native-provider/src/main/resources/dubbo.properties +++ /dev/null @@ -1 +0,0 @@ -native=true diff --git a/dubbo-demo/dubbo-demo-native/dubbo-demo-native-provider/src/main/resources/log4j2.xml b/dubbo-demo/dubbo-demo-native/dubbo-demo-native-provider/src/main/resources/log4j2.xml deleted file mode 100644 index 69e1321d220..00000000000 --- a/dubbo-demo/dubbo-demo-native/dubbo-demo-native-provider/src/main/resources/log4j2.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - diff --git a/dubbo-demo/dubbo-demo-annotation/pom.xml b/dubbo-demo/dubbo-demo-spring-boot-idl/dubbo-demo-spring-boot-idl-consumer/pom.xml similarity index 71% rename from dubbo-demo/dubbo-demo-annotation/pom.xml rename to dubbo-demo/dubbo-demo-spring-boot-idl/dubbo-demo-spring-boot-idl-consumer/pom.xml index 30f94c3f919..2a2b74953ae 100644 --- a/dubbo-demo/dubbo-demo-annotation/pom.xml +++ b/dubbo-demo/dubbo-demo-spring-boot-idl/dubbo-demo-spring-boot-idl-consumer/pom.xml @@ -19,37 +19,32 @@ 4.0.0 org.apache.dubbo - dubbo-parent + dubbo-demo-spring-boot-idl ${revision} - ../../pom.xml - dubbo-demo-annotation - pom - - dubbo-demo-annotation-provider - dubbo-demo-annotation-consumer - + dubbo-demo-spring-boot-idl-consumer + UTF-8 true - 2.7.18 - org.springframework.boot - spring-boot-maven-plugin - ${spring-boot-maven-plugin.version} + org.apache.dubbo + dubbo-maven-plugin + ${project.version} - repackage + compile + diff --git a/dubbo-demo/dubbo-demo-spring-boot-idl/dubbo-demo-spring-boot-idl-consumer/src/main/java/org/apache/dubbo/springboot/idl/demo/consumer/ConsumerApplication.java b/dubbo-demo/dubbo-demo-spring-boot-idl/dubbo-demo-spring-boot-idl-consumer/src/main/java/org/apache/dubbo/springboot/idl/demo/consumer/ConsumerApplication.java new file mode 100644 index 00000000000..f18b1a85acc --- /dev/null +++ b/dubbo-demo/dubbo-demo-spring-boot-idl/dubbo-demo-spring-boot-idl-consumer/src/main/java/org/apache/dubbo/springboot/idl/demo/consumer/ConsumerApplication.java @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.dubbo.springboot.idl.demo.consumer; + +import org.apache.dubbo.config.annotation.DubboReference; +import org.apache.dubbo.config.spring.context.annotation.EnableDubbo; +import org.apache.dubbo.demo.hello.GreeterService; +import org.apache.dubbo.demo.hello.HelloReply; +import org.apache.dubbo.demo.hello.HelloRequest; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.stereotype.Service; + +@SpringBootApplication +@Service +@EnableDubbo +public class ConsumerApplication { + + @DubboReference + private GreeterService demoService; + + public static void main(String[] args) { + + ConfigurableApplicationContext context = SpringApplication.run(ConsumerApplication.class, args); + ConsumerApplication application = context.getBean(ConsumerApplication.class); + HelloReply result = application.doSayHello("world"); + System.out.println("result: " + result.getMessage()); + } + + public HelloReply doSayHello(String name) { + return demoService.sayHello(HelloRequest.newBuilder().setName(name).build()); + } +} diff --git a/dubbo-demo/dubbo-demo-triple/src/main/proto/helloworld.proto b/dubbo-demo/dubbo-demo-spring-boot-idl/dubbo-demo-spring-boot-idl-consumer/src/main/proto/helloworld.proto similarity index 73% rename from dubbo-demo/dubbo-demo-triple/src/main/proto/helloworld.proto rename to dubbo-demo/dubbo-demo-spring-boot-idl/dubbo-demo-spring-boot-idl-consumer/src/main/proto/helloworld.proto index 52c3ef756ec..8debdd28961 100644 --- a/dubbo-demo/dubbo-demo-triple/src/main/proto/helloworld.proto +++ b/dubbo-demo/dubbo-demo-spring-boot-idl/dubbo-demo-spring-boot-idl-consumer/src/main/proto/helloworld.proto @@ -32,18 +32,4 @@ message HelloReply { service GreeterService { // Sends a greeting. rpc sayHello(HelloRequest) returns (HelloReply); - - /** - * Sends a greeting with server streaming. - */ - rpc sayHelloServerStream(HelloRequest) returns (stream HelloReply); - - /** - * Sends greetings with bi-directional streaming. - */ - rpc sayHelloBiStream(stream HelloRequest) returns (stream HelloReply); -} -service GreeterWrapperService{ - // Sends a greeting. - rpc sayHello(HelloRequest) returns (HelloReply); } diff --git a/dubbo-demo/dubbo-demo-spring-boot-idl/dubbo-demo-spring-boot-idl-consumer/src/main/resources/application.yml b/dubbo-demo/dubbo-demo-spring-boot-idl/dubbo-demo-spring-boot-idl-consumer/src/main/resources/application.yml new file mode 100644 index 00000000000..9cbc17d4d88 --- /dev/null +++ b/dubbo-demo/dubbo-demo-spring-boot-idl/dubbo-demo-spring-boot-idl-consumer/src/main/resources/application.yml @@ -0,0 +1,35 @@ +# 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. + +spring: + application: + name: dubbo-springboot-idl-demo-consumer + +dubbo: + application: + name: ${spring.application.name} + protocol: + name: tri + port: -1 + registry: + id: zk-registry + address: zookeeper://127.0.0.1:2181 + config-center: + address: zookeeper://127.0.0.1:2181 + metadata-report: + address: zookeeper://127.0.0.1:2181 + + diff --git a/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-provider/src/main/resources/log4j2.xml b/dubbo-demo/dubbo-demo-spring-boot-idl/dubbo-demo-spring-boot-idl-consumer/src/main/resources/log4j2.xml similarity index 87% rename from dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-provider/src/main/resources/log4j2.xml rename to dubbo-demo/dubbo-demo-spring-boot-idl/dubbo-demo-spring-boot-idl-consumer/src/main/resources/log4j2.xml index 69e1321d220..87c6dd5b190 100644 --- a/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-provider/src/main/resources/log4j2.xml +++ b/dubbo-demo/dubbo-demo-spring-boot-idl/dubbo-demo-spring-boot-idl-consumer/src/main/resources/log4j2.xml @@ -18,7 +18,7 @@ - + diff --git a/dubbo-demo/dubbo-demo-native/pom.xml b/dubbo-demo/dubbo-demo-spring-boot-idl/dubbo-demo-spring-boot-idl-provider/pom.xml similarity index 68% rename from dubbo-demo/dubbo-demo-native/pom.xml rename to dubbo-demo/dubbo-demo-spring-boot-idl/dubbo-demo-spring-boot-idl-provider/pom.xml index de54eca9bda..c81d3d8bf9f 100644 --- a/dubbo-demo/dubbo-demo-native/pom.xml +++ b/dubbo-demo/dubbo-demo-spring-boot-idl/dubbo-demo-spring-boot-idl-provider/pom.xml @@ -16,24 +16,35 @@ limitations under the License. --> - 4.0.0 org.apache.dubbo - dubbo-parent + dubbo-demo-spring-boot-idl ${revision} - ../../pom.xml - dubbo-demo-native - pom - - dubbo-demo-native-consumer - dubbo-demo-native-provider - dubbo-demo-native-interface - + dubbo-demo-spring-boot-idl-provider + UTF-8 true + + + + + org.apache.dubbo + dubbo-maven-plugin + ${project.version} + + + + compile + + + + + + + diff --git a/dubbo-demo/dubbo-demo-triple/src/main/java/org/apache/dubbo/demo/GreeterServiceImpl.java b/dubbo-demo/dubbo-demo-spring-boot-idl/dubbo-demo-spring-boot-idl-provider/src/main/java/org/apache/dubbo/springboot/idl/demo/provider/GreeterServiceImpl.java similarity index 58% rename from dubbo-demo/dubbo-demo-triple/src/main/java/org/apache/dubbo/demo/GreeterServiceImpl.java rename to dubbo-demo/dubbo-demo-spring-boot-idl/dubbo-demo-spring-boot-idl-provider/src/main/java/org/apache/dubbo/springboot/idl/demo/provider/GreeterServiceImpl.java index 8ec0403c2bc..495af515c44 100644 --- a/dubbo-demo/dubbo-demo-triple/src/main/java/org/apache/dubbo/demo/GreeterServiceImpl.java +++ b/dubbo-demo/dubbo-demo-spring-boot-idl/dubbo-demo-spring-boot-idl-provider/src/main/java/org/apache/dubbo/springboot/idl/demo/provider/GreeterServiceImpl.java @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dubbo.demo; +package org.apache.dubbo.springboot.idl.demo.provider; -import org.apache.dubbo.common.stream.StreamObserver; +import org.apache.dubbo.config.annotation.DubboService; import org.apache.dubbo.demo.hello.GreeterService; import org.apache.dubbo.demo.hello.HelloReply; import org.apache.dubbo.demo.hello.HelloRequest; @@ -26,6 +26,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +@DubboService public class GreeterServiceImpl implements GreeterService { private static final Logger LOGGER = LoggerFactory.getLogger(GreeterServiceImpl.class); @@ -44,39 +45,6 @@ public CompletableFuture sayHelloAsync(HelloRequest request) { HelloReply.newBuilder().setMessage("Hello " + request.getName()).build()); } - @Override - public void sayHelloServerStream(HelloRequest request, StreamObserver responseObserver) { - LOGGER.info("Received sayHelloServerStream request"); - for (int i = 1; i < 6; i++) { - LOGGER.info("sayHelloServerStream onNext: {} {} times", request.getName(), i); - responseObserver.onNext(toReply("Hello " + request.getName() + ' ' + i + " times")); - } - LOGGER.info("sayHelloServerStream onCompleted"); - responseObserver.onCompleted(); - } - - @Override - public StreamObserver sayHelloBiStream(StreamObserver responseObserver) { - LOGGER.info("Received sayHelloBiStream request"); - return new StreamObserver() { - @Override - public void onNext(HelloRequest request) { - LOGGER.info("sayHelloBiStream onNext: {}", request.getName()); - responseObserver.onNext(toReply("Hello " + request.getName())); - } - - @Override - public void onError(Throwable throwable) { - LOGGER.error("sayHelloBiStream onError", throwable); - } - - @Override - public void onCompleted() { - LOGGER.info("sayHelloBiStream onCompleted"); - } - }; - } - private static HelloReply toReply(String message) { return HelloReply.newBuilder().setMessage(message).build(); } diff --git a/dubbo-demo/dubbo-demo-xml/dubbo-demo-spring-mvc-rest-provider/src/main/java/org/apache/dubbo/demo/rest/api/SpringMvcRestProvider.java b/dubbo-demo/dubbo-demo-spring-boot-idl/dubbo-demo-spring-boot-idl-provider/src/main/java/org/apache/dubbo/springboot/idl/demo/provider/ProviderApplication.java similarity index 62% rename from dubbo-demo/dubbo-demo-xml/dubbo-demo-spring-mvc-rest-provider/src/main/java/org/apache/dubbo/demo/rest/api/SpringMvcRestProvider.java rename to dubbo-demo/dubbo-demo-spring-boot-idl/dubbo-demo-spring-boot-idl-provider/src/main/java/org/apache/dubbo/springboot/idl/demo/provider/ProviderApplication.java index 81bc1024812..488c22be385 100644 --- a/dubbo-demo/dubbo-demo-xml/dubbo-demo-spring-mvc-rest-provider/src/main/java/org/apache/dubbo/demo/rest/api/SpringMvcRestProvider.java +++ b/dubbo-demo/dubbo-demo-spring-boot-idl/dubbo-demo-spring-boot-idl-provider/src/main/java/org/apache/dubbo/springboot/idl/demo/provider/ProviderApplication.java @@ -14,20 +14,21 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dubbo.demo.rest.api; +package org.apache.dubbo.springboot.idl.demo.provider; -import org.springframework.context.support.ClassPathXmlApplicationContext; +import org.apache.dubbo.config.spring.context.annotation.EnableDubbo; -public class SpringMvcRestProvider { +import java.util.concurrent.CountDownLatch; - public static void main(String[] args) throws Exception { - ClassPathXmlApplicationContext context = - new ClassPathXmlApplicationContext(new String[] {"spring/rest-provider.xml"}); - - context.refresh(); +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; - System.out.println("spring mvc rest provider started"); - - System.in.read(); +@SpringBootApplication +@EnableDubbo +public class ProviderApplication { + public static void main(String[] args) throws Exception { + SpringApplication.run(ProviderApplication.class, args); + System.out.println("dubbo service started"); + new CountDownLatch(1).await(); } } diff --git a/dubbo-demo/dubbo-demo-spring-boot-idl/dubbo-demo-spring-boot-idl-provider/src/main/proto/helloworld.proto b/dubbo-demo/dubbo-demo-spring-boot-idl/dubbo-demo-spring-boot-idl-provider/src/main/proto/helloworld.proto new file mode 100644 index 00000000000..8debdd28961 --- /dev/null +++ b/dubbo-demo/dubbo-demo-spring-boot-idl/dubbo-demo-spring-boot-idl-provider/src/main/proto/helloworld.proto @@ -0,0 +1,35 @@ +// 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; +option java_package = "org.apache.dubbo.demo.hello"; +option java_outer_classname = "HelloWorldProto"; +option objc_class_prefix = "HLW"; + +package helloworld; + +// The request message containing the user's name. +message HelloRequest { + string name = 1; +} + +// The response message containing the greetings. +message HelloReply { + string message = 1; +} + +// Service definition. +service GreeterService { + // Sends a greeting. + rpc sayHello(HelloRequest) returns (HelloReply); +} diff --git a/dubbo-demo/dubbo-demo-spring-boot-idl/dubbo-demo-spring-boot-idl-provider/src/main/resources/application.yml b/dubbo-demo/dubbo-demo-spring-boot-idl/dubbo-demo-spring-boot-idl-provider/src/main/resources/application.yml new file mode 100644 index 00000000000..88c5c29c489 --- /dev/null +++ b/dubbo-demo/dubbo-demo-spring-boot-idl/dubbo-demo-spring-boot-idl-provider/src/main/resources/application.yml @@ -0,0 +1,33 @@ +# 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. + +spring: + application: + name: dubbo-springboot-idl-demo-provider + +dubbo: + application: + name: ${spring.application.name} + protocol: + name: tri + port: -1 + registry: + id: zk-registry + address: zookeeper://127.0.0.1:2181 + config-center: + address: zookeeper://127.0.0.1:2181 + metadata-report: + address: zookeeper://127.0.0.1:2181 diff --git a/dubbo-demo/dubbo-demo-triple/src/main/resources/log4j2.xml b/dubbo-demo/dubbo-demo-spring-boot-idl/dubbo-demo-spring-boot-idl-provider/src/main/resources/log4j2.xml similarity index 100% rename from dubbo-demo/dubbo-demo-triple/src/main/resources/log4j2.xml rename to dubbo-demo/dubbo-demo-spring-boot-idl/dubbo-demo-spring-boot-idl-provider/src/main/resources/log4j2.xml diff --git a/dubbo-demo/dubbo-demo-triple/pom.xml b/dubbo-demo/dubbo-demo-spring-boot-idl/pom.xml similarity index 90% rename from dubbo-demo/dubbo-demo-triple/pom.xml rename to dubbo-demo/dubbo-demo-spring-boot-idl/pom.xml index c5dc8381df5..321057f5e4a 100644 --- a/dubbo-demo/dubbo-demo-triple/pom.xml +++ b/dubbo-demo/dubbo-demo-spring-boot-idl/pom.xml @@ -24,16 +24,30 @@ ../../pom.xml - dubbo-demo-triple + dubbo-demo-spring-boot-idl + pom + + dubbo-demo-spring-boot-idl-provider + dubbo-demo-spring-boot-idl-consumer + true - 1.8 - 1.8 + 2.7.18 3.13.0 + + org.apache.dubbo + dubbo-spring-boot-starter + ${revision} + + + org.springframework.boot + spring-boot-starter + ${spring-boot.version} + org.apache.dubbo dubbo-filter-cache @@ -157,18 +171,7 @@ - - org.apache.dubbo - dubbo-maven-plugin - ${project.version} - - - - compile - - - - + org.apache.maven.plugins diff --git a/dubbo-demo/dubbo-demo-spring-boot/dubbo-demo-spring-boot-provider/src/main/resources/application.yml b/dubbo-demo/dubbo-demo-spring-boot/dubbo-demo-spring-boot-provider/src/main/resources/application.yml index b1789be60fa..f154d3967bd 100644 --- a/dubbo-demo/dubbo-demo-spring-boot/dubbo-demo-spring-boot-provider/src/main/resources/application.yml +++ b/dubbo-demo/dubbo-demo-spring-boot/dubbo-demo-spring-boot-provider/src/main/resources/application.yml @@ -22,7 +22,7 @@ dubbo: application: name: ${spring.application.name} protocol: - name: dubbo + name: tri port: -1 registry: id: zk-registry diff --git a/dubbo-demo/dubbo-demo-spring-boot/pom.xml b/dubbo-demo/dubbo-demo-spring-boot/pom.xml index c31b2884095..b6063769c4a 100644 --- a/dubbo-demo/dubbo-demo-spring-boot/pom.xml +++ b/dubbo-demo/dubbo-demo-spring-boot/pom.xml @@ -34,6 +34,8 @@ + 1.8 + 1.8 true 2.7.18 2.7.18 diff --git a/dubbo-demo/dubbo-demo-triple/src/main/java/org/apache/dubbo/demo/GreeterService.java b/dubbo-demo/dubbo-demo-triple/src/main/java/org/apache/dubbo/demo/GreeterService.java deleted file mode 100644 index e9210d25923..00000000000 --- a/dubbo-demo/dubbo-demo-triple/src/main/java/org/apache/dubbo/demo/GreeterService.java +++ /dev/null @@ -1,46 +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.demo; - -import org.apache.dubbo.common.stream.StreamObserver; -import org.apache.dubbo.demo.hello.HelloReply; -import org.apache.dubbo.demo.hello.HelloRequest; - -import java.util.concurrent.CompletableFuture; - -public interface GreeterService { - - /** - * Sends a greeting - */ - HelloReply sayHello(HelloRequest request); - - /** - * Sends a greeting asynchronously - */ - CompletableFuture sayHelloAsync(String request); - - /** - * Sends a greeting with server streaming - */ - void sayHelloServerStream(HelloRequest request, StreamObserver responseObserver); - - /** - * Sends greetings with bi streaming - */ - StreamObserver sayHelloBiStream(StreamObserver responseObserver); -} diff --git a/dubbo-demo/dubbo-demo-triple/src/main/java/org/apache/dubbo/demo/GreeterWrapperService.java b/dubbo-demo/dubbo-demo-triple/src/main/java/org/apache/dubbo/demo/GreeterWrapperService.java deleted file mode 100644 index bb90d4c54f3..00000000000 --- a/dubbo-demo/dubbo-demo-triple/src/main/java/org/apache/dubbo/demo/GreeterWrapperService.java +++ /dev/null @@ -1,25 +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.demo; - -public interface GreeterWrapperService { - - /** - * Sends a greeting - */ - String sayHello(String request); -} diff --git a/dubbo-demo/dubbo-demo-triple/src/main/java/org/apache/dubbo/demo/GreeterWrapperServiceImpl.java b/dubbo-demo/dubbo-demo-triple/src/main/java/org/apache/dubbo/demo/GreeterWrapperServiceImpl.java deleted file mode 100644 index 9af186a2197..00000000000 --- a/dubbo-demo/dubbo-demo-triple/src/main/java/org/apache/dubbo/demo/GreeterWrapperServiceImpl.java +++ /dev/null @@ -1,48 +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.demo; - -import org.apache.dubbo.demo.hello.GreeterWrapperService; -import org.apache.dubbo.demo.hello.HelloReply; -import org.apache.dubbo.demo.hello.HelloRequest; - -import java.util.concurrent.CompletableFuture; - -public class GreeterWrapperServiceImpl implements GreeterWrapperService { - - @Override - public HelloReply sayHello(HelloRequest request) { - StringBuilder responseBuilder = new StringBuilder(request.getName()); - for (int i = 0; i < 20; i++) { - responseBuilder.append(responseBuilder); - } - return HelloReply.newBuilder().setMessage(responseBuilder.toString()).build(); - } - - @Override - public CompletableFuture sayHelloAsync(HelloRequest request) { - return CompletableFuture.supplyAsync(() -> { - StringBuilder responseBuilder = new StringBuilder(request.getName()); - for (int i = 0; i < 20; i++) { - responseBuilder.append(responseBuilder); - } - return HelloReply.newBuilder() - .setMessage(responseBuilder.toString()) - .build(); - }); - } -} diff --git a/dubbo-demo/dubbo-demo-triple/src/main/java/org/apache/dubbo/demo/consumer/ApiConsumer.java b/dubbo-demo/dubbo-demo-triple/src/main/java/org/apache/dubbo/demo/consumer/ApiConsumer.java deleted file mode 100644 index 0ad003b5ceb..00000000000 --- a/dubbo-demo/dubbo-demo-triple/src/main/java/org/apache/dubbo/demo/consumer/ApiConsumer.java +++ /dev/null @@ -1,118 +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.demo.consumer; - -import org.apache.dubbo.common.constants.CommonConstants; -import org.apache.dubbo.common.stream.StreamObserver; -import org.apache.dubbo.config.ApplicationConfig; -import org.apache.dubbo.config.ProtocolConfig; -import org.apache.dubbo.config.ReferenceConfig; -import org.apache.dubbo.config.RegistryConfig; -import org.apache.dubbo.config.bootstrap.DubboBootstrap; -import org.apache.dubbo.demo.hello.GreeterService; -import org.apache.dubbo.demo.hello.HelloReply; -import org.apache.dubbo.demo.hello.HelloRequest; -import org.apache.dubbo.rpc.Constants; - -import java.util.Collections; -import java.util.concurrent.CompletableFuture; - -public class ApiConsumer { - - public static void main(String[] args) throws InterruptedException { - ReferenceConfig referenceConfig = new ReferenceConfig<>(); - referenceConfig.setInterface(GreeterService.class); - referenceConfig.setCheck(false); - referenceConfig.setProtocol(CommonConstants.TRIPLE); - referenceConfig.setLazy(true); - referenceConfig.setTimeout(100000); - if (args.length > 0 && Constants.HTTP3_KEY.equals(args[0])) { - referenceConfig.setParameters(Collections.singletonMap(Constants.HTTP3_KEY, "true")); - } - - DubboBootstrap bootstrap = DubboBootstrap.getInstance(); - bootstrap - .application(new ApplicationConfig("dubbo-demo-triple-api-consumer")) - .registry(new RegistryConfig("zookeeper://127.0.0.1:2181")) - .protocol(new ProtocolConfig(CommonConstants.TRIPLE, -1)) - .reference(referenceConfig) - .start(); - - GreeterService greeterService = referenceConfig.get(); - System.out.println("dubbo referenceConfig started"); - try { - System.out.println("Call sayHello"); - HelloReply reply = greeterService.sayHello(buildRequest("triple")); - System.out.println("sayHello reply: " + reply.getMessage()); - - System.out.println("Call sayHelloAsync"); - CompletableFuture sayHelloAsync = greeterService.sayHelloAsync( - HelloRequest.newBuilder().setName("triple").build()); - sayHelloAsync.thenAccept(value -> System.out.println("sayHelloAsync reply: " + value)); - - StreamObserver responseObserver = new StreamObserver() { - @Override - public void onNext(HelloReply reply) { - System.out.println("sayHelloServerStream onNext: " + reply.getMessage()); - } - - @Override - public void onError(Throwable t) { - System.out.println("sayHelloServerStream onError: " + t.getMessage()); - } - - @Override - public void onCompleted() { - System.out.println("sayHelloServerStream onCompleted"); - } - }; - System.out.println("Call sayHelloServerStream"); - greeterService.sayHelloServerStream(buildRequest("triple"), responseObserver); - - StreamObserver biResponseObserver = new StreamObserver() { - @Override - public void onNext(HelloReply reply) { - System.out.println("biRequestObserver onNext: " + reply.getMessage()); - } - - @Override - public void onError(Throwable t) { - System.out.println("biResponseObserver onError: " + t.getMessage()); - } - - @Override - public void onCompleted() { - System.out.println("biResponseObserver onCompleted"); - } - }; - System.out.println("Call biRequestObserver"); - StreamObserver biRequestObserver = greeterService.sayHelloBiStream(biResponseObserver); - for (int i = 0; i < 5; i++) { - biRequestObserver.onNext(buildRequest("triple" + i)); - } - biRequestObserver.onCompleted(); - } catch (Throwable t) { - //noinspection CallToPrintStackTrace - t.printStackTrace(); - } - Thread.sleep(2000); - } - - private static HelloRequest buildRequest(String name) { - return HelloRequest.newBuilder().setName(name).build(); - } -} diff --git a/dubbo-demo/dubbo-demo-triple/src/main/java/org/apache/dubbo/demo/consumer/ApiWrapperConsumer.java b/dubbo-demo/dubbo-demo-triple/src/main/java/org/apache/dubbo/demo/consumer/ApiWrapperConsumer.java deleted file mode 100644 index 387f5137d1c..00000000000 --- a/dubbo-demo/dubbo-demo-triple/src/main/java/org/apache/dubbo/demo/consumer/ApiWrapperConsumer.java +++ /dev/null @@ -1,61 +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.demo.consumer; - -import org.apache.dubbo.common.constants.CommonConstants; -import org.apache.dubbo.config.ApplicationConfig; -import org.apache.dubbo.config.ProtocolConfig; -import org.apache.dubbo.config.ReferenceConfig; -import org.apache.dubbo.config.RegistryConfig; -import org.apache.dubbo.config.bootstrap.DubboBootstrap; -import org.apache.dubbo.demo.hello.GreeterWrapperService; -import org.apache.dubbo.demo.hello.HelloReply; -import org.apache.dubbo.demo.hello.HelloRequest; -import org.apache.dubbo.rpc.Constants; - -import java.io.IOException; -import java.util.Collections; - -public class ApiWrapperConsumer { - public static void main(String[] args) throws IOException { - ReferenceConfig referenceConfig = new ReferenceConfig<>(); - referenceConfig.setInterface(GreeterWrapperService.class); - referenceConfig.setCheck(false); - referenceConfig.setProtocol("tri"); - referenceConfig.setLazy(true); - if (args.length > 0 && Constants.HTTP3_KEY.equals(args[0])) { - referenceConfig.setParameters(Collections.singletonMap(Constants.HTTP3_KEY, "true")); - } - - DubboBootstrap bootstrap = DubboBootstrap.getInstance(); - bootstrap - .application(new ApplicationConfig("dubbo-demo-triple-api-wrapper-consumer")) - .registry(new RegistryConfig("zookeeper://127.0.0.1:2181")) - .protocol(new ProtocolConfig(CommonConstants.TRIPLE, -1)) - .reference(referenceConfig) - .start(); - - final GreeterWrapperService greeterWrapperService = referenceConfig.get(); - System.out.println("dubbo referenceConfig started"); - long st = System.currentTimeMillis(); - HelloReply reply = greeterWrapperService.sayHello( - HelloRequest.newBuilder().setName("haha").build()); - // 4MB response - System.out.println("Reply Message:" + reply.getMessage() + " cost:" + (System.currentTimeMillis() - st)); - System.in.read(); - } -} diff --git a/dubbo-demo/dubbo-demo-triple/src/main/java/org/apache/dubbo/demo/provider/ApiProvider.java b/dubbo-demo/dubbo-demo-triple/src/main/java/org/apache/dubbo/demo/provider/ApiProvider.java deleted file mode 100644 index 468319c0883..00000000000 --- a/dubbo-demo/dubbo-demo-triple/src/main/java/org/apache/dubbo/demo/provider/ApiProvider.java +++ /dev/null @@ -1,49 +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.demo.provider; - -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 org.apache.dubbo.config.bootstrap.DubboBootstrap; -import org.apache.dubbo.demo.GreeterServiceImpl; -import org.apache.dubbo.demo.hello.GreeterService; -import org.apache.dubbo.rpc.Constants; - -import java.util.Collections; - -public class ApiProvider { - public static void main(String[] args) { - ServiceConfig serviceConfig = new ServiceConfig<>(); - serviceConfig.setInterface(GreeterService.class); - serviceConfig.setRef(new GreeterServiceImpl()); - if (args.length > 0 && Constants.HTTP3_KEY.equals(args[0])) { - serviceConfig.setParameters(Collections.singletonMap(Constants.HTTP3_KEY, "true")); - } - - DubboBootstrap bootstrap = DubboBootstrap.getInstance(); - bootstrap - .application(new ApplicationConfig("dubbo-demo-triple-api-provider")) - .registry(new RegistryConfig("zookeeper://127.0.0.1:2181")) - .protocol(new ProtocolConfig(CommonConstants.TRIPLE, -1)) - .service(serviceConfig) - .start() - .await(); - } -} diff --git a/dubbo-demo/dubbo-demo-triple/src/main/java/org/apache/dubbo/demo/provider/ApiWrapperProvider.java b/dubbo-demo/dubbo-demo-triple/src/main/java/org/apache/dubbo/demo/provider/ApiWrapperProvider.java deleted file mode 100644 index faeb49c3763..00000000000 --- a/dubbo-demo/dubbo-demo-triple/src/main/java/org/apache/dubbo/demo/provider/ApiWrapperProvider.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.demo.provider; - -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 org.apache.dubbo.config.bootstrap.DubboBootstrap; -import org.apache.dubbo.demo.GreeterWrapperServiceImpl; -import org.apache.dubbo.demo.hello.GreeterWrapperService; -import org.apache.dubbo.rpc.Constants; - -import java.io.IOException; -import java.util.Collections; - -public class ApiWrapperProvider { - public static void main(String[] args) throws IOException { - ServiceConfig serviceConfig = new ServiceConfig<>(); - serviceConfig.setInterface(GreeterWrapperService.class); - serviceConfig.setRef(new GreeterWrapperServiceImpl()); - if (args.length > 0 && Constants.HTTP3_KEY.equals(args[0])) { - serviceConfig.setParameters(Collections.singletonMap(Constants.HTTP3_KEY, "true")); - } - - DubboBootstrap bootstrap = DubboBootstrap.getInstance(); - bootstrap - .application(new ApplicationConfig("dubbo-demo-triple-api-wrapper-provider")) - .registry(new RegistryConfig("zookeeper://127.0.0.1:2181")) - .protocol(new ProtocolConfig(CommonConstants.TRIPLE, -1)) - .service(serviceConfig) - .start() - .await(); - } -} diff --git a/dubbo-demo/dubbo-demo-xml/dubbo-demo-spring-mvc-rest-consumer/pom.xml b/dubbo-demo/dubbo-demo-xml/dubbo-demo-spring-mvc-rest-consumer/pom.xml deleted file mode 100644 index 46cafa00479..00000000000 --- a/dubbo-demo/dubbo-demo-xml/dubbo-demo-spring-mvc-rest-consumer/pom.xml +++ /dev/null @@ -1,146 +0,0 @@ - - - - 4.0.0 - - org.apache.dubbo - dubbo-demo-xml - ${revision} - ../pom.xml - - - dubbo-demo-spring-mvc-rest-consumer - - jar - ${project.artifactId} - Dubbo Spring MVC Rest Consumer Demo - - - true - - - - - org.springframework - spring-context - - - org.springframework - spring-web - - - - org.apache.dubbo - dubbo-registry-multicast - ${project.version} - - - org.apache.dubbo - dubbo-registry-zookeeper - ${project.version} - - - org.apache.dubbo - dubbo-registry-nacos - ${project.version} - - - com.alibaba.nacos - nacos-client - - - org.apache.dubbo - dubbo-configcenter-zookeeper - ${project.version} - - - org.apache.dubbo - dubbo-configcenter-nacos - ${project.version} - - - org.apache.dubbo - dubbo-metadata-report-zookeeper - ${project.version} - - - org.apache.dubbo - dubbo-metadata-report-nacos - ${project.version} - - - org.apache.dubbo - dubbo-rpc-dubbo - ${project.version} - - - org.apache.dubbo - dubbo-config-spring - ${project.version} - - - org.apache.dubbo - dubbo-remoting-netty4 - ${project.version} - - - org.apache.dubbo - dubbo-serialization-hessian2 - ${project.version} - - - org.apache.dubbo - dubbo-serialization-fastjson2 - ${project.version} - - - - org.springframework - spring-test - test - - - - org.apache.dubbo - dubbo-demo-interface - ${project.version} - - - org.apache.logging.log4j - log4j-slf4j-impl - - - - - - - javax.annotation - - [1.11,) - - - - javax.annotation - javax.annotation-api - 1.3.2 - - - - - - diff --git a/dubbo-demo/dubbo-demo-xml/dubbo-demo-spring-mvc-rest-consumer/src/main/java/org/apache/dubbo/demo/rest/api/SpringMvcRestConsumer.java b/dubbo-demo/dubbo-demo-xml/dubbo-demo-spring-mvc-rest-consumer/src/main/java/org/apache/dubbo/demo/rest/api/SpringMvcRestConsumer.java deleted file mode 100644 index e64117cce0a..00000000000 --- a/dubbo-demo/dubbo-demo-xml/dubbo-demo-spring-mvc-rest-consumer/src/main/java/org/apache/dubbo/demo/rest/api/SpringMvcRestConsumer.java +++ /dev/null @@ -1,74 +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.demo.rest.api; - -import java.util.Arrays; - -import org.springframework.context.support.ClassPathXmlApplicationContext; -import org.springframework.util.LinkedMultiValueMap; -import org.springframework.util.MultiValueMap; -import po.User; - -public class SpringMvcRestConsumer { - - public static void main(String[] args) { - consumerService(); - } - - public static void consumerService() { - ClassPathXmlApplicationContext context = - new ClassPathXmlApplicationContext(new String[] {"spring/rest-consumer.xml"}); - context.start(); - System.out.println("spring mvc rest consumer start"); - springMvcRestDemoServiceTest(context); - System.out.println("spring mvc rest consumer test success"); - } - - private static void springMvcRestDemoServiceTest(ClassPathXmlApplicationContext context) { - SpringRestDemoService springRestDemoService = - context.getBean("springRestDemoService", SpringRestDemoService.class); - String hello = springRestDemoService.sayHello("hello"); - assertEquals("Hello, hello", hello); - Integer result = springRestDemoService.primitiveInt(1, 2); - Long resultLong = springRestDemoService.primitiveLong(1, 2l); - long resultByte = springRestDemoService.primitiveByte((byte) 1, 2l); - long resultShort = springRestDemoService.primitiveShort((short) 1, 2l, 1); - - assertEquals(result, 3); - assertEquals(resultShort, 3l); - assertEquals(resultLong, 3l); - assertEquals(resultByte, 3l); - - assertEquals(Long.valueOf(1l), springRestDemoService.testFormBody(1l)); - - MultiValueMap forms = new LinkedMultiValueMap<>(); - forms.put("form", Arrays.asList("F1")); - - assertEquals(Arrays.asList("F1"), springRestDemoService.testMapForm(forms)); - assertEquals(User.getInstance(), springRestDemoService.testJavaBeanBody(User.getInstance())); - } - - private static void assertEquals(Object returnStr, Object exception) { - boolean equal = returnStr != null && returnStr.equals(exception); - - if (equal) { - return; - } else { - throw new RuntimeException(); - } - } -} diff --git a/dubbo-demo/dubbo-demo-xml/dubbo-demo-spring-mvc-rest-consumer/src/main/java/org/apache/dubbo/demo/rest/api/config/DubboConfig.java b/dubbo-demo/dubbo-demo-xml/dubbo-demo-spring-mvc-rest-consumer/src/main/java/org/apache/dubbo/demo/rest/api/config/DubboConfig.java deleted file mode 100644 index 0d9eab4ecb0..00000000000 --- a/dubbo-demo/dubbo-demo-xml/dubbo-demo-spring-mvc-rest-consumer/src/main/java/org/apache/dubbo/demo/rest/api/config/DubboConfig.java +++ /dev/null @@ -1,22 +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.demo.rest.api.config; - -import org.apache.dubbo.config.spring.context.annotation.DubboComponentScan; - -@DubboComponentScan("org.apache.dubbo.demo.rest") -public class DubboConfig {} diff --git a/dubbo-demo/dubbo-demo-xml/dubbo-demo-spring-mvc-rest-consumer/src/main/java/org/apache/dubbo/demo/rest/api/consumer/SpringRestDemoServiceConsumer.java b/dubbo-demo/dubbo-demo-xml/dubbo-demo-spring-mvc-rest-consumer/src/main/java/org/apache/dubbo/demo/rest/api/consumer/SpringRestDemoServiceConsumer.java deleted file mode 100644 index fbedf5decde..00000000000 --- a/dubbo-demo/dubbo-demo-xml/dubbo-demo-spring-mvc-rest-consumer/src/main/java/org/apache/dubbo/demo/rest/api/consumer/SpringRestDemoServiceConsumer.java +++ /dev/null @@ -1,28 +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.demo.rest.api.consumer; - -import org.apache.dubbo.config.annotation.DubboReference; -import org.apache.dubbo.demo.rest.api.SpringRestDemoService; - -import org.springframework.stereotype.Component; - -@Component -public class SpringRestDemoServiceConsumer { - @DubboReference(interfaceClass = SpringRestDemoService.class) - SpringRestDemoService springRestDemoService; -} diff --git a/dubbo-demo/dubbo-demo-xml/dubbo-demo-spring-mvc-rest-consumer/src/main/resources/log4j2.xml b/dubbo-demo/dubbo-demo-xml/dubbo-demo-spring-mvc-rest-consumer/src/main/resources/log4j2.xml deleted file mode 100644 index 69e1321d220..00000000000 --- a/dubbo-demo/dubbo-demo-xml/dubbo-demo-spring-mvc-rest-consumer/src/main/resources/log4j2.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - diff --git a/dubbo-demo/dubbo-demo-xml/dubbo-demo-spring-mvc-rest-consumer/src/main/resources/spring/rest-consumer.xml b/dubbo-demo/dubbo-demo-xml/dubbo-demo-spring-mvc-rest-consumer/src/main/resources/spring/rest-consumer.xml deleted file mode 100644 index b0288791606..00000000000 --- a/dubbo-demo/dubbo-demo-xml/dubbo-demo-spring-mvc-rest-consumer/src/main/resources/spring/rest-consumer.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/dubbo-demo/dubbo-demo-xml/dubbo-demo-spring-mvc-rest-provider/pom.xml b/dubbo-demo/dubbo-demo-xml/dubbo-demo-spring-mvc-rest-provider/pom.xml deleted file mode 100644 index aba2a7387a3..00000000000 --- a/dubbo-demo/dubbo-demo-xml/dubbo-demo-spring-mvc-rest-provider/pom.xml +++ /dev/null @@ -1,146 +0,0 @@ - - - - 4.0.0 - - org.apache.dubbo - dubbo-demo-xml - ${revision} - ../pom.xml - - - dubbo-demo-spring-mvc-rest-provider - - jar - ${project.artifactId} - Dubbo Spring MVC Rest Provider Demo - - - true - - - - - org.springframework - spring-context - - - org.springframework - spring-web - - - - org.apache.dubbo - dubbo-registry-multicast - ${project.version} - - - org.apache.dubbo - dubbo-registry-zookeeper - ${project.version} - - - org.apache.dubbo - dubbo-registry-nacos - ${project.version} - - - com.alibaba.nacos - nacos-client - - - org.apache.dubbo - dubbo-configcenter-zookeeper - ${project.version} - - - org.apache.dubbo - dubbo-configcenter-nacos - ${project.version} - - - org.apache.dubbo - dubbo-metadata-report-zookeeper - ${project.version} - - - org.apache.dubbo - dubbo-metadata-report-nacos - ${project.version} - - - org.apache.dubbo - dubbo-rpc-dubbo - ${project.version} - - - org.apache.dubbo - dubbo-config-spring - ${project.version} - - - org.apache.dubbo - dubbo-remoting-netty4 - ${project.version} - - - org.apache.dubbo - dubbo-serialization-hessian2 - ${project.version} - - - org.apache.dubbo - dubbo-serialization-fastjson2 - ${project.version} - - - - org.springframework - spring-test - test - - - - org.apache.dubbo - dubbo-demo-interface - ${project.version} - - - org.apache.logging.log4j - log4j-slf4j-impl - - - - - - - javax.annotation - - [1.11,) - - - - javax.annotation - javax.annotation-api - 1.3.2 - - - - - - diff --git a/dubbo-demo/dubbo-demo-xml/dubbo-demo-spring-mvc-rest-provider/src/main/java/org/apache/dubbo/demo/rest/api/config/DubboConfig.java b/dubbo-demo/dubbo-demo-xml/dubbo-demo-spring-mvc-rest-provider/src/main/java/org/apache/dubbo/demo/rest/api/config/DubboConfig.java deleted file mode 100644 index 0d9eab4ecb0..00000000000 --- a/dubbo-demo/dubbo-demo-xml/dubbo-demo-spring-mvc-rest-provider/src/main/java/org/apache/dubbo/demo/rest/api/config/DubboConfig.java +++ /dev/null @@ -1,22 +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.demo.rest.api.config; - -import org.apache.dubbo.config.spring.context.annotation.DubboComponentScan; - -@DubboComponentScan("org.apache.dubbo.demo.rest") -public class DubboConfig {} diff --git a/dubbo-demo/dubbo-demo-xml/dubbo-demo-spring-mvc-rest-provider/src/main/java/org/apache/dubbo/demo/rest/api/impl/SpringRestDemoServiceImpl.java b/dubbo-demo/dubbo-demo-xml/dubbo-demo-spring-mvc-rest-provider/src/main/java/org/apache/dubbo/demo/rest/api/impl/SpringRestDemoServiceImpl.java deleted file mode 100644 index 6cdaede32f0..00000000000 --- a/dubbo-demo/dubbo-demo-xml/dubbo-demo-spring-mvc-rest-provider/src/main/java/org/apache/dubbo/demo/rest/api/impl/SpringRestDemoServiceImpl.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.demo.rest.api.impl; - -import org.apache.dubbo.config.annotation.DubboService; -import org.apache.dubbo.demo.rest.api.SpringRestDemoService; - -import java.util.List; -import java.util.Map; - -import org.springframework.util.MultiValueMap; -import po.User; - -@DubboService(interfaceClass = SpringRestDemoService.class, protocol = "rest") -public class SpringRestDemoServiceImpl implements SpringRestDemoService { - - @Override - public String sayHello(String name) { - return "Hello, " + name; - } - - @Override - public Long testFormBody(Long number) { - return number; - } - - @Override - public User testJavaBeanBody(User user) { - return user; - } - - @Override - public int primitiveInt(int a, int b) { - return a + b; - } - - @Override - public long primitiveLong(long a, Long b) { - return a + b; - } - - @Override - public long primitiveByte(byte a, Long b) { - return a + b; - } - - @Override - public long primitiveShort(short a, Long b, int c) { - return a + b; - } - - @Override - public String testMapParam(Map params) { - return params.get("param"); - } - - @Override - public String testMapHeader(Map headers) { - return headers.get("header"); - } - - @Override - public List testMapForm(MultiValueMap params) { - return params.get("form"); - } - - @Override - public int headerInt(int header) { - return header; - } - - @Override - public Integer hello(Integer a, Integer b) { - return a + b; - } - - @Override - public String error() { - throw new RuntimeException("test error"); - } -} diff --git a/dubbo-demo/dubbo-demo-xml/dubbo-demo-spring-mvc-rest-provider/src/main/resources/log4j2.xml b/dubbo-demo/dubbo-demo-xml/dubbo-demo-spring-mvc-rest-provider/src/main/resources/log4j2.xml deleted file mode 100644 index 69e1321d220..00000000000 --- a/dubbo-demo/dubbo-demo-xml/dubbo-demo-spring-mvc-rest-provider/src/main/resources/log4j2.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - diff --git a/dubbo-demo/dubbo-demo-xml/dubbo-demo-spring-mvc-rest-provider/src/main/resources/spring/rest-provider.xml b/dubbo-demo/dubbo-demo-xml/dubbo-demo-spring-mvc-rest-provider/src/main/resources/spring/rest-provider.xml deleted file mode 100644 index 8c6be976f72..00000000000 --- a/dubbo-demo/dubbo-demo-xml/dubbo-demo-spring-mvc-rest-provider/src/main/resources/spring/rest-provider.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-consumer/pom.xml b/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-consumer/pom.xml deleted file mode 100644 index cbd5e6d60c3..00000000000 --- a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-consumer/pom.xml +++ /dev/null @@ -1,113 +0,0 @@ - - - - 4.0.0 - - org.apache.dubbo - dubbo-demo-xml - ${revision} - ../pom.xml - - dubbo-demo-xml-consumer - jar - ${project.artifactId} - The demo consumer module of dubbo project - - true - - - - org.apache.dubbo - dubbo-demo-interface - ${project.parent.version} - - - org.apache.dubbo - dubbo-registry-multicast - ${project.version} - - - org.apache.dubbo - dubbo-registry-nacos - ${project.version} - - - com.alibaba.nacos - nacos-client - - - org.apache.dubbo - dubbo-registry-zookeeper - ${project.version} - - - org.apache.dubbo - dubbo-configcenter-zookeeper - ${project.version} - - - org.apache.dubbo - dubbo-configcenter-nacos - ${project.version} - - - org.apache.dubbo - dubbo-metadata-report-zookeeper - ${project.version} - - - org.apache.dubbo - dubbo-metadata-report-nacos - ${project.version} - - - org.apache.dubbo - dubbo-config-spring - ${project.version} - - - org.apache.dubbo - dubbo-rpc-dubbo - ${project.version} - - - org.apache.dubbo - dubbo-remoting-netty4 - ${project.version} - - - org.apache.dubbo - dubbo-serialization-hessian2 - ${project.version} - - - org.apache.dubbo - dubbo-serialization-fastjson2 - ${project.version} - - - org.apache.dubbo - dubbo-rpc-triple - ${project.version} - - - org.apache.logging.log4j - log4j-slf4j-impl - - - diff --git a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-consumer/src/main/java/org/apache/dubbo/demo/consumer/Application.java b/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-consumer/src/main/java/org/apache/dubbo/demo/consumer/Application.java deleted file mode 100644 index 2960b8d50e9..00000000000 --- a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-consumer/src/main/java/org/apache/dubbo/demo/consumer/Application.java +++ /dev/null @@ -1,106 +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.demo.consumer; - -import org.apache.dubbo.demo.DemoService; -import org.apache.dubbo.demo.GreetingService; -import org.apache.dubbo.demo.RestDemoService; -import org.apache.dubbo.demo.TripleService; - -import javax.ws.rs.core.MultivaluedHashMap; -import javax.ws.rs.core.MultivaluedMap; - -import java.util.Arrays; -import java.util.concurrent.CompletableFuture; - -import org.springframework.context.support.ClassPathXmlApplicationContext; -import po.TestPO; - -public class Application { - /** - * In order to make sure multicast registry works, need to specify '-Djava.net.preferIPv4Stack=true' before - * launch the application - */ - public static void main(String[] args) throws Exception { - ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/dubbo-consumer.xml"); - context.start(); - DemoService demoService = context.getBean("demoService", DemoService.class); - GreetingService greetingService = context.getBean("greetingService", GreetingService.class); - RestDemoService restDemoService = context.getBean("restDemoService", RestDemoService.class); - TripleService tripleService = context.getBean("tripleService", TripleService.class); - - new Thread(() -> { - while (true) { - try { - String greetings = greetingService.hello(); - System.out.println(greetings + " from separated thread."); - } catch (Exception e) { - // e.printStackTrace(); - } - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - } - } - }) - .start(); - - new Thread(() -> { - while (true) { - try { - Object restResult = restDemoService.sayHello("rest"); - System.out.println(restResult + " from separated thread."); - restResult = restDemoService.testBody5(TestPO.getInstance()); - System.out.println(restResult + " from separated thread."); - - restResult = restDemoService.hello(1, 2); - System.out.println(restResult + " from separated thread."); - - String form1 = restDemoService.testForm1("form1"); - System.out.println(form1); - - MultivaluedHashMap multivaluedHashMap = new MultivaluedHashMap(); - multivaluedHashMap.put("1", Arrays.asList("1")); - multivaluedHashMap.put("2", Arrays.asList("2")); - MultivaluedMap form2 = restDemoService.testForm2(multivaluedHashMap); - System.out.println(form2); - } catch (Exception e) { - e.printStackTrace(); - } - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - } - } - }) - .start(); - - while (true) { - try { - CompletableFuture hello = demoService.sayHelloAsync("world"); - System.out.println("result: " + hello.get()); - - String greetings = greetingService.hello(); - System.out.println("result: " + greetings); - } catch (Exception e) { - // e.printStackTrace(); - } - - Thread.sleep(5000); - } - } -} diff --git a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-consumer/src/main/resources/dubbo-migration.yaml b/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-consumer/src/main/resources/dubbo-migration.yaml deleted file mode 100644 index 3f55a0bf360..00000000000 --- a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-consumer/src/main/resources/dubbo-migration.yaml +++ /dev/null @@ -1,22 +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. -# -# - -key: demo-consumer -step: APPLICATION_FIRST -threshold: 0.1 \ No newline at end of file diff --git a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-consumer/src/main/resources/dubbo.properties b/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-consumer/src/main/resources/dubbo.properties deleted file mode 100644 index 8c3cb2559c7..00000000000 --- a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-consumer/src/main/resources/dubbo.properties +++ /dev/null @@ -1 +0,0 @@ -dubbo.application.qos.port=33333 diff --git a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-consumer/src/main/resources/log4j2.xml b/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-consumer/src/main/resources/log4j2.xml deleted file mode 100644 index 69e1321d220..00000000000 --- a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-consumer/src/main/resources/log4j2.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - diff --git a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-consumer/src/main/resources/spring/dubbo-consumer.xml b/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-consumer/src/main/resources/spring/dubbo-consumer.xml deleted file mode 100644 index 0767baf39ab..00000000000 --- a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-consumer/src/main/resources/spring/dubbo-consumer.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-provider/pom.xml b/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-provider/pom.xml deleted file mode 100644 index 2869a1dbff6..00000000000 --- a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-provider/pom.xml +++ /dev/null @@ -1,120 +0,0 @@ - - - - 4.0.0 - - org.apache.dubbo - dubbo-demo-xml - ${revision} - ../pom.xml - - dubbo-demo-xml-provider - jar - ${project.artifactId} - The demo provider module of dubbo project - - - true - - - - - org.apache.dubbo - dubbo-demo-interface - ${project.parent.version} - - - org.apache.dubbo - dubbo-registry-multicast - ${project.version} - - - org.apache.dubbo - dubbo-registry-zookeeper - ${project.version} - - - org.apache.dubbo - dubbo-registry-nacos - ${project.version} - - - com.alibaba.nacos - nacos-client - - - org.apache.dubbo - dubbo-configcenter-zookeeper - ${project.version} - - - org.apache.dubbo - dubbo-configcenter-nacos - ${project.version} - - - org.apache.dubbo - dubbo-metadata-report-zookeeper - ${project.version} - - - org.apache.dubbo - dubbo-metadata-report-nacos - ${project.version} - - - org.apache.dubbo - dubbo-rpc-dubbo - ${project.version} - - - org.apache.dubbo - dubbo-config-spring - ${project.version} - - - org.apache.dubbo - dubbo-remoting-netty4 - ${project.version} - - - org.apache.dubbo - dubbo-serialization-hessian2 - ${project.version} - - - org.apache.dubbo - dubbo-serialization-fastjson2 - ${project.version} - - - org.apache.dubbo - dubbo-rpc-triple - ${project.version} - - - org.apache.dubbo - dubbo-qos - ${project.version} - - - org.apache.logging.log4j - log4j-slf4j-impl - - - diff --git a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-provider/src/main/java/org/apache/dubbo/demo/provider/Application.java b/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-provider/src/main/java/org/apache/dubbo/demo/provider/Application.java deleted file mode 100644 index d1ab5be7489..00000000000 --- a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-provider/src/main/java/org/apache/dubbo/demo/provider/Application.java +++ /dev/null @@ -1,27 +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.demo.provider; - -import org.springframework.context.support.ClassPathXmlApplicationContext; - -public class Application { - public static void main(String[] args) throws Exception { - ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/dubbo-provider.xml"); - context.start(); - System.in.read(); - } -} diff --git a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-provider/src/main/java/org/apache/dubbo/demo/provider/DemoServiceImpl.java b/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-provider/src/main/java/org/apache/dubbo/demo/provider/DemoServiceImpl.java deleted file mode 100644 index 3467051454e..00000000000 --- a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-provider/src/main/java/org/apache/dubbo/demo/provider/DemoServiceImpl.java +++ /dev/null @@ -1,55 +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.demo.provider; - -import org.apache.dubbo.demo.DemoService; -import org.apache.dubbo.rpc.RpcContext; - -import java.util.concurrent.CompletableFuture; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class DemoServiceImpl implements DemoService { - private static final Logger logger = LoggerFactory.getLogger(DemoServiceImpl.class); - - @Override - public String sayHello(String name) { - logger.info("Hello " + name + ", request from consumer: " - + RpcContext.getServiceContext().getRemoteAddress()); - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - return "Hello " + name + ", response from provider: " - + RpcContext.getServiceContext().getLocalAddress(); - } - - @Override - public CompletableFuture sayHelloAsync(String name) { - CompletableFuture cf = CompletableFuture.supplyAsync(() -> { - // try { - // Thread.sleep(1000); - // } catch (InterruptedException e) { - // e.printStackTrace(); - // } - return "async result"; - }); - return cf; - } -} diff --git a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-provider/src/main/java/org/apache/dubbo/demo/provider/GreetingServiceImpl.java b/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-provider/src/main/java/org/apache/dubbo/demo/provider/GreetingServiceImpl.java deleted file mode 100644 index cc1b5de4139..00000000000 --- a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-provider/src/main/java/org/apache/dubbo/demo/provider/GreetingServiceImpl.java +++ /dev/null @@ -1,29 +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.demo.provider; - -import org.apache.dubbo.demo.GreetingService; - -/** - * - */ -public class GreetingServiceImpl implements GreetingService { - @Override - public String hello() { - return "Greetings!"; - } -} diff --git a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-provider/src/main/java/org/apache/dubbo/demo/provider/RestDemoServiceImpl.java b/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-provider/src/main/java/org/apache/dubbo/demo/provider/RestDemoServiceImpl.java deleted file mode 100644 index 37155fa436e..00000000000 --- a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-provider/src/main/java/org/apache/dubbo/demo/provider/RestDemoServiceImpl.java +++ /dev/null @@ -1,93 +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.demo.provider; - -import org.apache.dubbo.demo.RestDemoService; -import org.apache.dubbo.rpc.RpcContext; - -import javax.ws.rs.core.MultivaluedMap; - -import java.util.Map; - -import po.TestPO; - -public class RestDemoServiceImpl implements RestDemoService { - private static Map context; - private boolean called; - - public String sayHello(String name) { - called = true; - return "Hello, " + name; - } - - public boolean isCalled() { - return called; - } - - @Override - public Integer hello(Integer a, Integer b) { - context = RpcContext.getServerAttachment().getObjectAttachments(); - return a + b; - } - - @Override - public String error() { - throw new RuntimeException(); - } - - public static Map getAttachments() { - return context; - } - - @Override - public String getRemoteApplicationName() { - return RpcContext.getServiceContext().getRemoteApplicationName(); - } - - @Override - public Integer testBody(Integer b) { - return b; - } - - @Override - public String testBody2(String b) { - return b; - } - - @Override - public Boolean testBody2(Boolean b) { - return b; - } - - @Override - public TestPO testBody2(TestPO b) { - return b; - } - - @Override - public TestPO testBody5(TestPO testPO) { - return testPO; - } - - public String testForm1(String test) { - return test; - } - - public MultivaluedMap testForm2(MultivaluedMap map) { - return map; - } -} diff --git a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-provider/src/main/java/org/apache/dubbo/demo/provider/TripleServiceImpl.java b/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-provider/src/main/java/org/apache/dubbo/demo/provider/TripleServiceImpl.java deleted file mode 100644 index f1861454d1b..00000000000 --- a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-provider/src/main/java/org/apache/dubbo/demo/provider/TripleServiceImpl.java +++ /dev/null @@ -1,27 +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.demo.provider; - -import org.apache.dubbo.demo.TripleService; - -public class TripleServiceImpl implements TripleService { - - @Override - public String hello() { - return "Triple!"; - } -} diff --git a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-provider/src/main/resources/dubbo.properties b/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-provider/src/main/resources/dubbo.properties deleted file mode 100644 index dde68cbdf04..00000000000 --- a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-provider/src/main/resources/dubbo.properties +++ /dev/null @@ -1,3 +0,0 @@ -dubbo.application.qos-enable=true -dubbo.application.qos-port=22222 -dubbo.application.qos-accept-foreign-ip=true diff --git a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-provider/src/main/resources/log4j2.xml b/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-provider/src/main/resources/log4j2.xml deleted file mode 100644 index 69e1321d220..00000000000 --- a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-provider/src/main/resources/log4j2.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - diff --git a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-provider/src/main/resources/spring/dubbo-provider.xml b/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-provider/src/main/resources/spring/dubbo-provider.xml deleted file mode 100644 index ad402bc0683..00000000000 --- a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-provider/src/main/resources/spring/dubbo-provider.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dubbo-demo/dubbo-demo-xml/pom.xml b/dubbo-demo/dubbo-demo-xml/pom.xml deleted file mode 100644 index 83947141022..00000000000 --- a/dubbo-demo/dubbo-demo-xml/pom.xml +++ /dev/null @@ -1,61 +0,0 @@ - - - - 4.0.0 - - org.apache.dubbo - dubbo-parent - ${revision} - ../../pom.xml - - - dubbo-demo-xml - pom - - - dubbo-demo-xml-provider - dubbo-demo-xml-consumer - dubbo-demo-spring-mvc-rest-consumer - dubbo-demo-spring-mvc-rest-provider - - - - true - 2.7.18 - - - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring-boot-maven-plugin.version} - - - - repackage - - - - - - - - diff --git a/dubbo-dependencies-bom/pom.xml b/dubbo-dependencies-bom/pom.xml index 60e1f6a1f5a..919a07c6b1e 100644 --- a/dubbo-dependencies-bom/pom.xml +++ b/dubbo-dependencies-bom/pom.xml @@ -193,7 +193,7 @@ 1.15.1 0.16.0 - 3.3.2-SNAPSHOT + 3.3.3-SNAPSHOT diff --git a/dubbo-distribution/dubbo-bom/pom.xml b/dubbo-distribution/dubbo-bom/pom.xml index 4f007d77795..ea2c7712c1f 100644 --- a/dubbo-distribution/dubbo-bom/pom.xml +++ b/dubbo-distribution/dubbo-bom/pom.xml @@ -473,11 +473,6 @@ ${project.version} pom - - org.apache.dubbo - dubbo-spring-boot-actuator-autoconfigure - ${project.version} - org.apache.dubbo dubbo-spring-boot-autoconfigure-compatible diff --git a/dubbo-plugin/dubbo-rest-jaxrs/pom.xml b/dubbo-plugin/dubbo-rest-jaxrs/pom.xml index 5e6d2c8e36e..fcfc57ba658 100644 --- a/dubbo-plugin/dubbo-rest-jaxrs/pom.xml +++ b/dubbo-plugin/dubbo-rest-jaxrs/pom.xml @@ -113,9 +113,9 @@ rpc-rest-test - org.apache.dubbo + org.apache.dubbo.extensions dubbo-rpc-rest - 3.3.2-SNAPSHOT + 3.3.0 test diff --git a/dubbo-plugin/dubbo-rest-spring/pom.xml b/dubbo-plugin/dubbo-rest-spring/pom.xml index d40cbc93d0a..86f9ed0ab2e 100644 --- a/dubbo-plugin/dubbo-rest-spring/pom.xml +++ b/dubbo-plugin/dubbo-rest-spring/pom.xml @@ -122,9 +122,9 @@ rpc-rest-test - org.apache.dubbo + org.apache.dubbo.extensions dubbo-rpc-rest - 3.3.2-SNAPSHOT + 3.3.0 test diff --git a/dubbo-plugin/dubbo-triple-websocket/pom.xml b/dubbo-plugin/dubbo-triple-websocket/pom.xml index c7f465a66ad..6c7533f6508 100644 --- a/dubbo-plugin/dubbo-triple-websocket/pom.xml +++ b/dubbo-plugin/dubbo-triple-websocket/pom.xml @@ -19,9 +19,9 @@ 4.0.0 org.apache.dubbo - dubbo-plugin + dubbo-parent ${revision} - ../pom.xml + ../../pom.xml dubbo-triple-websocket diff --git a/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/util/CuratorFrameworkUtils.java b/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/util/CuratorFrameworkUtils.java index c373e2983ad..19da7748aff 100644 --- a/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/util/CuratorFrameworkUtils.java +++ b/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/util/CuratorFrameworkUtils.java @@ -45,6 +45,7 @@ import static org.apache.curator.x.discovery.ServiceInstance.builder; import static org.apache.dubbo.common.constants.CommonConstants.PATH_SEPARATOR; +import static org.apache.dubbo.common.constants.CommonConstants.SESSION_KEY; import static org.apache.dubbo.common.constants.CommonConstants.ZOOKEEPER_ENSEMBLE_TRACKER_KEY; import static org.apache.dubbo.registry.zookeeper.ZookeeperServiceDiscovery.DEFAULT_GROUP; import static org.apache.dubbo.registry.zookeeper.util.CuratorFrameworkParams.BASE_SLEEP_TIME; @@ -62,6 +63,8 @@ */ public abstract class CuratorFrameworkUtils { + protected static int DEFAULT_SESSION_TIMEOUT_MS = 60 * 1000; + public static ServiceDiscovery buildServiceDiscovery( CuratorFramework curatorFramework, String basePath) { return ServiceDiscoveryBuilder.builder(ZookeeperInstance.class) @@ -72,8 +75,10 @@ public static ServiceDiscovery buildServiceDiscovery( public static CuratorFramework buildCuratorFramework(URL connectionURL, ZookeeperServiceDiscovery serviceDiscovery) throws Exception { + int sessionTimeoutMs = connectionURL.getParameter(SESSION_KEY, DEFAULT_SESSION_TIMEOUT_MS); CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder() .connectString(connectionURL.getBackupAddress()) + .sessionTimeoutMs(sessionTimeoutMs) .retryPolicy(buildRetryPolicy(connectionURL)); try { // use reflect to check method exist to compatibility with curator4, can remove in dubbo3.3 and direct call diff --git a/dubbo-remoting/dubbo-remoting-http12/src/main/java/org/apache/dubbo/remoting/http12/AbstractServerHttpChannelObserver.java b/dubbo-remoting/dubbo-remoting-http12/src/main/java/org/apache/dubbo/remoting/http12/AbstractServerHttpChannelObserver.java index 1c7cf43cc47..c1edd74d504 100644 --- a/dubbo-remoting/dubbo-remoting-http12/src/main/java/org/apache/dubbo/remoting/http12/AbstractServerHttpChannelObserver.java +++ b/dubbo-remoting/dubbo-remoting-http12/src/main/java/org/apache/dubbo/remoting/http12/AbstractServerHttpChannelObserver.java @@ -96,7 +96,14 @@ public final void onNext(Object data) { doOnNext(data); } catch (Throwable t) { LOGGER.warn(INTERNAL_ERROR, "", "", "Error while doOnNext", t); - onError(t); + Throwable throwable = t; + try { + doOnError(throwable); + } catch (Throwable t1) { + LOGGER.warn(INTERNAL_ERROR, "", "", "Error while doOnError, original error: " + throwable, t1); + throwable = t1; + } + onCompleted(throwable); } } @@ -105,7 +112,6 @@ public final void onError(Throwable throwable) { if (closed) { return; } - try { throwable = customizeError(throwable); if (throwable == null) { @@ -122,7 +128,6 @@ public final void onError(Throwable throwable) { LOGGER.warn(INTERNAL_ERROR, "", "", "Error while doOnError, original error: " + throwable, t); throwable = t; } - onCompleted(throwable); } diff --git a/dubbo-remoting/dubbo-remoting-http12/src/main/java/org/apache/dubbo/remoting/http12/HttpUtils.java b/dubbo-remoting/dubbo-remoting-http12/src/main/java/org/apache/dubbo/remoting/http12/HttpUtils.java index 311d5bcb71d..7ffde474662 100644 --- a/dubbo-remoting/dubbo-remoting-http12/src/main/java/org/apache/dubbo/remoting/http12/HttpUtils.java +++ b/dubbo-remoting/dubbo-remoting-http12/src/main/java/org/apache/dubbo/remoting/http12/HttpUtils.java @@ -94,7 +94,7 @@ public static String encodeCookie(HttpCookie cookie) { public static List parseAccept(String header) { if (header == null) { - return Collections.emptyList(); + return new ArrayList<>(); } List> mediaTypes = new ArrayList<>(); for (String item : StringUtils.tokenize(header, ',')) { @@ -126,7 +126,7 @@ public static float parseQuality(String expr, int index) { public static List parseAcceptLanguage(String header) { List> locales = new ArrayList<>(); if (header == null) { - return Collections.emptyList(); + return new ArrayList<>(); } for (String item : StringUtils.tokenize(header, ',')) { String[] pair = StringUtils.tokenize(item, ';'); @@ -138,7 +138,7 @@ public static List parseAcceptLanguage(String header) { public static List parseContentLanguage(String header) { List locales = new ArrayList<>(); if (header == null) { - return Collections.emptyList(); + return new ArrayList<>(); } for (String item : StringUtils.tokenize(header, ',')) { locales.add(parseLocale(item)); diff --git a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/h3/negotiation/NegotiateClientCall.java b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/h3/negotiation/NegotiateClientCall.java index 54db142391b..2b3f629b814 100644 --- a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/h3/negotiation/NegotiateClientCall.java +++ b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/h3/negotiation/NegotiateClientCall.java @@ -59,6 +59,10 @@ public CompletableFuture start(URL url) { CompletableFuture future = new CompletableFuture<>(); try { Channel channel = connectionClient.getChannel(true); + if (channel == null) { + future.completeExceptionally(new IllegalStateException("Channel is null")); + return future; + } Http2StreamChannelBootstrap bootstrap = new Http2StreamChannelBootstrap(channel); bootstrap.handler(new ChannelInboundHandlerAdapter() { @Override @@ -112,9 +116,6 @@ private static final class Listener implements H2TransportListener { @Override public void onHeader(Http2Headers headers, boolean endStream) { - if (endStream) { - return; - } CharSequence line = headers.status(); if (line != null) { HttpResponseStatus status = HttpResponseStatus.parseLine(line); @@ -124,6 +125,9 @@ public void onHeader(Http2Headers headers, boolean endStream) { return; } } + if (endStream) { + return; + } executor.execute(() -> future.completeExceptionally(new RuntimeException("Status: " + line))); } diff --git a/dubbo-test/dubbo-dependencies-all/pom.xml b/dubbo-test/dubbo-dependencies-all/pom.xml index 87f11cb57c8..dd9b862abde 100644 --- a/dubbo-test/dubbo-dependencies-all/pom.xml +++ b/dubbo-test/dubbo-dependencies-all/pom.xml @@ -382,11 +382,6 @@ dubbo-spring-boot-autoconfigure ${project.version} - - org.apache.dubbo - dubbo-spring-boot-actuator-autoconfigure - ${project.version} - org.apache.dubbo dubbo-spring-boot-autoconfigure-compatible diff --git a/pom.xml b/pom.xml index 31b6121d3ec..5a4ff4d9125 100644 --- a/pom.xml +++ b/pom.xml @@ -79,6 +79,7 @@ dubbo-rpc dubbo-cluster dubbo-registry + dubbo-configcenter dubbo-config dubbo-serialization dubbo-compatible @@ -106,14 +107,10 @@ dubbo-plugin/dubbo-rest-jaxrs dubbo-plugin/dubbo-rest-spring dubbo-plugin/dubbo-triple-servlet - dubbo-demo/dubbo-demo-interface - dubbo-demo/dubbo-demo-xml - dubbo-demo/dubbo-demo-annotation + dubbo-plugin/dubbo-triple-websocket dubbo-demo/dubbo-demo-api - dubbo-demo/dubbo-demo-generic-call - dubbo-demo/dubbo-demo-triple - dubbo-demo/dubbo-demo-native dubbo-demo/dubbo-demo-spring-boot + dubbo-demo/dubbo-demo-spring-boot-idl @@ -175,7 +172,7 @@ 2.43.0 1.0.0 2.38.0 - 3.3.2-SNAPSHOT + 3.3.3-SNAPSHOT