Skip to content

Commit 1d22ee6

Browse files
hoxton agent init (#119)
Co-authored-by: shedfreewu <[email protected]>
1 parent e8b9b62 commit 1d22ee6

File tree

23 files changed

+1274
-2
lines changed

23 files changed

+1274
-2
lines changed

polaris-agent-examples/spring-cloud-plugins-examples/pom.xml

+3-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
<packaging>pom</packaging>
1616
<modules>
1717
<module>spring-cloud-2021-examples</module>
18-
<module>spring-cloud-2020-examples</module>
19-
</modules>
18+
<module>spring-cloud-2020-examples</module>
19+
<module>spring-cloud-hoxton-examples</module>
20+
</modules>
2021

2122
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<artifactId>spring-cloud-plugins-examples</artifactId>
7+
<groupId>com.tencent.polaris</groupId>
8+
<version>${revision}</version>
9+
<relativePath>../pom.xml</relativePath>
10+
</parent>
11+
<modelVersion>4.0.0</modelVersion>
12+
13+
<artifactId>spring-cloud-hoxton-examples</artifactId>
14+
15+
<packaging>pom</packaging>
16+
17+
<modules>
18+
<module>quickstart-examples</module>
19+
</modules>
20+
21+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<groupId>org.springframework.boot</groupId>
7+
<artifactId>spring-boot-starter-parent</artifactId>
8+
<version>2.3.7.RELEASE</version>
9+
<relativePath/>
10+
</parent>
11+
<modelVersion>4.0.0</modelVersion>
12+
13+
<name>hoxton-consumer</name>
14+
<description>Demo Consumer Project For Spring Cloud Alibaba</description>
15+
<artifactId>hoxton-consumer</artifactId>
16+
<packaging>jar</packaging>
17+
18+
<dependencyManagement>
19+
<dependencies>
20+
<dependency>
21+
<groupId>com.alibaba.cloud</groupId>
22+
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
23+
<version>2.2.1.RELEASE</version>
24+
<type>pom</type>
25+
<scope>import</scope>
26+
</dependency>
27+
28+
<dependency>
29+
<groupId>org.springframework.cloud</groupId>
30+
<artifactId>spring-cloud-dependencies</artifactId>
31+
<version>Hoxton.SR12</version>
32+
<type>pom</type>
33+
<scope>import</scope>
34+
</dependency>
35+
</dependencies>
36+
</dependencyManagement>
37+
38+
<dependencies>
39+
<!-- 简单的 Spring Cloud Web 依赖 -->
40+
<dependency>
41+
<groupId>org.springframework.boot</groupId>
42+
<artifactId>spring-boot-starter-web</artifactId>
43+
</dependency>
44+
45+
<!-- 引入 Spring Cloud Alibaba 的服务注册发现依赖 -->
46+
<dependency>
47+
<groupId>com.alibaba.cloud</groupId>
48+
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
49+
</dependency>
50+
51+
<dependency>
52+
<groupId>org.springframework.cloud</groupId>
53+
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
54+
</dependency>
55+
</dependencies>
56+
57+
<build>
58+
<plugins>
59+
<plugin>
60+
<groupId>org.springframework.boot</groupId>
61+
<artifactId>spring-boot-maven-plugin</artifactId>
62+
<configuration>
63+
<executable>true</executable>
64+
</configuration>
65+
<executions>
66+
<execution>
67+
<goals>
68+
<goal>repackage</goal>
69+
</goals>
70+
</execution>
71+
</executions>
72+
</plugin>
73+
</plugins>
74+
</build>
75+
76+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* Tencent is pleased to support the open source community by making Polaris available.
3+
*
4+
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
5+
*
6+
* Licensed under the BSD 3-Clause License (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* https://opensource.org/licenses/BSD-3-Clause
11+
*
12+
* Unless required by applicable law or agreed to in writing, software distributed
13+
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
14+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
15+
* specific language governing permissions and limitations under the License.
16+
*/
17+
18+
package cn.polarismesh.agent.examples.alibaba.cloud.cloud;
19+
20+
import org.springframework.boot.SpringApplication;
21+
import org.springframework.boot.autoconfigure.SpringBootApplication;
22+
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
23+
import org.springframework.context.annotation.Bean;
24+
import org.springframework.http.ResponseEntity;
25+
import org.springframework.web.bind.annotation.GetMapping;
26+
import org.springframework.web.bind.annotation.PathVariable;
27+
import org.springframework.web.bind.annotation.RestController;
28+
import org.springframework.web.client.RestTemplate;
29+
30+
/**
31+
* @author <a href="mailto:[email protected]">liaochuntao</a>
32+
*/
33+
@SpringBootApplication
34+
public class ConsumerApplication {
35+
36+
public static void main(String[] args) {
37+
SpringApplication.run(ConsumerApplication.class, args);
38+
}
39+
40+
@LoadBalanced
41+
@Bean
42+
public RestTemplate restTemplate() {
43+
return new RestTemplate();
44+
}
45+
46+
@RestController
47+
public static class EchoController {
48+
49+
private RestTemplate template;
50+
51+
public EchoController(RestTemplate restTemplate) {
52+
this.template = restTemplate;
53+
}
54+
55+
@GetMapping("/echo/{str}")
56+
public ResponseEntity<String> rest(@PathVariable String str) {
57+
ResponseEntity<String> response = template.getForEntity("http://service-provider/echo/" + str,
58+
String.class);
59+
return response;
60+
}
61+
62+
63+
}
64+
65+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
server.port=0
2+
spring.application.name=service-consumer
3+
spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848
4+
spring.cloud.nacos.discovery.enabled=true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<artifactId>spring-cloud-hoxton-examples</artifactId>
7+
<groupId>com.tencent.polaris</groupId>
8+
<version>${revision}</version>
9+
<relativePath>../pom.xml</relativePath>
10+
</parent>
11+
<modelVersion>4.0.0</modelVersion>
12+
13+
<artifactId>hoxton-quickstart-examples</artifactId>
14+
<packaging>pom</packaging>
15+
<modules>
16+
<module>provider</module>
17+
<module>consumer</module>
18+
</modules>
19+
20+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<groupId>org.springframework.boot</groupId>
7+
<artifactId>spring-boot-starter-parent</artifactId>
8+
<version>2.3.7.RELEASE</version>
9+
<relativePath/>
10+
</parent>
11+
<modelVersion>4.0.0</modelVersion>
12+
13+
<name>hoxton-provider</name>
14+
<description>Demo Provider Project For Spring Cloud Alibaba</description>
15+
<artifactId>hoxton-provider</artifactId>
16+
<packaging>jar</packaging>
17+
18+
<dependencyManagement>
19+
<dependencies>
20+
<dependency>
21+
<groupId>com.alibaba.cloud</groupId>
22+
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
23+
<version>2.2.1.RELEASE</version>
24+
<type>pom</type>
25+
<scope>import</scope>
26+
</dependency>
27+
28+
<dependency>
29+
<groupId>org.springframework.cloud</groupId>
30+
<artifactId>spring-cloud-dependencies</artifactId>
31+
<version>Hoxton.SR12</version>
32+
<type>pom</type>
33+
<scope>import</scope>
34+
</dependency>
35+
</dependencies>
36+
</dependencyManagement>
37+
38+
<dependencies>
39+
<!-- 简单的 Spring Cloud Web 依赖 -->
40+
<dependency>
41+
<groupId>org.springframework.boot</groupId>
42+
<artifactId>spring-boot-starter-web</artifactId>
43+
</dependency>
44+
45+
<!-- 引入 Spring Cloud Alibaba 的服务注册发现依赖 -->
46+
<dependency>
47+
<groupId>com.alibaba.cloud</groupId>
48+
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
49+
</dependency>
50+
</dependencies>
51+
52+
<build>
53+
<plugins>
54+
<plugin>
55+
<groupId>org.springframework.boot</groupId>
56+
<artifactId>spring-boot-maven-plugin</artifactId>
57+
<configuration>
58+
<executable>true</executable>
59+
</configuration>
60+
<executions>
61+
<execution>
62+
<goals>
63+
<goal>repackage</goal>
64+
</goals>
65+
</execution>
66+
</executions>
67+
</plugin>
68+
</plugins>
69+
</build>
70+
71+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* Tencent is pleased to support the open source community by making Polaris available.
3+
*
4+
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
5+
*
6+
* Licensed under the BSD 3-Clause License (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* https://opensource.org/licenses/BSD-3-Clause
11+
*
12+
* Unless required by applicable law or agreed to in writing, software distributed
13+
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
14+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
15+
* specific language governing permissions and limitations under the License.
16+
*/
17+
18+
package cn.polarismesh.agent.examples.alibaba.cloud.cloud;
19+
20+
21+
import org.springframework.boot.SpringApplication;
22+
import org.springframework.boot.autoconfigure.SpringBootApplication;
23+
import org.springframework.cloud.client.serviceregistry.Registration;
24+
import org.springframework.web.bind.annotation.GetMapping;
25+
import org.springframework.web.bind.annotation.PathVariable;
26+
import org.springframework.web.bind.annotation.RestController;
27+
28+
/**
29+
* @author <a href="mailto:[email protected]">liaochuntao</a>
30+
*/
31+
@SpringBootApplication
32+
public class ProviderApplication {
33+
34+
public static void main(String[] args) {
35+
SpringApplication.run(ProviderApplication.class, args);
36+
}
37+
38+
@RestController
39+
public static class EchoController {
40+
41+
private Registration registration;
42+
43+
public EchoController(Registration registration) {
44+
this.registration = registration;
45+
}
46+
47+
@GetMapping("/echo/{string}")
48+
public String echo(@PathVariable String string) {
49+
String sb = "Hello, I'm provider, receive msg : "
50+
+ string
51+
+ "my metadata : "
52+
+ registration.getMetadata();
53+
return sb;
54+
}
55+
56+
}
57+
58+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
server.port=0
2+
spring.application.name=service-provider
3+
spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848
4+
spring.cloud.nacos.discovery.enabled=true

polaris-agent-plugins/spring-cloud-plugins/pom.xml

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<modules>
1717
<module>spring-cloud-2021-plugin</module>
1818
<module>spring-cloud-2020-plugin</module>
19+
<module>spring-cloud-hoxton-plugin</module>
1920
</modules>
2021

2122
<properties>

0 commit comments

Comments
 (0)