This is an automated email from the ASF dual-hosted git repository.
liujun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-samples.git
The following commit(s) were added to refs/heads/master by this push:
new 26917a85 feat: Support extensibility filter task (#717)
26917a85 is described below
commit 26917a85e7bae67a8c53e19ab7abf0274e4ddfde
Author: Pin Xiong <[email protected]>
AuthorDate: Wed Feb 1 00:05:45 2023 +0800
feat: Support extensibility filter task (#717)
---
10-task/dubbo-samples-extensibility/deploy/All.yml | 137 +++++++++++++++++++++
.../deploy/Namespace.yml | 25 ++++
.../deploy/filter/Deployment.yml | 65 ++++++++++
.../deploy/nacos/Deployment.yml | 72 +++++++++++
.../pom.xml | 26 ++--
.../filter/api/ExtensibilityFilterService.java | 22 ++++
.../pom.xml | 108 ++++++++++++++++
.../ExtensibilityFilterConsumerApplication.java | 27 +---
.../consumer/ExtensibilityFilterConsumerTask.java | 33 ++---
.../src/main/resources/application.properties | 24 ++++
.../pom.xml | 107 ++++++++++++++++
.../filter/provider/AppendedFilter.java | 37 ++++++
.../ExtensibilityFilterProviderApplication.java | 25 +---
.../provider/ExtensibilityFilterServiceImpl.java | 29 +++++
.../META-INF/dubbo/org.apache.dubbo.rpc.Filter | 1 +
.../src/main/resources/application.properties | 30 +++++
10-task/{ => dubbo-samples-extensibility}/pom.xml | 19 +--
.../dubbo/samples/detail/DetailServiceImpl.java | 1 -
10-task/pom.xml | 1 +
.../dubbo/samples/seata/AccountServiceImpl.java | 2 -
.../dubbo/samples/seata/BusinessServiceImpl.java | 1 -
.../dubbo/samples/seata/OrderApplication.java | 4 -
22 files changed, 701 insertions(+), 95 deletions(-)
diff --git a/10-task/dubbo-samples-extensibility/deploy/All.yml
b/10-task/dubbo-samples-extensibility/deploy/All.yml
new file mode 100644
index 00000000..d49c8b92
--- /dev/null
+++ b/10-task/dubbo-samples-extensibility/deploy/All.yml
@@ -0,0 +1,137 @@
+# 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.
+
+# Namespace
+apiVersion: v1
+kind: Namespace
+metadata:
+ name: dubbo-demo
+---
+apiVersion: v1
+kind: Namespace
+metadata:
+ name: dubbo-system
+---
+
+# Nacos
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: nacos
+ namespace: dubbo-system
+spec:
+ replicas: 1
+ selector:
+ matchLabels:
+ app: nacos
+ template:
+ metadata:
+ labels:
+ app: nacos
+ spec:
+ containers:
+ - name: consumer
+ image: nacos/nacos-server:v2.2.0
+ imagePullPolicy: Always
+ resources:
+ requests:
+ memory: "2Gi"
+ cpu: "500m"
+ ports:
+ - containerPort: 8848
+ name: client
+ - containerPort: 9848
+ name: client-rpc
+ env:
+ - name: NACOS_SERVER_PORT
+ value: "8848"
+ - name: NACOS_APPLICATION_PORT
+ value: "8848"
+ - name: PREFER_HOST_MODE
+ value: "hostname"
+ - name: MODE
+ value: "standalone"
+ - name: NACOS_AUTH_ENABLE
+ value: "true"
+---
+apiVersion: v1
+kind: Service
+metadata:
+ name: nacos
+ namespace: dubbo-system
+spec:
+ type: ClusterIP
+ sessionAffinity: None
+ selector:
+ app: nacos
+ ports:
+ - port: 8848
+ name: server
+ targetPort: 8848
+ - port: 9848
+ name: client-rpc
+ targetPort: 9848
+---
+
+# Provider
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: dubbo-samples-extensibility-filter-provider
+ namespace: dubbo-demo
+spec:
+ replicas: 1
+ selector:
+ matchLabels:
+ app: dubbo-samples-extensibility-filter-provider
+ template:
+ metadata:
+ labels:
+ app: dubbo-samples-extensibility-filter-provider
+ spec:
+ containers:
+ - name: consumer
+ image:
apache/dubbo-demo:dubbo-samples-extensibility-filter-provider_0.0.1
+ imagePullPolicy: Always
+ ports:
+ - name: dubbo
+ containerPort: 20880
+ protocol: TCP
+---
+
+# Consumer
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: dubbo-samples-extensibility-filter-consumer
+ namespace: dubbo-demo
+spec:
+ replicas: 1
+ selector:
+ matchLabels:
+ app: dubbo-samples-extensibility-filter-consumer
+ template:
+ metadata:
+ labels:
+ app: dubbo-samples-extensibility-filter-consumer
+ spec:
+ containers:
+ - name: consumer
+ image:
apache/dubbo-demo:dubbo-samples-extensibility-filter-consumer_0.0.1
+ imagePullPolicy: Always
+ ports:
+ - name: dubbo
+ containerPort: 20880
+ protocol: TCP
\ No newline at end of file
diff --git a/10-task/dubbo-samples-extensibility/deploy/Namespace.yml
b/10-task/dubbo-samples-extensibility/deploy/Namespace.yml
new file mode 100644
index 00000000..20d311f1
--- /dev/null
+++ b/10-task/dubbo-samples-extensibility/deploy/Namespace.yml
@@ -0,0 +1,25 @@
+# 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.
+
+apiVersion: v1
+kind: Namespace
+metadata:
+ name: dubbo-demo
+---
+
+apiVersion: v1
+kind: Namespace
+metadata:
+ name: dubbo-system
\ No newline at end of file
diff --git a/10-task/dubbo-samples-extensibility/deploy/filter/Deployment.yml
b/10-task/dubbo-samples-extensibility/deploy/filter/Deployment.yml
new file mode 100644
index 00000000..c08f4941
--- /dev/null
+++ b/10-task/dubbo-samples-extensibility/deploy/filter/Deployment.yml
@@ -0,0 +1,65 @@
+# 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.
+
+# Provider
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: dubbo-samples-extensibility-filter-provider
+ namespace: dubbo-demo
+spec:
+ replicas: 1
+ selector:
+ matchLabels:
+ app: dubbo-samples-extensibility-filter-provider
+ template:
+ metadata:
+ labels:
+ app: dubbo-samples-extensibility-filter-provider
+ spec:
+ containers:
+ - name: consumer
+ image:
apache/dubbo-demo:dubbo-samples-extensibility-filter-provider_0.0.1
+ imagePullPolicy: Always
+ ports:
+ - name: dubbo
+ containerPort: 20880
+ protocol: TCP
+---
+
+# Consumer
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: dubbo-samples-extensibility-filter-consumer
+ namespace: dubbo-demo
+spec:
+ replicas: 1
+ selector:
+ matchLabels:
+ app: dubbo-samples-extensibility-filter-consumer
+ template:
+ metadata:
+ labels:
+ app: dubbo-samples-extensibility-filter-consumer
+ spec:
+ containers:
+ - name: consumer
+ image:
apache/dubbo-demo:dubbo-samples-extensibility-filter-consumer_0.0.1
+ imagePullPolicy: Always
+ ports:
+ - name: dubbo
+ containerPort: 20880
+ protocol: TCP
\ No newline at end of file
diff --git a/10-task/dubbo-samples-extensibility/deploy/nacos/Deployment.yml
b/10-task/dubbo-samples-extensibility/deploy/nacos/Deployment.yml
new file mode 100644
index 00000000..83bcc5ba
--- /dev/null
+++ b/10-task/dubbo-samples-extensibility/deploy/nacos/Deployment.yml
@@ -0,0 +1,72 @@
+# 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.
+
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: nacos
+ namespace: dubbo-system
+spec:
+ replicas: 1
+ selector:
+ matchLabels:
+ app: nacos
+ template:
+ metadata:
+ labels:
+ app: nacos
+ spec:
+ containers:
+ - name: consumer
+ image: nacos/nacos-server:v2.2.0
+ imagePullPolicy: Always
+ resources:
+ requests:
+ memory: "2Gi"
+ cpu: "500m"
+ ports:
+ - containerPort: 8848
+ name: client
+ - containerPort: 9848
+ name: client-rpc
+ env:
+ - name: NACOS_SERVER_PORT
+ value: "8848"
+ - name: NACOS_APPLICATION_PORT
+ value: "8848"
+ - name: PREFER_HOST_MODE
+ value: "hostname"
+ - name: MODE
+ value: "standalone"
+ - name: NACOS_AUTH_ENABLE
+ value: "true"
+---
+apiVersion: v1
+kind: Service
+metadata:
+ name: nacos
+ namespace: dubbo-system
+spec:
+ type: ClusterIP
+ sessionAffinity: None
+ selector:
+ app: nacos
+ ports:
+ - port: 8848
+ name: server
+ targetPort: 8848
+ - port: 9848
+ name: client-rpc
+ targetPort: 9848
\ No newline at end of file
diff --git a/10-task/pom.xml
b/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-filter-api/pom.xml
similarity index 56%
copy from 10-task/pom.xml
copy to
10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-filter-api/pom.xml
index b141237d..e8e0bafb 100644
--- a/10-task/pom.xml
+++
b/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-filter-api/pom.xml
@@ -15,20 +15,22 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <groupId>org.apache</groupId>
+ <artifactId>apache</artifactId>
+ <version>23</version>
+ <relativePath/>
+ </parent>
<modelVersion>4.0.0</modelVersion>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>10-task</artifactId>
- <packaging>pom</packaging>
- <version>1.0-SNAPSHOT</version>
+ <groupId>org.apache.dubbo.samples</groupId>
+ <artifactId>dubbo-samples-extensibility-filter-api</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
- <name>Task</name>
- <description>Dubbo Learning Task</description>
+ <name>Dubbo Extensibility Filter Task - API</name>
+ <description>Dubbo Extensibility Filter Task - API</description>
- <modules>
- <module>dubbo-samples-rpc-basic</module>
- <module>dubbo-samples-rpc-advanced</module>
- <module>dubbo-samples-shop</module>
- </modules>
</project>
\ No newline at end of file
diff --git
a/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-filter-api/src/main/java/org/apache/dubbo/samples/extensibility/filter/api/ExtensibilityFilterService.java
b/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-filter-api/src/main/java/org/apache/dubbo/samples/extensibility/filter/api/ExtensibilityFilterService.java
new file mode 100644
index 00000000..e8fb60e0
--- /dev/null
+++
b/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-filter-api/src/main/java/org/apache/dubbo/samples/extensibility/filter/api/ExtensibilityFilterService.java
@@ -0,0 +1,22 @@
+/*
+ * 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.samples.extensibility.filter.api;
+
+public interface ExtensibilityFilterService {
+
+ String sayHello(String name);
+}
\ No newline at end of file
diff --git
a/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-filter-consumer/pom.xml
b/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-filter-consumer/pom.xml
new file mode 100644
index 00000000..bc2ed5f5
--- /dev/null
+++
b/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-filter-consumer/pom.xml
@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-parent</artifactId>
+ <version>3.0.0</version>
+ <relativePath/> <!-- lookup parent from repository -->
+ </parent>
+
+ <groupId>org.apache.dubbo.samples</groupId>
+ <artifactId>dubbo-samples-extensibility-filter-consumer</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+
+ <name>Dubbo Extensibility Filter Task - Consumer</name>
+ <description>Dubbo Extensibility Filter Task - Consumer</description>
+
+ <properties>
+ <java.version>17</java.version>
+ <dubbo.version>3.2.0-beta.2</dubbo.version>
+ <nacos.version>2.2.0</nacos.version>
+ </properties>
+
+ <dependencies>
+ <!-- common api -->
+ <dependency>
+ <groupId>org.apache.dubbo.samples</groupId>
+ <artifactId>dubbo-samples-extensibility-filter-api</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ </dependency>
+
+ <!-- registry dependency -->
+ <dependency>
+ <groupId>com.alibaba.nacos</groupId>
+ <artifactId>nacos-client</artifactId>
+ <version>${nacos.version}</version>
+ </dependency>
+
+ <!-- dubbo dependency-->
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-spring-boot-starter</artifactId>
+ <version>${dubbo.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.graalvm.buildtools</groupId>
+ <artifactId>native-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>com.google.cloud.tools</groupId>
+ <artifactId>jib-maven-plugin</artifactId>
+ <version>3.2.1</version>
+ <configuration>
+ <to>
+
<image>apache/dubbo-demo:dubbo-samples-extensibility-filter-consumer_0.0.1</image>
+ </to>
+ <container>
+ <jvmFlags>
+
<jvmFlag>-Dnacos.address=nacos.dubbo-system.svc</jvmFlag>
+ </jvmFlags>
+ <ports>
+ <port>20881</port>
+ <port>20991</port>
+ </ports>
+ </container>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
\ No newline at end of file
diff --git
a/2-advanced/dubbo-samples-seata/dubbo-samples-seata-order/src/main/java/org/apache/dubbo/samples/seata/OrderApplication.java
b/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-filter-consumer/src/main/java/org/apache/dubbo/samples/extensibility/filter/consumer/ExtensibilityFilterConsumerApplication.java
similarity index 56%
copy from
2-advanced/dubbo-samples-seata/dubbo-samples-seata-order/src/main/java/org/apache/dubbo/samples/seata/OrderApplication.java
copy to
10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-filter-consumer/src/main/java/org/apache/dubbo/samples/extensibility/filter/consumer/ExtensibilityFilterConsumerApplication.java
index 33cc8141..0bd28802 100644
---
a/2-advanced/dubbo-samples-seata/dubbo-samples-seata-order/src/main/java/org/apache/dubbo/samples/seata/OrderApplication.java
+++
b/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-filter-consumer/src/main/java/org/apache/dubbo/samples/extensibility/filter/consumer/ExtensibilityFilterConsumerApplication.java
@@ -14,33 +14,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.samples.seata;
+package org.apache.dubbo.samples.extensibility.filter.consumer;
-import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
-
-import io.seata.rm.datasource.DataSourceProxy;
-import io.seata.spring.annotation.GlobalTransactionScanner;
-import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.context.annotation.Bean;
-import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.stereotype.Component;
-
-import javax.sql.DataSource;
-@EnableDubbo
@SpringBootApplication
-public class OrderApplication {
-
+public class ExtensibilityFilterConsumerApplication {
public static void main(String[] args) {
- SpringApplication.run(OrderApplication.class, args);
- }
-
- @Bean
- public JdbcTemplate jdbcTemplate(DataSource dataSource) {
- JdbcTemplate jdbcTemplate = new JdbcTemplate();
- jdbcTemplate.setDataSource(dataSource);
- return jdbcTemplate;
+ SpringApplication.run(ExtensibilityFilterConsumerApplication.class,
args);
}
-}
+}
\ No newline at end of file
diff --git
a/2-advanced/dubbo-samples-seata/dubbo-samples-seata-order/src/main/java/org/apache/dubbo/samples/seata/OrderApplication.java
b/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-filter-consumer/src/main/java/org/apache/dubbo/samples/extensibility/filter/consumer/ExtensibilityFilterConsumerTask.java
similarity index 51%
copy from
2-advanced/dubbo-samples-seata/dubbo-samples-seata-order/src/main/java/org/apache/dubbo/samples/seata/OrderApplication.java
copy to
10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-filter-consumer/src/main/java/org/apache/dubbo/samples/extensibility/filter/consumer/ExtensibilityFilterConsumerTask.java
index 33cc8141..0c3f8f82 100644
---
a/2-advanced/dubbo-samples-seata/dubbo-samples-seata-order/src/main/java/org/apache/dubbo/samples/seata/OrderApplication.java
+++
b/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-filter-consumer/src/main/java/org/apache/dubbo/samples/extensibility/filter/consumer/ExtensibilityFilterConsumerTask.java
@@ -14,33 +14,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.samples.seata;
+package org.apache.dubbo.samples.extensibility.filter.consumer;
-import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
-
-import io.seata.rm.datasource.DataSourceProxy;
-import io.seata.spring.annotation.GlobalTransactionScanner;
+import org.apache.dubbo.config.annotation.DubboReference;
+import
org.apache.dubbo.samples.extensibility.filter.api.ExtensibilityFilterService;
import org.springframework.boot.CommandLineRunner;
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.context.annotation.Bean;
-import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
-import javax.sql.DataSource;
-
-@EnableDubbo
-@SpringBootApplication
-public class OrderApplication {
-
- public static void main(String[] args) {
- SpringApplication.run(OrderApplication.class, args);
- }
+@Component
+public class ExtensibilityFilterConsumerTask implements CommandLineRunner {
+ @DubboReference
+ private ExtensibilityFilterService extensibilityFilterService;
- @Bean
- public JdbcTemplate jdbcTemplate(DataSource dataSource) {
- JdbcTemplate jdbcTemplate = new JdbcTemplate();
- jdbcTemplate.setDataSource(dataSource);
- return jdbcTemplate;
+ @Override
+ public void run(String... args) {
+ System.out.println("Dubbo Remote Return ======> " +
this.extensibilityFilterService.sayHello("dubbo"));
}
}
diff --git
a/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-filter-consumer/src/main/resources/application.properties
b/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-filter-consumer/src/main/resources/application.properties
new file mode 100644
index 00000000..1b8a1c43
--- /dev/null
+++
b/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-filter-consumer/src/main/resources/application.properties
@@ -0,0 +1,24 @@
+# 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.
+
+# Specify the application name of Dubbo
+dubbo.application.name=extensibility-filter-consumer
+
+# Enable token verification for each invocation
+dubbo.provider.token=true
+
+# Specify the registry address
+dubbo.registry.address=nacos://localhost:8848?username=nacos&password=nacos
+#
dubbo.registry.address=nacos://${nacos.address:localhost}:8848?username=nacos&password=nacos
diff --git
a/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-filter-provider/pom.xml
b/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-filter-provider/pom.xml
new file mode 100644
index 00000000..49862cc5
--- /dev/null
+++
b/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-filter-provider/pom.xml
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-parent</artifactId>
+ <version>3.0.0</version>
+ <relativePath/> <!-- lookup parent from repository -->
+ </parent>
+
+ <groupId>org.apache.dubbo.samples</groupId>
+ <artifactId>dubbo-samples-extensibility-filter-provider</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+
+ <name>Dubbo Extensibility Filter Task - Provider</name>
+ <description>Dubbo Extensibility Filter Task - Provider</description>
+
+ <properties>
+ <java.version>17</java.version>
+ <dubbo.version>3.2.0-beta.2</dubbo.version>
+ <nacos.version>2.2.0</nacos.version>
+ </properties>
+
+ <dependencies>
+ <!-- common api -->
+ <dependency>
+ <groupId>org.apache.dubbo.samples</groupId>
+ <artifactId>dubbo-samples-extensibility-filter-api</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ </dependency>
+
+ <!-- registry dependency -->
+ <dependency>
+ <groupId>com.alibaba.nacos</groupId>
+ <artifactId>nacos-client</artifactId>
+ <version>${nacos.version}</version>
+ </dependency>
+
+ <!-- dubbo dependency-->
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-spring-boot-starter</artifactId>
+ <version>${dubbo.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.graalvm.buildtools</groupId>
+ <artifactId>native-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>com.google.cloud.tools</groupId>
+ <artifactId>jib-maven-plugin</artifactId>
+ <version>3.2.1</version>
+ <configuration>
+ <to>
+
<image>apache/dubbo-demo:dubbo-samples-extensibility-filter-provider_0.0.1</image>
+ </to>
+ <container>
+ <jvmFlags>
+
<jvmFlag>-Dnacos.address=nacos.dubbo-system.svc</jvmFlag>
+ </jvmFlags>
+ <ports>
+ <port>20881</port>
+ <port>20991</port>
+ </ports>
+ </container>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
diff --git
a/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-filter-provider/src/main/java/org/apache/dubbo/samples/extensibility/filter/provider/AppendedFilter.java
b/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-filter-provider/src/main/java/org/apache/dubbo/samples/extensibility/filter/provider/AppendedFilter.java
new file mode 100644
index 00000000..d302ea6f
--- /dev/null
+++
b/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-filter-provider/src/main/java/org/apache/dubbo/samples/extensibility/filter/provider/AppendedFilter.java
@@ -0,0 +1,37 @@
+/*
+ * 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.samples.extensibility.filter.provider;
+
+import org.apache.dubbo.rpc.Filter;
+import org.apache.dubbo.rpc.Result;
+import org.apache.dubbo.rpc.Invoker;
+import org.apache.dubbo.rpc.Invocation;
+import org.apache.dubbo.rpc.RpcException;
+import org.apache.dubbo.rpc.AsyncRpcResult;
+
+public class AppendedFilter implements Filter {
+
+ @Override
+ public Result invoke(Invoker<?> invoker, Invocation invocation) throws
RpcException {
+ Result result= invoker.invoke(invocation);
+ // Obtain the returned value
+ Result appResponse = ((AsyncRpcResult) result).getAppResponse();
+ // Appended value
+ appResponse.setValue(appResponse.getValue()+"'s customized
AppendedFilter");
+ return result;
+ }
+}
diff --git
a/2-advanced/dubbo-samples-seata/dubbo-samples-seata-order/src/main/java/org/apache/dubbo/samples/seata/OrderApplication.java
b/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-filter-provider/src/main/java/org/apache/dubbo/samples/extensibility/filter/provider/ExtensibilityFilterProviderApplication.java
similarity index 61%
copy from
2-advanced/dubbo-samples-seata/dubbo-samples-seata-order/src/main/java/org/apache/dubbo/samples/seata/OrderApplication.java
copy to
10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-filter-provider/src/main/java/org/apache/dubbo/samples/extensibility/filter/provider/ExtensibilityFilterProviderApplication.java
index 33cc8141..b69d1325 100644
---
a/2-advanced/dubbo-samples-seata/dubbo-samples-seata-order/src/main/java/org/apache/dubbo/samples/seata/OrderApplication.java
+++
b/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-filter-provider/src/main/java/org/apache/dubbo/samples/extensibility/filter/provider/ExtensibilityFilterProviderApplication.java
@@ -14,33 +14,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.samples.seata;
+package org.apache.dubbo.samples.extensibility.filter.provider;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
-
-import io.seata.rm.datasource.DataSourceProxy;
-import io.seata.spring.annotation.GlobalTransactionScanner;
-import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.context.annotation.Bean;
-import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.stereotype.Component;
-
-import javax.sql.DataSource;
@EnableDubbo
@SpringBootApplication
-public class OrderApplication {
-
+public class ExtensibilityFilterProviderApplication {
public static void main(String[] args) {
- SpringApplication.run(OrderApplication.class, args);
- }
-
- @Bean
- public JdbcTemplate jdbcTemplate(DataSource dataSource) {
- JdbcTemplate jdbcTemplate = new JdbcTemplate();
- jdbcTemplate.setDataSource(dataSource);
- return jdbcTemplate;
+ SpringApplication.run(ExtensibilityFilterProviderApplication.class,
args);
}
-}
+}
\ No newline at end of file
diff --git
a/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-filter-provider/src/main/java/org/apache/dubbo/samples/extensibility/filter/provider/ExtensibilityFilterServiceImpl.java
b/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-filter-provider/src/main/java/org/apache/dubbo/samples/extensibility/filter/provider/ExtensibilityFilterServiceImpl.java
new file mode 100644
index 00000000..44b13d5e
--- /dev/null
+++
b/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-filter-provider/src/main/java/org/apache/dubbo/samples/extensibility/filter/provider/ExtensibilityFilterServiceImpl.java
@@ -0,0 +1,29 @@
+/*
+ * 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.samples.extensibility.filter.provider;
+
+import org.apache.dubbo.config.annotation.DubboService;
+import
org.apache.dubbo.samples.extensibility.filter.api.ExtensibilityFilterService;
+
+@DubboService
+public class ExtensibilityFilterServiceImpl implements
ExtensibilityFilterService {
+
+ @Override
+ public String sayHello(String name) {
+ return "Hello, " + name;
+ }
+}
diff --git
a/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-filter-provider/src/main/resources/META-INF/dubbo/org.apache.dubbo.rpc.Filter
b/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-filter-provider/src/main/resources/META-INF/dubbo/org.apache.dubbo.rpc.Filter
new file mode 100644
index 00000000..513d54ba
--- /dev/null
+++
b/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-filter-provider/src/main/resources/META-INF/dubbo/org.apache.dubbo.rpc.Filter
@@ -0,0 +1 @@
+appended=org.apache.dubbo.samples.extensibility.filter.provider.AppendedFilter
\ No newline at end of file
diff --git
a/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-filter-provider/src/main/resources/application.properties
b/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-filter-provider/src/main/resources/application.properties
new file mode 100644
index 00000000..5465ee34
--- /dev/null
+++
b/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-filter-provider/src/main/resources/application.properties
@@ -0,0 +1,30 @@
+# 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.
+
+# Specify the application name of Dubbo
+dubbo.application.name=extensibility-filter-provider
+
+# Enable token verification for each invocation
+dubbo.provider.token=true
+
+# Specify the registry address
+dubbo.registry.address=nacos://localhost:8848?username=nacos&password=nacos
+#
dubbo.registry.address=nacos://${nacos.address:localhost}:8848?username=nacos&password=nacos
+
+# Specify the port of Dubbo protocol
+dubbo.protocol.port=20881
+
+# Apply AppendedFilter
+dubbo.provider.filter=appended
\ No newline at end of file
diff --git a/10-task/pom.xml b/10-task/dubbo-samples-extensibility/pom.xml
similarity index 60%
copy from 10-task/pom.xml
copy to 10-task/dubbo-samples-extensibility/pom.xml
index b141237d..02617715 100644
--- a/10-task/pom.xml
+++ b/10-task/dubbo-samples-extensibility/pom.xml
@@ -15,20 +15,23 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>10-task</artifactId>
+ <groupId>org.apache.dubbo.samples</groupId>
+ <artifactId>dubbo-samples-extensibility</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
- <name>Task</name>
- <description>Dubbo Learning Task</description>
+ <name>Extensibility Task</name>
+ <description>Dubbo Samples Extensibility Task</description>
<modules>
- <module>dubbo-samples-rpc-basic</module>
- <module>dubbo-samples-rpc-advanced</module>
- <module>dubbo-samples-shop</module>
+ <module>dubbo-samples-extensibility-filter-api</module>
+ <module>dubbo-samples-extensibility-filter-provider</module>
+ <module>dubbo-samples-extensibility-filter-consumer</module>
</modules>
+
</project>
\ No newline at end of file
diff --git
a/10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/java/org/apache/dubbo/samples/detail/DetailServiceImpl.java
b/10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/java/org/apache/dubbo/samples/detail/DetailServiceImpl.java
index caad12bb..57ae9033 100644
---
a/10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/java/org/apache/dubbo/samples/detail/DetailServiceImpl.java
+++
b/10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/java/org/apache/dubbo/samples/detail/DetailServiceImpl.java
@@ -20,7 +20,6 @@ import org.apache.dubbo.config.annotation.DubboService;
import org.apache.dubbo.samples.DetailService;
import org.apache.dubbo.samples.Item;
-import java.math.BigInteger;
import java.util.concurrent.ThreadLocalRandom;
@DubboService
diff --git a/10-task/pom.xml b/10-task/pom.xml
index b141237d..b5aea31f 100644
--- a/10-task/pom.xml
+++ b/10-task/pom.xml
@@ -30,5 +30,6 @@
<module>dubbo-samples-rpc-basic</module>
<module>dubbo-samples-rpc-advanced</module>
<module>dubbo-samples-shop</module>
+ <module>dubbo-samples-extensibility</module>
</modules>
</project>
\ No newline at end of file
diff --git
a/2-advanced/dubbo-samples-seata/dubbo-samples-seata-account/src/main/java/org/apache/dubbo/samples/seata/AccountServiceImpl.java
b/2-advanced/dubbo-samples-seata/dubbo-samples-seata-account/src/main/java/org/apache/dubbo/samples/seata/AccountServiceImpl.java
index f1e15dfc..7e479643 100644
---
a/2-advanced/dubbo-samples-seata/dubbo-samples-seata-account/src/main/java/org/apache/dubbo/samples/seata/AccountServiceImpl.java
+++
b/2-advanced/dubbo-samples-seata/dubbo-samples-seata-account/src/main/java/org/apache/dubbo/samples/seata/AccountServiceImpl.java
@@ -24,9 +24,7 @@ import io.seata.core.context.RootContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.CommandLineRunner;
import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.stereotype.Component;
@DubboService(timeout = 10000)
public class AccountServiceImpl implements AccountService {
diff --git
a/2-advanced/dubbo-samples-seata/dubbo-samples-seata-business/src/main/java/org/apache/dubbo/samples/seata/BusinessServiceImpl.java
b/2-advanced/dubbo-samples-seata/dubbo-samples-seata-business/src/main/java/org/apache/dubbo/samples/seata/BusinessServiceImpl.java
index dcc0b9d5..8ad49a39 100644
---
a/2-advanced/dubbo-samples-seata/dubbo-samples-seata-business/src/main/java/org/apache/dubbo/samples/seata/BusinessServiceImpl.java
+++
b/2-advanced/dubbo-samples-seata/dubbo-samples-seata-business/src/main/java/org/apache/dubbo/samples/seata/BusinessServiceImpl.java
@@ -26,7 +26,6 @@ import io.seata.core.context.RootContext;
import io.seata.spring.annotation.GlobalTransactional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
diff --git
a/2-advanced/dubbo-samples-seata/dubbo-samples-seata-order/src/main/java/org/apache/dubbo/samples/seata/OrderApplication.java
b/2-advanced/dubbo-samples-seata/dubbo-samples-seata-order/src/main/java/org/apache/dubbo/samples/seata/OrderApplication.java
index 33cc8141..48fceb9f 100644
---
a/2-advanced/dubbo-samples-seata/dubbo-samples-seata-order/src/main/java/org/apache/dubbo/samples/seata/OrderApplication.java
+++
b/2-advanced/dubbo-samples-seata/dubbo-samples-seata-order/src/main/java/org/apache/dubbo/samples/seata/OrderApplication.java
@@ -18,14 +18,10 @@ package org.apache.dubbo.samples.seata;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
-import io.seata.rm.datasource.DataSourceProxy;
-import io.seata.spring.annotation.GlobalTransactionScanner;
-import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.stereotype.Component;
import javax.sql.DataSource;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]