You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by li...@apache.org on 2024/01/19 06:19:39 UTC
(servicecomb-samples) branch master updated: add spring cloud & java chassis interoperability (#138)
This is an automated email from the ASF dual-hosted git repository.
liubao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-samples.git
The following commit(s) were added to refs/heads/master by this push:
new e215bec add spring cloud & java chassis interoperability (#138)
e215bec is described below
commit e215bec9e5839ae0725b66eb4d088e30e8339870
Author: liubao68 <bi...@qq.com>
AuthorDate: Fri Jan 19 14:19:34 2024 +0800
add spring cloud & java chassis interoperability (#138)
---
java-chassis-interoprability/README.md | 35 +++++++
.../java-chassis-3.0.x/pom.xml | 115 +++++++++++++++++++++
.../java-chassis-3.0.x/provider/pom.xml | 50 +++++++++
.../servicecomb/samples/ProviderApplication.java | 36 +++++++
.../servicecomb/samples/ProviderController.java | 41 ++++++++
.../servicecomb/samples/SpringCloudService.java | 27 +++++
.../provider/src/main/resources/application.yml | 74 +++++++++++++
.../provider/src/main/resources/log4j2.xml | 71 +++++++++++++
java-chassis-interoprability/pom.xml | 67 ++++++++++++
.../spring-cloud-2022.0.x/gateway/pom.xml | 71 +++++++++++++
.../servicecomb/samples/GatewayApplication.java | 36 +++++++
.../gateway/src/main/resources/application.yaml | 37 +++++++
.../gateway/src/main/resources/bootstrap.yml | 101 ++++++++++++++++++
.../gateway/src/main/resources/log4j2.xml | 59 +++++++++++
.../spring-cloud-2022.0.x/pom.xml | 83 +++++++++++++++
.../spring-cloud-2022.0.x/provider/pom.xml | 85 +++++++++++++++
.../samples/JavaChassisManagementEndpoint.java | 74 +++++++++++++
.../servicecomb/samples/JavaChassisService.java | 27 +++++
.../servicecomb/samples/ProviderApplication.java | 38 +++++++
.../servicecomb/samples/ProviderController.java | 45 ++++++++
.../provider/src/main/resources/bootstrap.yml | 84 +++++++++++++++
.../main/resources/export/ProviderController.yaml | 52 ++++++++++
.../provider/src/main/resources/log4j2.xml | 59 +++++++++++
23 files changed, 1367 insertions(+)
diff --git a/java-chassis-interoprability/README.md b/java-chassis-interoprability/README.md
new file mode 100644
index 0000000..1b963d7
--- /dev/null
+++ b/java-chassis-interoprability/README.md
@@ -0,0 +1,35 @@
+# About Spring Cloud and Java Chassis interoperability
+
+In this demo, we build a gateway using spring-cloud-gateway, a microservice `provider-java-chassis` using Java Chassis, a microservice `provider-spring-cloud` using Spring Cloud.
+
+Scenario 1: User -> gateway -> provider-spring-cloud -> provider-java-chassis
+
+Request:
+
+ `http://localhost:9090/spring-cloud/sayHello?name=World`
+
+Result:
+
+ `"Hello from Java Chassis, World"`
+
+
+Scenario 2: User -> gateway -> provider-java-chassis -> provider-spring-cloud
+
+Request:
+
+ `http://localhost:9090/java-chassis/sayHello?name=World`
+
+Result:
+
+ `"Hello from Spring Cloud, World"`
+
+## Using Service Center & Kie
+
+Maven profile and Spring Profile using `servicecomb`.
+
+## Using Nacos
+
+Maven profile and Spring Profile using `nacos`.
+
+>>> Notice: Nacos 2.3.0 and above is required. Because older versions of nacos will not generate instance id for Spring Cloud applications and Java Chassis interoperability needs instance id.
+
diff --git a/java-chassis-interoprability/java-chassis-3.0.x/pom.xml b/java-chassis-interoprability/java-chassis-3.0.x/pom.xml
new file mode 100644
index 0000000..fc1bb12
--- /dev/null
+++ b/java-chassis-interoprability/java-chassis-3.0.x/pom.xml
@@ -0,0 +1,115 @@
+<?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.apache.servicecomb.interoprability</groupId>
+ <artifactId>interoprability-parent</artifactId>
+ <version>3.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>java-chassis-3.0.x</artifactId>
+ <packaging>pom</packaging>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <servicecomb.version>3.0.1</servicecomb.version>
+ </properties>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.servicecomb</groupId>
+ <artifactId>java-chassis-dependencies</artifactId>
+ <version>${servicecomb.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.servicecomb</groupId>
+ <artifactId>solution-basic</artifactId>
+ </dependency>
+ <!-- using log4j2 -->
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-slf4j-impl</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.lmax</groupId>
+ <artifactId>disruptor</artifactId>
+ <version>3.4.4</version>
+ </dependency>
+ </dependencies>
+
+ <profiles>
+ <profile>
+ <id>servicecomb</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <dependencies>
+ <!-- using service-center & kie -->
+ <dependency>
+ <groupId>org.apache.servicecomb</groupId>
+ <artifactId>registry-service-center</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicecomb</groupId>
+ <artifactId>config-kie</artifactId>
+ </dependency>
+ </dependencies>
+ </profile>
+ <profile>
+ <id>nacos</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ </activation>
+ <dependencies>
+ <!-- using nacos -->
+ <dependency>
+ <groupId>org.apache.servicecomb</groupId>
+ <artifactId>registry-nacos</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicecomb</groupId>
+ <artifactId>config-nacos</artifactId>
+ </dependency>
+ </dependencies>
+ </profile>
+ </profiles>
+
+ <modules>
+ <module>provider</module>
+ </modules>
+
+</project>
diff --git a/java-chassis-interoprability/java-chassis-3.0.x/provider/pom.xml b/java-chassis-interoprability/java-chassis-3.0.x/provider/pom.xml
new file mode 100644
index 0000000..4d8aa8c
--- /dev/null
+++ b/java-chassis-interoprability/java-chassis-3.0.x/provider/pom.xml
@@ -0,0 +1,50 @@
+<?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.apache.servicecomb.interoprability</groupId>
+ <artifactId>java-chassis-3.0.x</artifactId>
+ <version>3.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>java-chassis-provider-3.0.x</artifactId>
+ <packaging>jar</packaging>
+
+ <properties>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.servicecomb</groupId>
+ <artifactId>java-chassis-spring-boot-starter-standalone</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
diff --git a/java-chassis-interoprability/java-chassis-3.0.x/provider/src/main/java/org/apache/servicecomb/samples/ProviderApplication.java b/java-chassis-interoprability/java-chassis-3.0.x/provider/src/main/java/org/apache/servicecomb/samples/ProviderApplication.java
new file mode 100644
index 0000000..f429b34
--- /dev/null
+++ b/java-chassis-interoprability/java-chassis-3.0.x/provider/src/main/java/org/apache/servicecomb/samples/ProviderApplication.java
@@ -0,0 +1,36 @@
+/*
+ * 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.servicecomb.samples;
+
+import org.springframework.boot.WebApplicationType;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+
+@SpringBootApplication
+public class ProviderApplication {
+ public static void main(String[] args) throws Exception {
+ try {
+ new SpringApplicationBuilder()
+ .web(WebApplicationType.NONE)
+ .sources(ProviderApplication.class)
+ .run(args);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/java-chassis-interoprability/java-chassis-3.0.x/provider/src/main/java/org/apache/servicecomb/samples/ProviderController.java b/java-chassis-interoprability/java-chassis-3.0.x/provider/src/main/java/org/apache/servicecomb/samples/ProviderController.java
new file mode 100644
index 0000000..92230e1
--- /dev/null
+++ b/java-chassis-interoprability/java-chassis-3.0.x/provider/src/main/java/org/apache/servicecomb/samples/ProviderController.java
@@ -0,0 +1,41 @@
+/*
+ * 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.servicecomb.samples;
+
+import org.apache.servicecomb.provider.pojo.RpcReference;
+import org.apache.servicecomb.provider.rest.common.RestSchema;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+@RestSchema(schemaId = "ProviderController")
+@RequestMapping(path = "/java-chassis")
+public class ProviderController {
+ @RpcReference(schemaId = "ProviderController", microserviceName = "provider-spring-cloud")
+ private SpringCloudService springCloudService;
+
+ @GetMapping("/sayHello")
+ public String sayHello(@RequestParam("name") String name) throws Exception {
+ return springCloudService.sayHelloInternal(name);
+ }
+
+ @GetMapping("/sayHelloInternal")
+ public String sayHelloInternal(@RequestParam("name") String name) throws Exception {
+ return "Hello from Java Chassis, " + name;
+ }
+}
diff --git a/java-chassis-interoprability/java-chassis-3.0.x/provider/src/main/java/org/apache/servicecomb/samples/SpringCloudService.java b/java-chassis-interoprability/java-chassis-3.0.x/provider/src/main/java/org/apache/servicecomb/samples/SpringCloudService.java
new file mode 100644
index 0000000..2f92ba6
--- /dev/null
+++ b/java-chassis-interoprability/java-chassis-3.0.x/provider/src/main/java/org/apache/servicecomb/samples/SpringCloudService.java
@@ -0,0 +1,27 @@
+/*
+ * 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.servicecomb.samples;
+
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+@RequestMapping("/spring-cloud")
+public interface SpringCloudService {
+ @GetMapping("/sayHelloInternal")
+ String sayHelloInternal(@RequestParam("name") String name);
+}
diff --git a/java-chassis-interoprability/java-chassis-3.0.x/provider/src/main/resources/application.yml b/java-chassis-interoprability/java-chassis-3.0.x/provider/src/main/resources/application.yml
new file mode 100644
index 0000000..126a73f
--- /dev/null
+++ b/java-chassis-interoprability/java-chassis-3.0.x/provider/src/main/resources/application.yml
@@ -0,0 +1,74 @@
+#
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+servicecomb:
+ service:
+ application: basic-application
+ name: provider-java-chassis
+ environment: production
+ version: 0.0.1
+ rest:
+ address: 0.0.0.0:9093
+
+ accesslog:
+ enabled: true
+ metrics:
+ window_time: 60000
+ invocation:
+ latencyDistribution: 0,10,50,100,1000
+ Consumer.invocation.slow:
+ enabled: true
+ msTime: 50
+ Provider.invocation.slow:
+ enabled: true
+ msTime: 50
+ publisher.defaultLog:
+ enabled: true
+ endpoints.client.detail.enabled: true
+
+spring:
+ profiles:
+ active: servicecomb # 注册中心类型:servicecomb 或者 nacos
+
+---
+spring:
+ config:
+ activate:
+ on-profile: servicecomb
+servicecomb:
+ # 注册发现
+ registry:
+ sc:
+ address: http://localhost:30100
+ # 动态配置
+ kie:
+ serverUri: http://localhost:30110
+
+---
+spring:
+ config:
+ activate:
+ on-profile: nacos
+servicecomb:
+ # 注册发现
+ registry:
+ nacos:
+ serverAddr: http://localhost:8848
+ # 动态配置
+ nacos:
+ serverAddr: http://localhost:8848
+
diff --git a/java-chassis-interoprability/java-chassis-3.0.x/provider/src/main/resources/log4j2.xml b/java-chassis-interoprability/java-chassis-3.0.x/provider/src/main/resources/log4j2.xml
new file mode 100644
index 0000000..53ed8e9
--- /dev/null
+++ b/java-chassis-interoprability/java-chassis-3.0.x/provider/src/main/resources/log4j2.xml
@@ -0,0 +1,71 @@
+<?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.
+-->
+<Configuration>
+ <Properties>
+ <property name="FILE_PATH" value="./logs/provider-java-chassis"/>
+ </Properties>
+
+ <Appenders>
+ <Console name="Console" target="SYSTEM_OUT">
+ <PatternLayout pattern="%d [%p][%t][%c:%L] %m%n"/>
+ </Console>
+
+ <RollingFile name="AccessLog" fileName="${FILE_PATH}/access.log"
+ filePattern="${FILE_PATH}/access-%d{yyyy-MM-dd}_%i.log.gz">
+ <PatternLayout pattern="%d [%t] %m%n"/>
+ <Policies>
+ <SizeBasedTriggeringPolicy size="20MB"/>
+ </Policies>
+ <DefaultRolloverStrategy max="100"/>
+ </RollingFile>
+
+ <RollingFile name="MetricsLog" fileName="${FILE_PATH}/metrics.log"
+ filePattern="${FILE_PATH}/metrics-%d{yyyy-MM-dd}_%i.log.gz">
+ <PatternLayout pattern="%d [%t] %m%n"/>
+ <Policies>
+ <SizeBasedTriggeringPolicy size="20MB"/>
+ </Policies>
+ <DefaultRolloverStrategy max="100"/>
+ </RollingFile>
+
+ <RollingFile name="SlowLog" fileName="${FILE_PATH}/slow.log"
+ filePattern="${FILE_PATH}/slow-%d{yyyy-MM-dd}_%i.log.gz">
+ <PatternLayout pattern="%d [%t] %m%n"/>
+ <Policies>
+ <SizeBasedTriggeringPolicy size="20MB"/>
+ </Policies>
+ <DefaultRolloverStrategy max="100"/>
+ </RollingFile>
+ </Appenders>
+
+ <Loggers>
+ <AsyncLogger name="scb-access" level="INFO" additivity="false">
+ <AppenderRef ref="AccessLog"/>
+ </AsyncLogger>
+ <AsyncLogger name="scb-metrics" level="INFO" additivity="false">
+ <AppenderRef ref="MetricsLog"/>
+ </AsyncLogger>
+ <AsyncLogger name="scb-slow" level="INFO" additivity="false">
+ <AppenderRef ref="SlowLog"/>
+ </AsyncLogger>
+
+ <Root level="INFO">
+ <AppenderRef ref="Console"/>
+ </Root>
+ </Loggers>
+</Configuration>
diff --git a/java-chassis-interoprability/pom.xml b/java-chassis-interoprability/pom.xml
new file mode 100644
index 0000000..efc69ef
--- /dev/null
+++ b/java-chassis-interoprability/pom.xml
@@ -0,0 +1,67 @@
+<?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>
+
+ <groupId>org.apache.servicecomb.interoprability</groupId>
+ <artifactId>interoprability-parent</artifactId>
+ <version>3.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <maven-compiler-plugin.version>3.11.0</maven-compiler-plugin.version>
+ <spring-boot-maven-plugin.version>3.1.3</spring-boot-maven-plugin.version>
+ </properties>
+
+ <modules>
+ <module>java-chassis-3.0.x</module>
+ <module>spring-cloud-2022.0.x</module>
+ </modules>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>${maven-compiler-plugin.version}</version>
+ <configuration>
+ <compilerArgument>-parameters</compilerArgument>
+ <source>17</source>
+ <target>17</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ <version>${spring-boot-maven-plugin.version}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>repackage</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+</project>
diff --git a/java-chassis-interoprability/spring-cloud-2022.0.x/gateway/pom.xml b/java-chassis-interoprability/spring-cloud-2022.0.x/gateway/pom.xml
new file mode 100644
index 0000000..f89233d
--- /dev/null
+++ b/java-chassis-interoprability/spring-cloud-2022.0.x/gateway/pom.xml
@@ -0,0 +1,71 @@
+<!--
+ ~ 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.apache.servicecomb.interoprability</groupId>
+ <artifactId>spring-cloud-application-2022.0.x</artifactId>
+ <version>3.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>spring-cloud-gateway-2022.0.x</artifactId>
+ <packaging>jar</packaging>
+
+ <dependencies>
+ </dependencies>
+
+ <profiles>
+ <profile>
+ <id>servicecomb</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <dependencies>
+ <!-- using service-center & kie -->
+ <dependency>
+ <groupId>com.huaweicloud</groupId>
+ <artifactId>spring-cloud-starter-huawei-service-engine-gateway</artifactId>
+ </dependency>
+ </dependencies>
+ </profile>
+ <profile>
+ <id>nacos</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ </activation>
+ <dependencies>
+ <!-- using nacos -->
+ <dependency>
+ <groupId>com.huaweicloud</groupId>
+ <artifactId>spring-cloud-starter-huawei-nacos-gateway</artifactId>
+ </dependency>
+ </dependencies>
+ </profile>
+ </profiles>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
diff --git a/java-chassis-interoprability/spring-cloud-2022.0.x/gateway/src/main/java/org/apache/servicecomb/samples/GatewayApplication.java b/java-chassis-interoprability/spring-cloud-2022.0.x/gateway/src/main/java/org/apache/servicecomb/samples/GatewayApplication.java
new file mode 100644
index 0000000..4177bf0
--- /dev/null
+++ b/java-chassis-interoprability/spring-cloud-2022.0.x/gateway/src/main/java/org/apache/servicecomb/samples/GatewayApplication.java
@@ -0,0 +1,36 @@
+/*
+ * 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.servicecomb.samples;
+
+import org.springframework.boot.WebApplicationType;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+
+@SpringBootApplication
+public class GatewayApplication {
+ public static void main(String[] args) throws Exception {
+ try {
+ new SpringApplicationBuilder()
+ .web(WebApplicationType.REACTIVE)
+ .sources(GatewayApplication.class)
+ .run(args);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/java-chassis-interoprability/spring-cloud-2022.0.x/gateway/src/main/resources/application.yaml b/java-chassis-interoprability/spring-cloud-2022.0.x/gateway/src/main/resources/application.yaml
new file mode 100644
index 0000000..cf7daa4
--- /dev/null
+++ b/java-chassis-interoprability/spring-cloud-2022.0.x/gateway/src/main/resources/application.yaml
@@ -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.
+## ---------------------------------------------------------------------------
+spring:
+ cloud:
+ gateway:
+ routes:
+ - id: provider-java-chassis
+ uri: lb://provider-java-chassis
+ predicates:
+ - Path=/java-chassis/**
+ - id: provider-spring-cloud
+ uri: lb://provider-spring-cloud
+ predicates:
+ - Path=/spring-cloud/**
+
+ httpclient:
+ pool:
+ maxConnections: 50
+ maxIdleTime: PT300S
+ maxLifeTime: PT600S
+ evictionInterval: PT600S
+ type: FIXED
diff --git a/java-chassis-interoprability/spring-cloud-2022.0.x/gateway/src/main/resources/bootstrap.yml b/java-chassis-interoprability/spring-cloud-2022.0.x/gateway/src/main/resources/bootstrap.yml
new file mode 100644
index 0000000..1f631ec
--- /dev/null
+++ b/java-chassis-interoprability/spring-cloud-2022.0.x/gateway/src/main/resources/bootstrap.yml
@@ -0,0 +1,101 @@
+#
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+#
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+server:
+ port: 9090
+
+# Profile:注册中心类型:servicecomb/nacos
+spring:
+ profiles:
+ active: servicecomb
+
+ application:
+ # 微服务名称。 微服务名称定义好以后,后续不能变更。
+ name: gateway
+
+# CSE 注册配置中心
+---
+spring:
+ activate:
+ on-profile: servicecomb
+ cloud:
+ servicecomb:
+ # 微服务的基本信息
+ service:
+ # 微服务名称,和spring.application.name保持一致。
+ name: ${spring.application.name}
+ # 微服务版本号,本示例使用ServiceStage环境变量。建议保留这种配置方式,
+ # 部署的时候,不用手工修改版本号,防止契约注册失败。
+ version: ${CAS_INSTANCE_VERSION:0.0.2}
+ # 应用名称。默认情况下只有应用名称相同的微服务之间才可以相互发现。
+ application: ${CAS_APPLICATION_NAME:basic-application}
+ # 环境名称。只有环境名称相同的微服务之间才可以相互发现。
+ # 可以取值 development, testing, acceptance, production
+ environment: production
+ # 注册发现相关配置
+ discovery:
+ # 注册中心地址,本示例使用ServiceStage环境变量。建议保留这种配置方式,
+ # 部署的时候,不用手工修改地址。
+ address: ${PAAS_CSE_SC_ENDPOINT:http://127.0.0.1:30100}
+ # 微服务向CSE发送心跳间隔时间,单位秒
+ healthCheckInterval: 10
+ # 拉取实例的轮询时间,单位毫秒
+ pollInterval: 15000
+ # 优雅停机设置。优雅停机后,先从注册中心注销自己。这个时间表示注销自己后等待的时间,这个时间后才退出。
+ waitTimeForShutDownInMillis: 15000
+ config:
+ # 配置中心地址,本示例使用ServiceStage环境变量。建议保留这种配置方式,
+ # 部署的时候,不用手工修改地址。
+ serverAddr: ${PAAS_CSE_CC_ENDPOINT:http://127.0.0.1:30110}
+ serverType: kie
+
+# Nacos 注册配置中心
+---
+spring:
+ activate:
+ on-profile: nacos
+ cloud:
+ nacos:
+ discovery:
+ enabled: true
+ server-addr: http://127.0.0.1:8848
+ service: ${spring.application.name}
+ group: ${CAS_APPLICATION_NAME:basic-application}
+ namespace: production
+ config:
+ enabled: true
+ server-addr: http://127.0.0.1:8848
+ group: ${CAS_APPLICATION_NAME:basic-application}
+ namespace: production
+ file-extension: yaml
diff --git a/java-chassis-interoprability/spring-cloud-2022.0.x/gateway/src/main/resources/log4j2.xml b/java-chassis-interoprability/spring-cloud-2022.0.x/gateway/src/main/resources/log4j2.xml
new file mode 100644
index 0000000..5680024
--- /dev/null
+++ b/java-chassis-interoprability/spring-cloud-2022.0.x/gateway/src/main/resources/log4j2.xml
@@ -0,0 +1,59 @@
+<?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.
+-->
+<Configuration>
+ <Properties>
+ <property name="FILE_PATH" value="./logs/gateway"/>
+ </Properties>
+
+ <Appenders>
+ <Console name="Console" target="SYSTEM_OUT">
+ <PatternLayout pattern="%d [%p][%t][%c:%L] %m%n"/>
+ </Console>
+
+ <RollingFile name="AccessLog" fileName="${FILE_PATH}/access.log"
+ filePattern="${FILE_PATH}/access-%d{yyyy-MM-dd}_%i.log.gz">
+ <PatternLayout pattern="%d [%t] %m%n"/>
+ <Policies>
+ <SizeBasedTriggeringPolicy size="20MB"/>
+ </Policies>
+ <DefaultRolloverStrategy max="100"/>
+ </RollingFile>
+
+ <RollingFile name="MetricsLog" fileName="${FILE_PATH}/metrics.log"
+ filePattern="${FILE_PATH}/metrics-%d{yyyy-MM-dd}_%i.log.gz">
+ <PatternLayout pattern="%d [%t] %m%n"/>
+ <Policies>
+ <SizeBasedTriggeringPolicy size="20MB"/>
+ </Policies>
+ <DefaultRolloverStrategy max="100"/>
+ </RollingFile>
+ </Appenders>
+
+ <Loggers>
+ <AsyncLogger name="access_logger" level="INFO" additivity="false">
+ <AppenderRef ref="AccessLog"/>
+ </AsyncLogger>
+ <AsyncLogger name="metrics_logger" level="INFO" additivity="false">
+ <AppenderRef ref="MetricsLog"/>
+ </AsyncLogger>
+
+ <Root level="INFO">
+ <AppenderRef ref="Console"/>
+ </Root>
+ </Loggers>
+</Configuration>
diff --git a/java-chassis-interoprability/spring-cloud-2022.0.x/pom.xml b/java-chassis-interoprability/spring-cloud-2022.0.x/pom.xml
new file mode 100644
index 0000000..fa054d6
--- /dev/null
+++ b/java-chassis-interoprability/spring-cloud-2022.0.x/pom.xml
@@ -0,0 +1,83 @@
+<?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.apache.servicecomb.interoprability</groupId>
+ <artifactId>interoprability-parent</artifactId>
+ <version>3.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>spring-cloud-application-2022.0.x</artifactId>
+ <packaging>pom</packaging>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <spring-cloud.version>2022.0.2</spring-cloud.version>
+ <spring-boot.version>3.0.7</spring-boot.version>
+ <spring-cloud-huawei.version>1.11.0-2022.0.x</spring-cloud-huawei.version>
+ </properties>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>com.huaweicloud</groupId>
+ <artifactId>spring-cloud-huawei-dependencies</artifactId>
+ <version>${spring-cloud-huawei.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-actuator</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>io.micrometer</groupId>
+ <artifactId>micrometer-registry-prometheus</artifactId>
+ </dependency>
+ <!-- using log4j2 -->
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-log4j2</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.lmax</groupId>
+ <artifactId>disruptor</artifactId>
+ <version>3.4.4</version>
+ </dependency>
+ </dependencies>
+
+ <modules>
+ <module>provider</module>
+ <module>gateway</module>
+ </modules>
+
+</project>
diff --git a/java-chassis-interoprability/spring-cloud-2022.0.x/provider/pom.xml b/java-chassis-interoprability/spring-cloud-2022.0.x/provider/pom.xml
new file mode 100644
index 0000000..4d7df6a
--- /dev/null
+++ b/java-chassis-interoprability/spring-cloud-2022.0.x/provider/pom.xml
@@ -0,0 +1,85 @@
+<?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.apache.servicecomb.interoprability</groupId>
+ <artifactId>spring-cloud-application-2022.0.x</artifactId>
+ <version>3.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>spring-cloud-provider-2022.0.x</artifactId>
+ <packaging>jar</packaging>
+
+ <properties>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-web</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ </dependencies>
+
+ <profiles>
+ <profile>
+ <id>servicecomb</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <dependencies>
+ <!-- using service-center & kie -->
+ <dependency>
+ <groupId>com.huaweicloud</groupId>
+ <artifactId>spring-cloud-starter-huawei-service-engine</artifactId>
+ </dependency>
+ </dependencies>
+ </profile>
+ <profile>
+ <id>nacos</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ </activation>
+ <dependencies>
+ <!-- using nacos -->
+ <dependency>
+ <groupId>com.huaweicloud</groupId>
+ <artifactId>spring-cloud-starter-huawei-nacos</artifactId>
+ </dependency>
+ </dependencies>
+ </profile>
+ </profiles>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
diff --git a/java-chassis-interoprability/spring-cloud-2022.0.x/provider/src/main/java/org/apache/servicecomb/samples/JavaChassisManagementEndpoint.java b/java-chassis-interoprability/spring-cloud-2022.0.x/provider/src/main/java/org/apache/servicecomb/samples/JavaChassisManagementEndpoint.java
new file mode 100644
index 0000000..b327ae4
--- /dev/null
+++ b/java-chassis-interoprability/spring-cloud-2022.0.x/provider/src/main/java/org/apache/servicecomb/samples/JavaChassisManagementEndpoint.java
@@ -0,0 +1,74 @@
+/*
+ * 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.servicecomb.samples;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.nio.charset.StandardCharsets;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.servicecomb.foundation.common.utils.ResourceUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cloud.client.serviceregistry.Registration;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping(("/scb/management"))
+public class JavaChassisManagementEndpoint {
+ private static final Logger LOGGER = LoggerFactory.getLogger(JavaChassisManagementEndpoint.class);
+
+ @Autowired
+ private Registration registration;
+
+ @GetMapping(path = "/health")
+ public boolean health(@RequestParam("instanceId") String instanceId,
+ @RequestParam("registryName") String registryName) {
+ return "sc-registry".equals(registryName) && registration.getInstanceId().equals(instanceId);
+ }
+
+ @PostMapping(path = "/schema/contents")
+ public Map<String, String> schemaContents() {
+ try {
+ List<URI> resourceUris = ResourceUtil.findResourcesBySuffix("export", ".yaml");
+ Map<String, String> result = new HashMap<>(resourceUris.size());
+ for (URI uri : resourceUris) {
+ String path = uri.toURL().getPath();
+ String[] segments = path.split("/");
+ if (segments.length < 2 || !"export".equals(segments[segments.length - 2])) {
+ continue;
+ }
+ result.put(segments[segments.length - 1].substring(0, segments[segments.length - 1].indexOf(".yaml")),
+ IOUtils.toString(uri, StandardCharsets.UTF_8));
+ }
+ return result;
+ } catch (IOException | URISyntaxException e) {
+ LOGGER.error("Load schema ids failed from microservices. {}.", e.getMessage());
+ return Collections.emptyMap();
+ }
+ }
+}
diff --git a/java-chassis-interoprability/spring-cloud-2022.0.x/provider/src/main/java/org/apache/servicecomb/samples/JavaChassisService.java b/java-chassis-interoprability/spring-cloud-2022.0.x/provider/src/main/java/org/apache/servicecomb/samples/JavaChassisService.java
new file mode 100644
index 0000000..bc0c8fd
--- /dev/null
+++ b/java-chassis-interoprability/spring-cloud-2022.0.x/provider/src/main/java/org/apache/servicecomb/samples/JavaChassisService.java
@@ -0,0 +1,27 @@
+/*
+ * 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.servicecomb.samples;
+
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+@FeignClient(name = "provider-java-chassis", path = "/java-chassis")
+public interface JavaChassisService {
+ @GetMapping("/sayHelloInternal")
+ String sayHelloInternal(@RequestParam("name") String name);
+}
diff --git a/java-chassis-interoprability/spring-cloud-2022.0.x/provider/src/main/java/org/apache/servicecomb/samples/ProviderApplication.java b/java-chassis-interoprability/spring-cloud-2022.0.x/provider/src/main/java/org/apache/servicecomb/samples/ProviderApplication.java
new file mode 100644
index 0000000..65e070b
--- /dev/null
+++ b/java-chassis-interoprability/spring-cloud-2022.0.x/provider/src/main/java/org/apache/servicecomb/samples/ProviderApplication.java
@@ -0,0 +1,38 @@
+/*
+ * 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.servicecomb.samples;
+
+import org.springframework.boot.WebApplicationType;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+import org.springframework.cloud.openfeign.EnableFeignClients;
+
+@SpringBootApplication
+@EnableFeignClients
+public class ProviderApplication {
+ public static void main(String[] args) throws Exception {
+ try {
+ new SpringApplicationBuilder()
+ .web(WebApplicationType.SERVLET)
+ .sources(ProviderApplication.class)
+ .run(args);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/java-chassis-interoprability/spring-cloud-2022.0.x/provider/src/main/java/org/apache/servicecomb/samples/ProviderController.java b/java-chassis-interoprability/spring-cloud-2022.0.x/provider/src/main/java/org/apache/servicecomb/samples/ProviderController.java
new file mode 100644
index 0000000..d3c1aae
--- /dev/null
+++ b/java-chassis-interoprability/spring-cloud-2022.0.x/provider/src/main/java/org/apache/servicecomb/samples/ProviderController.java
@@ -0,0 +1,45 @@
+/*
+ * 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.servicecomb.samples;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping(path = "/spring-cloud")
+public class ProviderController {
+ private JavaChassisService javaChassisService;
+
+ @Autowired
+ public void setJavaChassisService(JavaChassisService javaChassisService) {
+ this.javaChassisService = javaChassisService;
+ }
+
+ @GetMapping("/sayHello")
+ public String sayHello(@RequestParam("name") String name) throws Exception {
+ return javaChassisService.sayHelloInternal(name);
+ }
+
+ @GetMapping("/sayHelloInternal")
+ public String sayHelloInternal(@RequestParam("name") String name) throws Exception {
+ return "Hello from Spring Cloud, " + name;
+ }
+}
diff --git a/java-chassis-interoprability/spring-cloud-2022.0.x/provider/src/main/resources/bootstrap.yml b/java-chassis-interoprability/spring-cloud-2022.0.x/provider/src/main/resources/bootstrap.yml
new file mode 100644
index 0000000..e0e9398
--- /dev/null
+++ b/java-chassis-interoprability/spring-cloud-2022.0.x/provider/src/main/resources/bootstrap.yml
@@ -0,0 +1,84 @@
+#
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+server:
+ port: 9092
+
+# Profile:注册中心类型:servicecomb/nacos
+spring:
+ profiles:
+ active: servicecomb # 注册中心类型:servicecomb 或者 nacos
+
+ application:
+ # 微服务名称。 微服务名称定义好以后,后续不能变更。
+ name: provider-spring-cloud
+
+# CSE 注册配置中心
+---
+spring:
+ activate:
+ on-profile: servicecomb
+ cloud:
+ servicecomb:
+ # 微服务的基本信息
+ service:
+ # 微服务名称,和spring.application.name保持一致。
+ name: ${spring.application.name}
+ # 微服务版本号,本示例使用ServiceStage环境变量。建议保留这种配置方式,
+ # 部署的时候,不用手工修改版本号,防止契约注册失败。
+ version: ${CAS_INSTANCE_VERSION:0.0.2}
+ # 应用名称。默认情况下只有应用名称相同的微服务之间才可以相互发现。
+ application: ${CAS_APPLICATION_NAME:basic-application}
+ # 环境名称。只有环境名称相同的微服务之间才可以相互发现。
+ # 可以取值 development, testing, acceptance, production
+ environment: production
+ # 注册发现相关配置
+ discovery:
+ # 注册中心地址,本示例使用ServiceStage环境变量。建议保留这种配置方式,
+ # 部署的时候,不用手工修改地址。
+ address: ${PAAS_CSE_SC_ENDPOINT:http://127.0.0.1:30100}
+ # 微服务向CSE发送心跳间隔时间,单位秒
+ healthCheckInterval: 10
+ # 拉取实例的轮询时间,单位毫秒
+ pollInterval: 15000
+ # 优雅停机设置。优雅停机后,先从注册中心注销自己。这个时间表示注销自己后等待的时间,这个时间后才退出。
+ waitTimeForShutDownInMillis: 15000
+ config:
+ # 配置中心地址,本示例使用ServiceStage环境变量。建议保留这种配置方式,
+ # 部署的时候,不用手工修改地址。
+ serverAddr: ${PAAS_CSE_CC_ENDPOINT:http://127.0.0.1:30110}
+ serverType: kie
+
+# Nacos 注册配置中心
+---
+spring:
+ activate:
+ on-profile: nacos
+ cloud:
+ nacos:
+ discovery:
+ enabled: true
+ server-addr: http://127.0.0.1:8848
+ service: ${spring.application.name}
+ group: ${CAS_APPLICATION_NAME:basic-application}
+ namespace: production
+ config:
+ enabled: true
+ server-addr: http://127.0.0.1:8848
+ group: ${CAS_APPLICATION_NAME:basic-application}
+ namespace: production
+ file-extension: yaml
diff --git a/java-chassis-interoprability/spring-cloud-2022.0.x/provider/src/main/resources/export/ProviderController.yaml b/java-chassis-interoprability/spring-cloud-2022.0.x/provider/src/main/resources/export/ProviderController.yaml
new file mode 100644
index 0000000..462bfe4
--- /dev/null
+++ b/java-chassis-interoprability/spring-cloud-2022.0.x/provider/src/main/resources/export/ProviderController.yaml
@@ -0,0 +1,52 @@
+openapi: 3.0.1
+info:
+ title: swagger definition for org.apache.servicecomb.samples.ProviderController
+ version: 1.0.0
+servers:
+- url: /spring-cloud
+paths:
+ /sayHello:
+ get:
+ operationId: sayHello
+ parameters:
+ - name: name
+ in: query
+ required: true
+ schema:
+ type: string
+ responses:
+ "200":
+ description: response of 200
+ content:
+ application/json:
+ schema:
+ type: string
+ application/protobuf:
+ schema:
+ type: string
+ text/plain:
+ schema:
+ type: string
+ /sayHelloInternal:
+ get:
+ operationId: sayHelloInternal
+ parameters:
+ - name: name
+ in: query
+ required: true
+ schema:
+ type: string
+ responses:
+ "200":
+ description: response of 200
+ content:
+ application/json:
+ schema:
+ type: string
+ application/protobuf:
+ schema:
+ type: string
+ text/plain:
+ schema:
+ type: string
+components: {}
diff --git a/java-chassis-interoprability/spring-cloud-2022.0.x/provider/src/main/resources/log4j2.xml b/java-chassis-interoprability/spring-cloud-2022.0.x/provider/src/main/resources/log4j2.xml
new file mode 100644
index 0000000..4105c13
--- /dev/null
+++ b/java-chassis-interoprability/spring-cloud-2022.0.x/provider/src/main/resources/log4j2.xml
@@ -0,0 +1,59 @@
+<?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.
+-->
+<Configuration>
+ <Properties>
+ <property name="FILE_PATH" value="./logs/provider-spring-cloud"/>
+ </Properties>
+
+ <Appenders>
+ <Console name="Console" target="SYSTEM_OUT">
+ <PatternLayout pattern="%d [%p][%t][%c:%L] %m%n"/>
+ </Console>
+
+ <RollingFile name="AccessLog" fileName="${FILE_PATH}/access.log"
+ filePattern="${FILE_PATH}/access-%d{yyyy-MM-dd}_%i.log.gz">
+ <PatternLayout pattern="%d [%t] %m%n"/>
+ <Policies>
+ <SizeBasedTriggeringPolicy size="20MB"/>
+ </Policies>
+ <DefaultRolloverStrategy max="100"/>
+ </RollingFile>
+
+ <RollingFile name="MetricsLog" fileName="${FILE_PATH}/metrics.log"
+ filePattern="${FILE_PATH}/metrics-%d{yyyy-MM-dd}_%i.log.gz">
+ <PatternLayout pattern="%d [%t] %m%n"/>
+ <Policies>
+ <SizeBasedTriggeringPolicy size="20MB"/>
+ </Policies>
+ <DefaultRolloverStrategy max="100"/>
+ </RollingFile>
+ </Appenders>
+
+ <Loggers>
+ <AsyncLogger name="access_logger" level="INFO" additivity="false">
+ <AppenderRef ref="AccessLog"/>
+ </AsyncLogger>
+ <AsyncLogger name="metrics_logger" level="INFO" additivity="false">
+ <AppenderRef ref="MetricsLog"/>
+ </AsyncLogger>
+
+ <Root level="INFO">
+ <AppenderRef ref="Console"/>
+ </Root>
+ </Loggers>
+</Configuration>