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 2023/02/01 13:03:41 UTC
[servicecomb-java-chassis] branch master updated: [SCB-2757]remove spring initializer support and use spring boot to st… (#3610)
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-java-chassis.git
The following commit(s) were added to refs/heads/master by this push:
new 4a6c0c241 [SCB-2757]remove spring initializer support and use spring boot to st… (#3610)
4a6c0c241 is described below
commit 4a6c0c24178fe9891e8402667000af4eae03e28d
Author: liubao68 <bi...@qq.com>
AuthorDate: Wed Feb 1 21:03:35 2023 +0800
[SCB-2757]remove spring initializer support and use spring boot to st… (#3610)
---
demo/demo-crossapp/crossapp-client/pom.xml | 8 -
.../servicecomb/demo/crossapp/CrossappClient.java | 18 ++-
.../servicecomb/demo/crossapp/CrossAppIT.java | 7 +-
demo/demo-crossapp/crossapp-server/pom.xml | 4 +-
.../servicecomb/demo/crossapp/CrossappServer.java | 8 +-
demo/demo-crossapp/pom.xml | 4 +
demo/demo-edge/authentication/pom.xml | 4 +-
.../demo/edge/authentication/AuthMain.java | 7 +-
demo/demo-edge/business-1-1-0/pom.xml | 4 +-
.../demo/edge/business/BusinessMain_V1_1_0.java | 7 +-
demo/demo-edge/business-1.0.0/pom.xml | 4 +-
.../demo/edge/business/BusinessMain_V1_0_0.java | 7 +-
demo/demo-edge/business-2.0.0/pom.xml | 4 +-
.../demo/edge/business/BusinessMain_V2_0_0.java | 7 +-
.../demo/edge/consumer/ConsumerMain.java | 11 +-
.../servicecomb/demo/edge/consumer/EdgeDemoIT.java | 7 +-
demo/demo-edge/edge-service/pom.xml | 4 +-
.../org/apache/servicecomb/demo/edge/EdgeMain.java | 7 +-
demo/demo-edge/pom.xml | 4 +
.../servicecomb/demo/filter/FilterClient.java | 7 +-
.../demo/filter/retry/FilterClientIT.java | 7 +-
demo/demo-filter/filter-server/pom.xml | 4 +-
.../servicecomb/demo/filter/FilterServer.java | 7 +-
demo/demo-filter/pom.xml | 4 +
demo/demo-jaxrs/jaxrs-client/pom.xml | 8 -
.../apache/servicecomb/demo/jaxrs/JaxrsClient.java | 8 +-
.../org/apache/servicecomb/demo/jaxrs/JaxrsIT.java | 7 +-
demo/demo-jaxrs/jaxrs-server/pom.xml | 4 +-
.../apache/servicecomb/demo/jaxrs/JaxrsServer.java | 9 +-
demo/demo-jaxrs/pom.xml | 4 +
demo/demo-multiple/a-client/pom.xml | 1 +
.../demo/multiple/a/client/AClientMain.java | 6 +-
demo/demo-multiple/a-server/pom.xml | 1 +
.../demo/multiple/a/server/AServerMain.java | 7 +-
demo/demo-multiple/b-client/pom.xml | 1 +
.../demo/multiple/b/client/BClientMain.java | 6 +-
.../demo/multiple/b/server/BServerMain.java | 7 +-
demo/demo-multiple/multiple-client/pom.xml | 2 +-
.../demo/multiple/client/MultipleClient.java | 10 +-
.../demo/multiple/client/MultipleIT.java} | 11 +-
demo/demo-multiple/multiple-server/pom.xml | 5 +-
.../demo/multiple/server/MultipleServer.java | 7 +-
demo/demo-multiple/pom.xml | 4 +
.../servicecomb/demo/pojo/client/PojoClient.java | 8 +-
.../org/apache/servicecomb/demo/pojo/PojoIT.java | 7 +-
demo/demo-pojo/pojo-server/pom.xml | 4 +-
.../servicecomb/demo/pojo/server/PojoServer.java | 7 +-
demo/demo-pojo/pom.xml | 4 +
.../src/main/resources/microservice.yaml | 10 +-
.../demo-spring-boot-jaxrs-client/pom.xml | 72 ---------
.../springboot/jaxrs/client/JaxrsClient.java | 41 -----
.../src/main/resources/application.yml | 35 -----
.../springboot/jaxrs/SpringBootJaxrsIT.java | 43 -----
.../demo-spring-boot-jaxrs-server/pom.xml | 89 -----------
.../springboot/jaxrs/server/JaxrsServer.java | 37 -----
.../src/main/resources/application.yml | 34 ----
demo/demo-spring-boot-provider/pom.xml | 64 --------
.../springboot/pojo/client/PojoClient.java | 3 +-
.../src/main/resources/application.yml | 3 +-
.../springboot/pojo/client/PojoClientIT.java | 10 +-
.../demo-spring-boot-pojo-server/pom.xml | 3 +-
.../demo-spring-boot-springmvc-client/pom.xml | 14 +-
.../springmvc/client/PlaceHolderSchemaTest.java | 2 +-
.../springmvc/client/SpringmvcClient.java | 7 +-
.../src/main/resources/application.yml | 4 +
.../springmvc/client/SpringmvcClientIT.java | 7 +-
.../demo-spring-boot-springmvc-server/pom.xml | 2 +-
.../src/main/resources/application.yml | 6 +-
.../src/main/resources/microservice.yaml | 23 ++-
demo/demo-springmvc/pom.xml | 4 +
.../demo/springmvc/SpringmvcClient.java | 18 +--
.../src/main/resources/microservice.yaml | 6 +-
.../servicecomb/demo/springmvc/SpringMvcIT.java | 7 +-
demo/demo-springmvc/springmvc-server/pom.xml | 4 +-
.../demo/springmvc/SpringmvcServer.java | 7 +-
.../pom.xml | 2 +-
demo/pom.xml | 1 -
.../foundation/common/utils/BeanUtils.java | 82 ----------
.../foundation/common/utils/ResourceUtil.java | 14 +-
.../src/test/java/TestNoPackageMain.java | 45 ------
.../foundation/common/utils/ResourceUtilTest.java | 12 --
.../foundation/common/utils/TestBeanUtils.java | 173 ---------------------
parents/default/pom.xml | 12 +-
pom.xml | 12 +-
.../java-chassis-spring-boot-starter/pom.xml | 4 +-
.../rest/servlet/CseDispatcherServlet.java | 31 ----
.../rest/servlet/CseXmlWebApplicationContext.java | 85 ----------
.../rest/servlet/RestServletContextListener.java | 52 -------
.../servlet/TestCseXmlWebApplicationContext.java | 131 ----------------
.../servlet/TestRestServletContextListener.java | 57 -------
90 files changed, 313 insertions(+), 1248 deletions(-)
diff --git a/demo/demo-crossapp/crossapp-client/pom.xml b/demo/demo-crossapp/crossapp-client/pom.xml
index 70468e4c1..73d7375cd 100644
--- a/demo/demo-crossapp/crossapp-client/pom.xml
+++ b/demo/demo-crossapp/crossapp-client/pom.xml
@@ -46,14 +46,6 @@
<properties>
<demo.main>org.apache.servicecomb.demo.crossapp.CrossappClient</demo.main>
</properties>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
<profiles>
<profile>
diff --git a/demo/demo-crossapp/crossapp-client/src/main/java/org/apache/servicecomb/demo/crossapp/CrossappClient.java b/demo/demo-crossapp/crossapp-client/src/main/java/org/apache/servicecomb/demo/crossapp/CrossappClient.java
index 0420cc73d..5c821665b 100644
--- a/demo/demo-crossapp/crossapp-client/src/main/java/org/apache/servicecomb/demo/crossapp/CrossappClient.java
+++ b/demo/demo-crossapp/crossapp-client/src/main/java/org/apache/servicecomb/demo/crossapp/CrossappClient.java
@@ -22,34 +22,33 @@ import java.util.TreeSet;
import org.apache.servicecomb.core.provider.consumer.InvokerUtils;
import org.apache.servicecomb.demo.TestMgr;
-import org.apache.servicecomb.foundation.common.utils.BeanUtils;
import org.apache.servicecomb.provider.pojo.RpcReference;
import org.apache.servicecomb.provider.springmvc.reference.RestTemplateBuilder;
+import org.apache.servicecomb.springboot2.starter.EnableServiceComb;
+import org.springframework.boot.WebApplicationType;
+import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
-import org.springframework.stereotype.Component;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
-@Component
+@EnableServiceComb
public class CrossappClient {
@RpcReference(microserviceName = "appServer:appService", schemaId = "helloworld")
private static HelloWorld helloWorld;
public static void main(String[] args) throws Exception {
- System.setProperty("sun.net.http.allowRestrictedHeaders", "true");
- BeanUtils.init();
+ new SpringApplicationBuilder(CrossappClient.class).web(WebApplicationType.NONE).run(args);
run();
-
- TestMgr.summary();
- System.setProperty("sun.net.http.allowRestrictedHeaders", "false");
}
@SuppressWarnings({"deprecation"})
public static void run() {
+ System.setProperty("sun.net.http.allowRestrictedHeaders", "true");
+
Object result = InvokerUtils.syncInvoke("appServer:appService", "helloworld", "sayHello", null);
TestMgr.check("hello world", result);
@@ -63,6 +62,9 @@ public class CrossappClient {
TestMgr.check("hello world", result);
testCorsHandler();
+
+ TestMgr.summary();
+ System.setProperty("sun.net.http.allowRestrictedHeaders", "false");
}
private static void testCorsHandler() {
diff --git a/demo/demo-crossapp/crossapp-client/src/test/java/org/apache/servicecomb/demo/crossapp/CrossAppIT.java b/demo/demo-crossapp/crossapp-client/src/test/java/org/apache/servicecomb/demo/crossapp/CrossAppIT.java
index f1142479b..54b02c90a 100644
--- a/demo/demo-crossapp/crossapp-client/src/test/java/org/apache/servicecomb/demo/crossapp/CrossAppIT.java
+++ b/demo/demo-crossapp/crossapp-client/src/test/java/org/apache/servicecomb/demo/crossapp/CrossAppIT.java
@@ -21,7 +21,12 @@ import org.apache.servicecomb.demo.TestMgr;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+@ExtendWith(SpringExtension.class)
+@SpringBootTest(classes = CrossappClient.class)
public class CrossAppIT {
@BeforeEach
@@ -31,7 +36,7 @@ public class CrossAppIT {
@Test
public void clientGetsNoError() throws Exception {
- CrossappClient.main(new String[0]);
+ CrossappClient.run();
Assertions.assertTrue(TestMgr.errors().isEmpty());
}
diff --git a/demo/demo-crossapp/crossapp-server/pom.xml b/demo/demo-crossapp/crossapp-server/pom.xml
index 15d04177e..8beed1c14 100644
--- a/demo/demo-crossapp/crossapp-server/pom.xml
+++ b/demo/demo-crossapp/crossapp-server/pom.xml
@@ -45,8 +45,8 @@
<build>
<plugins>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
diff --git a/demo/demo-crossapp/crossapp-server/src/main/java/org/apache/servicecomb/demo/crossapp/CrossappServer.java b/demo/demo-crossapp/crossapp-server/src/main/java/org/apache/servicecomb/demo/crossapp/CrossappServer.java
index 46b32deeb..55a383c4d 100644
--- a/demo/demo-crossapp/crossapp-server/src/main/java/org/apache/servicecomb/demo/crossapp/CrossappServer.java
+++ b/demo/demo-crossapp/crossapp-server/src/main/java/org/apache/servicecomb/demo/crossapp/CrossappServer.java
@@ -17,11 +17,13 @@
package org.apache.servicecomb.demo.crossapp;
-import org.apache.servicecomb.foundation.common.utils.BeanUtils;
+import org.apache.servicecomb.springboot2.starter.EnableServiceComb;
+import org.springframework.boot.WebApplicationType;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+@EnableServiceComb
public class CrossappServer {
-
public static void main(String[] args) throws Exception {
- BeanUtils.init();
+ new SpringApplicationBuilder(CrossappServer.class).web(WebApplicationType.NONE).run(args);
}
}
diff --git a/demo/demo-crossapp/pom.xml b/demo/demo-crossapp/pom.xml
index 043a0e07c..b55affcf1 100644
--- a/demo/demo-crossapp/pom.xml
+++ b/demo/demo-crossapp/pom.xml
@@ -38,6 +38,10 @@
<groupId>org.apache.servicecomb</groupId>
<artifactId>registry-service-center</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.servicecomb</groupId>
+ <artifactId>java-chassis-spring-boot-starter-standalone</artifactId>
+ </dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
diff --git a/demo/demo-edge/authentication/pom.xml b/demo/demo-edge/authentication/pom.xml
index b09764458..f59c500ef 100644
--- a/demo/demo-edge/authentication/pom.xml
+++ b/demo/demo-edge/authentication/pom.xml
@@ -41,8 +41,8 @@
<build>
<plugins>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
diff --git a/demo/demo-edge/authentication/src/main/java/org/apache/servicecomb/demo/edge/authentication/AuthMain.java b/demo/demo-edge/authentication/src/main/java/org/apache/servicecomb/demo/edge/authentication/AuthMain.java
index edc96b056..aeb485861 100644
--- a/demo/demo-edge/authentication/src/main/java/org/apache/servicecomb/demo/edge/authentication/AuthMain.java
+++ b/demo/demo-edge/authentication/src/main/java/org/apache/servicecomb/demo/edge/authentication/AuthMain.java
@@ -17,10 +17,13 @@
package org.apache.servicecomb.demo.edge.authentication;
-import org.apache.servicecomb.foundation.common.utils.BeanUtils;
+import org.apache.servicecomb.springboot2.starter.EnableServiceComb;
+import org.springframework.boot.WebApplicationType;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+@EnableServiceComb
public class AuthMain {
public static void main(String[] args) throws Exception {
- BeanUtils.init();
+ new SpringApplicationBuilder(AuthMain.class).web(WebApplicationType.NONE).run(args);
}
}
diff --git a/demo/demo-edge/business-1-1-0/pom.xml b/demo/demo-edge/business-1-1-0/pom.xml
index 391e8821c..9ebe914e4 100644
--- a/demo/demo-edge/business-1-1-0/pom.xml
+++ b/demo/demo-edge/business-1-1-0/pom.xml
@@ -51,8 +51,8 @@
<build>
<plugins>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
diff --git a/demo/demo-edge/business-1-1-0/src/main/java/org/apache/servicecomb/demo/edge/business/BusinessMain_V1_1_0.java b/demo/demo-edge/business-1-1-0/src/main/java/org/apache/servicecomb/demo/edge/business/BusinessMain_V1_1_0.java
index 32993adf4..792922866 100644
--- a/demo/demo-edge/business-1-1-0/src/main/java/org/apache/servicecomb/demo/edge/business/BusinessMain_V1_1_0.java
+++ b/demo/demo-edge/business-1-1-0/src/main/java/org/apache/servicecomb/demo/edge/business/BusinessMain_V1_1_0.java
@@ -17,10 +17,13 @@
package org.apache.servicecomb.demo.edge.business;
-import org.apache.servicecomb.foundation.common.utils.BeanUtils;
+import org.apache.servicecomb.springboot2.starter.EnableServiceComb;
+import org.springframework.boot.WebApplicationType;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+@EnableServiceComb
public class BusinessMain_V1_1_0 {
public static void main(String[] args) throws Exception {
- BeanUtils.init();
+ new SpringApplicationBuilder(BusinessMain_V1_1_0.class).web(WebApplicationType.NONE).run(args);
}
}
diff --git a/demo/demo-edge/business-1.0.0/pom.xml b/demo/demo-edge/business-1.0.0/pom.xml
index 46ea333bb..1fb6bdd99 100644
--- a/demo/demo-edge/business-1.0.0/pom.xml
+++ b/demo/demo-edge/business-1.0.0/pom.xml
@@ -53,8 +53,8 @@
<build>
<plugins>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
diff --git a/demo/demo-edge/business-1.0.0/src/main/java/org/apache/servicecomb/demo/edge/business/BusinessMain_V1_0_0.java b/demo/demo-edge/business-1.0.0/src/main/java/org/apache/servicecomb/demo/edge/business/BusinessMain_V1_0_0.java
index da7fe7c20..eeea509b2 100644
--- a/demo/demo-edge/business-1.0.0/src/main/java/org/apache/servicecomb/demo/edge/business/BusinessMain_V1_0_0.java
+++ b/demo/demo-edge/business-1.0.0/src/main/java/org/apache/servicecomb/demo/edge/business/BusinessMain_V1_0_0.java
@@ -17,10 +17,13 @@
package org.apache.servicecomb.demo.edge.business;
-import org.apache.servicecomb.foundation.common.utils.BeanUtils;
+import org.apache.servicecomb.springboot2.starter.EnableServiceComb;
+import org.springframework.boot.WebApplicationType;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+@EnableServiceComb
public class BusinessMain_V1_0_0 {
public static void main(String[] args) throws Exception {
- BeanUtils.init();
+ new SpringApplicationBuilder(BusinessMain_V1_0_0.class).web(WebApplicationType.NONE).run(args);
}
}
diff --git a/demo/demo-edge/business-2.0.0/pom.xml b/demo/demo-edge/business-2.0.0/pom.xml
index 1dab55c03..6975a2e2a 100644
--- a/demo/demo-edge/business-2.0.0/pom.xml
+++ b/demo/demo-edge/business-2.0.0/pom.xml
@@ -53,8 +53,8 @@
<build>
<plugins>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
diff --git a/demo/demo-edge/business-2.0.0/src/main/java/org/apache/servicecomb/demo/edge/business/BusinessMain_V2_0_0.java b/demo/demo-edge/business-2.0.0/src/main/java/org/apache/servicecomb/demo/edge/business/BusinessMain_V2_0_0.java
index 42aa98cd5..c548ef3ac 100644
--- a/demo/demo-edge/business-2.0.0/src/main/java/org/apache/servicecomb/demo/edge/business/BusinessMain_V2_0_0.java
+++ b/demo/demo-edge/business-2.0.0/src/main/java/org/apache/servicecomb/demo/edge/business/BusinessMain_V2_0_0.java
@@ -17,10 +17,13 @@
package org.apache.servicecomb.demo.edge.business;
-import org.apache.servicecomb.foundation.common.utils.BeanUtils;
+import org.apache.servicecomb.springboot2.starter.EnableServiceComb;
+import org.springframework.boot.WebApplicationType;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+@EnableServiceComb
public class BusinessMain_V2_0_0 {
public static void main(String[] args) throws Exception {
- BeanUtils.init();
+ new SpringApplicationBuilder(BusinessMain_V2_0_0.class).web(WebApplicationType.NONE).run(args);
}
}
diff --git a/demo/demo-edge/consumer/src/main/java/org/apache/servicecomb/demo/edge/consumer/ConsumerMain.java b/demo/demo-edge/consumer/src/main/java/org/apache/servicecomb/demo/edge/consumer/ConsumerMain.java
index 41b6e5578..ab6a5737e 100644
--- a/demo/demo-edge/consumer/src/main/java/org/apache/servicecomb/demo/edge/consumer/ConsumerMain.java
+++ b/demo/demo-edge/consumer/src/main/java/org/apache/servicecomb/demo/edge/consumer/ConsumerMain.java
@@ -20,12 +20,19 @@ package org.apache.servicecomb.demo.edge.consumer;
import org.apache.servicecomb.demo.CategorizedTestCaseRunner;
import org.apache.servicecomb.demo.TestMgr;
import org.apache.servicecomb.demo.edge.model.ChannelRequestBase;
-import org.apache.servicecomb.foundation.common.utils.BeanUtils;
+import org.apache.servicecomb.springboot2.starter.EnableServiceComb;
+import org.springframework.boot.WebApplicationType;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+@EnableServiceComb
public class ConsumerMain {
public static void main(String[] args) throws Exception {
- BeanUtils.init();
+ new SpringApplicationBuilder(ConsumerMain.class).web(WebApplicationType.NONE).run(args);
+ runTest();
+ }
+
+ public static void runTest() throws Exception {
new Consumer().testEncrypt();
new Consumer().invokeBusiness("cse://business/business/v1", new ChannelRequestBase());
diff --git a/demo/demo-edge/consumer/src/test/java/org/apache/servicecomb/demo/edge/consumer/EdgeDemoIT.java b/demo/demo-edge/consumer/src/test/java/org/apache/servicecomb/demo/edge/consumer/EdgeDemoIT.java
index 8b5add109..0ef1f0c9b 100644
--- a/demo/demo-edge/consumer/src/test/java/org/apache/servicecomb/demo/edge/consumer/EdgeDemoIT.java
+++ b/demo/demo-edge/consumer/src/test/java/org/apache/servicecomb/demo/edge/consumer/EdgeDemoIT.java
@@ -21,7 +21,12 @@ import org.apache.servicecomb.demo.TestMgr;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+@ExtendWith(SpringExtension.class)
+@SpringBootTest(classes = ConsumerMain.class)
public class EdgeDemoIT {
@BeforeEach
public void setUp() {
@@ -30,7 +35,7 @@ public class EdgeDemoIT {
@Test
public void clientGetsNoError() throws Exception {
- ConsumerMain.main(new String[0]);
+ ConsumerMain.runTest();
Assertions.assertTrue(TestMgr.errors().isEmpty());
}
diff --git a/demo/demo-edge/edge-service/pom.xml b/demo/demo-edge/edge-service/pom.xml
index 59f27e76e..6dd81c385 100644
--- a/demo/demo-edge/edge-service/pom.xml
+++ b/demo/demo-edge/edge-service/pom.xml
@@ -51,8 +51,8 @@
<build>
<plugins>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
diff --git a/demo/demo-edge/edge-service/src/main/java/org/apache/servicecomb/demo/edge/EdgeMain.java b/demo/demo-edge/edge-service/src/main/java/org/apache/servicecomb/demo/edge/EdgeMain.java
index fc3983de5..9b6910922 100644
--- a/demo/demo-edge/edge-service/src/main/java/org/apache/servicecomb/demo/edge/EdgeMain.java
+++ b/demo/demo-edge/edge-service/src/main/java/org/apache/servicecomb/demo/edge/EdgeMain.java
@@ -17,10 +17,13 @@
package org.apache.servicecomb.demo.edge;
-import org.apache.servicecomb.foundation.common.utils.BeanUtils;
+import org.apache.servicecomb.springboot2.starter.EnableServiceComb;
+import org.springframework.boot.WebApplicationType;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+@EnableServiceComb
public class EdgeMain {
public static void main(String[] args) throws Exception {
- BeanUtils.init();
+ new SpringApplicationBuilder(EdgeMain.class).web(WebApplicationType.NONE).run(args);
}
}
diff --git a/demo/demo-edge/pom.xml b/demo/demo-edge/pom.xml
index 4bceed758..c6afd4ce3 100644
--- a/demo/demo-edge/pom.xml
+++ b/demo/demo-edge/pom.xml
@@ -37,6 +37,10 @@
<groupId>org.apache.servicecomb</groupId>
<artifactId>registry-schema-discovery</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.servicecomb</groupId>
+ <artifactId>java-chassis-spring-boot-starter-standalone</artifactId>
+ </dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
diff --git a/demo/demo-filter/filter-client/src/main/java/org/apache/servicecomb/demo/filter/FilterClient.java b/demo/demo-filter/filter-client/src/main/java/org/apache/servicecomb/demo/filter/FilterClient.java
index 0b517c44d..573870896 100644
--- a/demo/demo-filter/filter-client/src/main/java/org/apache/servicecomb/demo/filter/FilterClient.java
+++ b/demo/demo-filter/filter-client/src/main/java/org/apache/servicecomb/demo/filter/FilterClient.java
@@ -19,16 +19,19 @@ package org.apache.servicecomb.demo.filter;
import org.apache.servicecomb.demo.CategorizedTestCaseRunner;
import org.apache.servicecomb.demo.TestMgr;
-import org.apache.servicecomb.foundation.common.utils.BeanUtils;
+import org.apache.servicecomb.springboot2.starter.EnableServiceComb;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.boot.WebApplicationType;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+@EnableServiceComb
public class FilterClient {
private static final Logger LOGGER = LoggerFactory.getLogger(FilterClient.class);
public static void main(String[] args) throws Exception {
try {
- BeanUtils.init();
+ new SpringApplicationBuilder(FilterClient.class).web(WebApplicationType.NONE).run(args);
run();
} catch (Throwable e) {
diff --git a/demo/demo-filter/filter-client/src/test/java/org/apache/servicecomb/demo/filter/retry/FilterClientIT.java b/demo/demo-filter/filter-client/src/test/java/org/apache/servicecomb/demo/filter/retry/FilterClientIT.java
index 0f332eec6..ccb369ae1 100644
--- a/demo/demo-filter/filter-client/src/test/java/org/apache/servicecomb/demo/filter/retry/FilterClientIT.java
+++ b/demo/demo-filter/filter-client/src/test/java/org/apache/servicecomb/demo/filter/retry/FilterClientIT.java
@@ -22,7 +22,12 @@ import org.apache.servicecomb.demo.filter.FilterClient;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+@ExtendWith(SpringExtension.class)
+@SpringBootTest(classes = FilterClient.class)
public class FilterClientIT {
@BeforeEach
@@ -32,7 +37,7 @@ public class FilterClientIT {
@Test
public void clientGetsNoError() throws Exception {
- FilterClient.main(new String[0]);
+ FilterClient.run();
Assertions.assertTrue(TestMgr.errors().isEmpty());
}
diff --git a/demo/demo-filter/filter-server/pom.xml b/demo/demo-filter/filter-server/pom.xml
index 67cc6eb0d..a4d1c0525 100644
--- a/demo/demo-filter/filter-server/pom.xml
+++ b/demo/demo-filter/filter-server/pom.xml
@@ -45,8 +45,8 @@
<build>
<plugins>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
diff --git a/demo/demo-filter/filter-server/src/main/java/org/apache/servicecomb/demo/filter/FilterServer.java b/demo/demo-filter/filter-server/src/main/java/org/apache/servicecomb/demo/filter/FilterServer.java
index 44df62a9c..186c289f3 100644
--- a/demo/demo-filter/filter-server/src/main/java/org/apache/servicecomb/demo/filter/FilterServer.java
+++ b/demo/demo-filter/filter-server/src/main/java/org/apache/servicecomb/demo/filter/FilterServer.java
@@ -17,10 +17,13 @@
package org.apache.servicecomb.demo.filter;
-import org.apache.servicecomb.foundation.common.utils.BeanUtils;
+import org.apache.servicecomb.springboot2.starter.EnableServiceComb;
+import org.springframework.boot.WebApplicationType;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+@EnableServiceComb
public class FilterServer {
public static void main(String[] args) throws Exception {
- BeanUtils.init();
+ new SpringApplicationBuilder(FilterServer.class).web(WebApplicationType.NONE).run(args);
}
}
diff --git a/demo/demo-filter/pom.xml b/demo/demo-filter/pom.xml
index b99f1f7e1..eb31e6299 100644
--- a/demo/demo-filter/pom.xml
+++ b/demo/demo-filter/pom.xml
@@ -36,6 +36,10 @@
<groupId>org.apache.servicecomb</groupId>
<artifactId>registry-service-center</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.servicecomb</groupId>
+ <artifactId>java-chassis-spring-boot-starter-standalone</artifactId>
+ </dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
diff --git a/demo/demo-jaxrs/jaxrs-client/pom.xml b/demo/demo-jaxrs/jaxrs-client/pom.xml
index 7c11eb860..915a07461 100644
--- a/demo/demo-jaxrs/jaxrs-client/pom.xml
+++ b/demo/demo-jaxrs/jaxrs-client/pom.xml
@@ -49,19 +49,11 @@
<groupId>org.apache.servicecomb</groupId>
<artifactId>handler-governance</artifactId>
</dependency>
- <!-- can be added in local test -->
- <!-- This jar will add an environment version={project.version}, and may cause spring boot application
- startup fail -->
- <!-- <dependency>-->
- <!-- <groupId>org.apache.servicecomb</groupId>-->
- <!-- <artifactId>config-nacos</artifactId>-->
- <!-- </dependency>-->
</dependencies>
<properties>
<demo.main>org.apache.servicecomb.demo.jaxrs.JaxrsClient</demo.main>
</properties>
-
<profiles>
<profile>
<id>docker</id>
diff --git a/demo/demo-jaxrs/jaxrs-client/src/main/java/org/apache/servicecomb/demo/jaxrs/JaxrsClient.java b/demo/demo-jaxrs/jaxrs-client/src/main/java/org/apache/servicecomb/demo/jaxrs/JaxrsClient.java
index 93e086c27..54d829c9f 100644
--- a/demo/demo-jaxrs/jaxrs-client/src/main/java/org/apache/servicecomb/demo/jaxrs/JaxrsClient.java
+++ b/demo/demo-jaxrs/jaxrs-client/src/main/java/org/apache/servicecomb/demo/jaxrs/JaxrsClient.java
@@ -36,13 +36,15 @@ import org.apache.servicecomb.demo.jaxrs.client.CodeFirstRestTemplateJaxrs;
import org.apache.servicecomb.demo.jaxrs.client.pojoDefault.DefaultModelServiceClient;
import org.apache.servicecomb.demo.jaxrs.client.validation.ValidationServiceClient;
import org.apache.servicecomb.demo.validator.Student;
-import org.apache.servicecomb.foundation.common.utils.BeanUtils;
import org.apache.servicecomb.foundation.test.scaffolding.config.ArchaiusUtils;
import org.apache.servicecomb.provider.springmvc.reference.RestTemplateBuilder;
+import org.apache.servicecomb.springboot2.starter.EnableServiceComb;
import org.apache.servicecomb.swagger.invocation.exception.CommonExceptionData;
import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.boot.WebApplicationType;
+import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
@@ -51,12 +53,15 @@ import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
+@EnableServiceComb
public class JaxrsClient {
private static final Logger LOGGER = LoggerFactory.getLogger(JaxrsClient.class);
private static RestTemplate templateNew = RestTemplateBuilder.create();
public static void main(String[] args) throws Exception {
+ new SpringApplicationBuilder(JaxrsClient.class).web(WebApplicationType.NONE).run(args);
+
init();
try {
@@ -72,7 +77,6 @@ public class JaxrsClient {
}
public static void init() throws Exception {
- BeanUtils.init();
RestObjectMapperFactory.setDefaultRestObjectMapper(new RestObjectMapperWithStringMapper());
RestObjectMapperFactory.setConsumerWriterMapper(new RestObjectMapperWithStringMapperNotWriteNull());
}
diff --git a/demo/demo-jaxrs/jaxrs-client/src/test/java/org/apache/servicecomb/demo/jaxrs/JaxrsIT.java b/demo/demo-jaxrs/jaxrs-client/src/test/java/org/apache/servicecomb/demo/jaxrs/JaxrsIT.java
index aaf2ea127..c1bb351ba 100644
--- a/demo/demo-jaxrs/jaxrs-client/src/test/java/org/apache/servicecomb/demo/jaxrs/JaxrsIT.java
+++ b/demo/demo-jaxrs/jaxrs-client/src/test/java/org/apache/servicecomb/demo/jaxrs/JaxrsIT.java
@@ -21,7 +21,12 @@ import org.apache.servicecomb.demo.TestMgr;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+@ExtendWith(SpringExtension.class)
+@SpringBootTest(classes = JaxrsClient.class)
public class JaxrsIT {
@BeforeEach
@@ -31,7 +36,7 @@ public class JaxrsIT {
@Test
public void clientGetsNoError() throws Exception {
- JaxrsClient.main(new String[0]);
+ JaxrsClient.run();
Assertions.assertTrue(TestMgr.errors().isEmpty());
}
diff --git a/demo/demo-jaxrs/jaxrs-server/pom.xml b/demo/demo-jaxrs/jaxrs-server/pom.xml
index a45d3ba35..877e63826 100644
--- a/demo/demo-jaxrs/jaxrs-server/pom.xml
+++ b/demo/demo-jaxrs/jaxrs-server/pom.xml
@@ -56,8 +56,8 @@
<build>
<plugins>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
diff --git a/demo/demo-jaxrs/jaxrs-server/src/main/java/org/apache/servicecomb/demo/jaxrs/JaxrsServer.java b/demo/demo-jaxrs/jaxrs-server/src/main/java/org/apache/servicecomb/demo/jaxrs/JaxrsServer.java
index 4f281d34e..e17958c35 100644
--- a/demo/demo-jaxrs/jaxrs-server/src/main/java/org/apache/servicecomb/demo/jaxrs/JaxrsServer.java
+++ b/demo/demo-jaxrs/jaxrs-server/src/main/java/org/apache/servicecomb/demo/jaxrs/JaxrsServer.java
@@ -20,13 +20,16 @@ package org.apache.servicecomb.demo.jaxrs;
import org.apache.servicecomb.common.rest.codec.RestObjectMapperFactory;
import org.apache.servicecomb.demo.RestObjectMapperWithStringMapper;
import org.apache.servicecomb.demo.RestObjectMapperWithStringMapperNotWriteNull;
-import org.apache.servicecomb.foundation.common.utils.BeanUtils;
+import org.apache.servicecomb.springboot2.starter.EnableServiceComb;
+import org.springframework.boot.WebApplicationType;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+@EnableServiceComb
public class JaxrsServer {
public static void main(String[] args) throws Exception {
+ new SpringApplicationBuilder(JaxrsServer.class).web(WebApplicationType.NONE).run(args);
+
RestObjectMapperFactory.setDefaultRestObjectMapper(new RestObjectMapperWithStringMapper());
RestObjectMapperFactory.setConsumerWriterMapper(new RestObjectMapperWithStringMapperNotWriteNull());
-
- BeanUtils.init();
}
}
diff --git a/demo/demo-jaxrs/pom.xml b/demo/demo-jaxrs/pom.xml
index 358bb557a..327cf6927 100644
--- a/demo/demo-jaxrs/pom.xml
+++ b/demo/demo-jaxrs/pom.xml
@@ -36,6 +36,10 @@
<groupId>org.apache.servicecomb</groupId>
<artifactId>registry-service-center</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.servicecomb</groupId>
+ <artifactId>java-chassis-spring-boot-starter-standalone</artifactId>
+ </dependency>
<dependency>
<groupId>org.apache.servicecomb</groupId>
<artifactId>swagger-generator-spring-data</artifactId>
diff --git a/demo/demo-multiple/a-client/pom.xml b/demo/demo-multiple/a-client/pom.xml
index dfa776736..78e09c0e3 100644
--- a/demo/demo-multiple/a-client/pom.xml
+++ b/demo/demo-multiple/a-client/pom.xml
@@ -30,4 +30,5 @@
<properties>
<demo.main>org.apache.servicecomb.demo.multiple.a.client.AClientMain</demo.main>
</properties>
+
</project>
diff --git a/demo/demo-multiple/a-client/src/main/java/org/apache/servicecomb/demo/multiple/a/client/AClientMain.java b/demo/demo-multiple/a-client/src/main/java/org/apache/servicecomb/demo/multiple/a/client/AClientMain.java
index 108a88772..d394a483d 100644
--- a/demo/demo-multiple/a-client/src/main/java/org/apache/servicecomb/demo/multiple/a/client/AClientMain.java
+++ b/demo/demo-multiple/a-client/src/main/java/org/apache/servicecomb/demo/multiple/a/client/AClientMain.java
@@ -19,10 +19,14 @@ package org.apache.servicecomb.demo.multiple.a.client;
import org.apache.servicecomb.demo.TestMgr;
import org.apache.servicecomb.foundation.common.utils.BeanUtils;
+import org.apache.servicecomb.springboot2.starter.EnableServiceComb;
+import org.springframework.boot.WebApplicationType;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+@EnableServiceComb
public class AClientMain {
public static void main(String[] args) throws Exception {
- BeanUtils.init();
+ new SpringApplicationBuilder(AClientMain.class).web(WebApplicationType.NONE).run(args);
AClient client = BeanUtils.getContext().getBean(AClient.class);
client.run();
diff --git a/demo/demo-multiple/a-server/pom.xml b/demo/demo-multiple/a-server/pom.xml
index f5ae1faaa..8f7431807 100644
--- a/demo/demo-multiple/a-server/pom.xml
+++ b/demo/demo-multiple/a-server/pom.xml
@@ -31,4 +31,5 @@
<properties>
<demo.main>org.apache.servicecomb.demo.multiple.a.server.AServerMain</demo.main>
</properties>
+
</project>
diff --git a/demo/demo-multiple/a-server/src/main/java/org/apache/servicecomb/demo/multiple/a/server/AServerMain.java b/demo/demo-multiple/a-server/src/main/java/org/apache/servicecomb/demo/multiple/a/server/AServerMain.java
index 1ddd01169..1d62a4499 100644
--- a/demo/demo-multiple/a-server/src/main/java/org/apache/servicecomb/demo/multiple/a/server/AServerMain.java
+++ b/demo/demo-multiple/a-server/src/main/java/org/apache/servicecomb/demo/multiple/a/server/AServerMain.java
@@ -17,10 +17,13 @@
package org.apache.servicecomb.demo.multiple.a.server;
-import org.apache.servicecomb.foundation.common.utils.BeanUtils;
+import org.apache.servicecomb.springboot2.starter.EnableServiceComb;
+import org.springframework.boot.WebApplicationType;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+@EnableServiceComb
public class AServerMain {
public static void main(String[] args) throws Exception {
- BeanUtils.init();
+ new SpringApplicationBuilder(AServerMain.class).web(WebApplicationType.NONE).run(args);
}
}
diff --git a/demo/demo-multiple/b-client/pom.xml b/demo/demo-multiple/b-client/pom.xml
index a25e42eb0..ed130e302 100644
--- a/demo/demo-multiple/b-client/pom.xml
+++ b/demo/demo-multiple/b-client/pom.xml
@@ -30,4 +30,5 @@
<properties>
<demo.main>org.apache.servicecomb.demo.multiple.b.client.BClientMain</demo.main>
</properties>
+
</project>
diff --git a/demo/demo-multiple/b-client/src/main/java/org/apache/servicecomb/demo/multiple/b/client/BClientMain.java b/demo/demo-multiple/b-client/src/main/java/org/apache/servicecomb/demo/multiple/b/client/BClientMain.java
index fcd527791..a7ed33c36 100644
--- a/demo/demo-multiple/b-client/src/main/java/org/apache/servicecomb/demo/multiple/b/client/BClientMain.java
+++ b/demo/demo-multiple/b-client/src/main/java/org/apache/servicecomb/demo/multiple/b/client/BClientMain.java
@@ -19,10 +19,14 @@ package org.apache.servicecomb.demo.multiple.b.client;
import org.apache.servicecomb.demo.TestMgr;
import org.apache.servicecomb.foundation.common.utils.BeanUtils;
+import org.apache.servicecomb.springboot2.starter.EnableServiceComb;
+import org.springframework.boot.WebApplicationType;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+@EnableServiceComb
public class BClientMain {
public static void main(String[] args) throws Exception {
- BeanUtils.init();
+ new SpringApplicationBuilder(BClientMain.class).web(WebApplicationType.NONE).run(args);
BClient client = BeanUtils.getContext().getBean(BClient.class);
client.run();
diff --git a/demo/demo-multiple/b-server/src/main/java/org/apache/servicecomb/demo/multiple/b/server/BServerMain.java b/demo/demo-multiple/b-server/src/main/java/org/apache/servicecomb/demo/multiple/b/server/BServerMain.java
index f948c2e5d..d4cb7a11d 100644
--- a/demo/demo-multiple/b-server/src/main/java/org/apache/servicecomb/demo/multiple/b/server/BServerMain.java
+++ b/demo/demo-multiple/b-server/src/main/java/org/apache/servicecomb/demo/multiple/b/server/BServerMain.java
@@ -17,10 +17,13 @@
package org.apache.servicecomb.demo.multiple.b.server;
-import org.apache.servicecomb.foundation.common.utils.BeanUtils;
+import org.apache.servicecomb.springboot2.starter.EnableServiceComb;
+import org.springframework.boot.WebApplicationType;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+@EnableServiceComb
public class BServerMain {
public static void main(String[] args) throws Exception {
- BeanUtils.init();
+ new SpringApplicationBuilder(BServerMain.class).web(WebApplicationType.NONE).run(args);
}
}
diff --git a/demo/demo-multiple/multiple-client/pom.xml b/demo/demo-multiple/multiple-client/pom.xml
index f0f482698..24fd83221 100644
--- a/demo/demo-multiple/multiple-client/pom.xml
+++ b/demo/demo-multiple/multiple-client/pom.xml
@@ -40,7 +40,7 @@
<properties>
<demo.main>org.apache.servicecomb.demo.multiple.client.MultipleClient</demo.main>
</properties>
-
+
<profiles>
<profile>
<id>docker</id>
diff --git a/demo/demo-multiple/multiple-client/src/main/java/org/apache/servicecomb/demo/multiple/client/MultipleClient.java b/demo/demo-multiple/multiple-client/src/main/java/org/apache/servicecomb/demo/multiple/client/MultipleClient.java
index 68bddd0a3..fd57d21a1 100644
--- a/demo/demo-multiple/multiple-client/src/main/java/org/apache/servicecomb/demo/multiple/client/MultipleClient.java
+++ b/demo/demo-multiple/multiple-client/src/main/java/org/apache/servicecomb/demo/multiple/client/MultipleClient.java
@@ -20,11 +20,19 @@ import org.apache.servicecomb.demo.TestMgr;
import org.apache.servicecomb.demo.multiple.a.client.AClient;
import org.apache.servicecomb.demo.multiple.b.client.BClient;
import org.apache.servicecomb.foundation.common.utils.BeanUtils;
+import org.apache.servicecomb.springboot2.starter.EnableServiceComb;
+import org.springframework.boot.WebApplicationType;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+@EnableServiceComb
public class MultipleClient {
public static void main(String[] args) throws Exception {
- BeanUtils.init();
+ new SpringApplicationBuilder(MultipleClient.class).web(WebApplicationType.NONE).run(args);
+ runTest();
+ }
+
+ public static void runTest() {
AClient aClient = BeanUtils.getContext().getBean(AClient.class);
BClient bClient = BeanUtils.getContext().getBean(BClient.class);
diff --git a/demo/demo-jaxrs/jaxrs-client/src/test/java/org/apache/servicecomb/demo/jaxrs/JaxrsIT.java b/demo/demo-multiple/multiple-client/src/test/java/org/apache/servicecomb/demo/multiple/client/MultipleIT.java
similarity index 75%
copy from demo/demo-jaxrs/jaxrs-client/src/test/java/org/apache/servicecomb/demo/jaxrs/JaxrsIT.java
copy to demo/demo-multiple/multiple-client/src/test/java/org/apache/servicecomb/demo/multiple/client/MultipleIT.java
index aaf2ea127..c5c839ae6 100644
--- a/demo/demo-jaxrs/jaxrs-client/src/test/java/org/apache/servicecomb/demo/jaxrs/JaxrsIT.java
+++ b/demo/demo-multiple/multiple-client/src/test/java/org/apache/servicecomb/demo/multiple/client/MultipleIT.java
@@ -15,14 +15,19 @@
* limitations under the License.
*/
-package org.apache.servicecomb.demo.jaxrs;
+package org.apache.servicecomb.demo.multiple.client;
import org.apache.servicecomb.demo.TestMgr;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
-public class JaxrsIT {
+@ExtendWith(SpringExtension.class)
+@SpringBootTest(classes = MultipleClient.class)
+public class MultipleIT {
@BeforeEach
public void setUp() {
@@ -31,7 +36,7 @@ public class JaxrsIT {
@Test
public void clientGetsNoError() throws Exception {
- JaxrsClient.main(new String[0]);
+ MultipleClient.runTest();
Assertions.assertTrue(TestMgr.errors().isEmpty());
}
diff --git a/demo/demo-multiple/multiple-server/pom.xml b/demo/demo-multiple/multiple-server/pom.xml
index 745205cd9..841487513 100644
--- a/demo/demo-multiple/multiple-server/pom.xml
+++ b/demo/demo-multiple/multiple-server/pom.xml
@@ -40,11 +40,12 @@
<properties>
<demo.main>org.apache.servicecomb.demo.multiple.server.MultipleServer</demo.main>
</properties>
+
<build>
<plugins>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
diff --git a/demo/demo-multiple/multiple-server/src/main/java/org/apache/servicecomb/demo/multiple/server/MultipleServer.java b/demo/demo-multiple/multiple-server/src/main/java/org/apache/servicecomb/demo/multiple/server/MultipleServer.java
index f64e15e7e..5de6ec2ac 100644
--- a/demo/demo-multiple/multiple-server/src/main/java/org/apache/servicecomb/demo/multiple/server/MultipleServer.java
+++ b/demo/demo-multiple/multiple-server/src/main/java/org/apache/servicecomb/demo/multiple/server/MultipleServer.java
@@ -16,10 +16,13 @@
*/
package org.apache.servicecomb.demo.multiple.server;
-import org.apache.servicecomb.foundation.common.utils.BeanUtils;
+import org.apache.servicecomb.springboot2.starter.EnableServiceComb;
+import org.springframework.boot.WebApplicationType;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+@EnableServiceComb
public class MultipleServer {
public static void main(String[] args) throws Exception {
- BeanUtils.init();
+ new SpringApplicationBuilder(MultipleServer.class).web(WebApplicationType.NONE).run(args);
}
}
diff --git a/demo/demo-multiple/pom.xml b/demo/demo-multiple/pom.xml
index 3559b311c..bbe1a688e 100644
--- a/demo/demo-multiple/pom.xml
+++ b/demo/demo-multiple/pom.xml
@@ -74,6 +74,10 @@
<groupId>org.apache.servicecomb</groupId>
<artifactId>provider-pojo</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.servicecomb</groupId>
+ <artifactId>java-chassis-spring-boot-starter-standalone</artifactId>
+ </dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
diff --git a/demo/demo-pojo/pojo-client/src/main/java/org/apache/servicecomb/demo/pojo/client/PojoClient.java b/demo/demo-pojo/pojo-client/src/main/java/org/apache/servicecomb/demo/pojo/client/PojoClient.java
index 64e323633..8f4373ef3 100644
--- a/demo/demo-pojo/pojo-client/src/main/java/org/apache/servicecomb/demo/pojo/client/PojoClient.java
+++ b/demo/demo-pojo/pojo-client/src/main/java/org/apache/servicecomb/demo/pojo/client/PojoClient.java
@@ -41,14 +41,16 @@ import org.apache.servicecomb.foundation.common.utils.BeanUtils;
import org.apache.servicecomb.foundation.test.scaffolding.config.ArchaiusUtils;
import org.apache.servicecomb.foundation.vertx.client.http.HttpClients;
import org.apache.servicecomb.provider.pojo.RpcReference;
+import org.apache.servicecomb.springboot2.starter.EnableServiceComb;
import org.apache.servicecomb.swagger.invocation.context.ContextUtils;
import org.apache.servicecomb.swagger.invocation.context.InvocationContext;
import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
+import org.springframework.boot.WebApplicationType;
+import org.springframework.boot.builder.SpringApplicationBuilder;
-@Component
+@EnableServiceComb
public class PojoClient {
private static final Logger LOGGER = LoggerFactory.getLogger(PojoClient.class);
@@ -75,7 +77,7 @@ public class PojoClient {
}
public static void main(String[] args) throws Exception {
- BeanUtils.init();
+ new SpringApplicationBuilder(PojoClient.class).web(WebApplicationType.NONE).run(args);
try {
run();
diff --git a/demo/demo-pojo/pojo-client/src/test/java/org/apache/servicecomb/demo/pojo/PojoIT.java b/demo/demo-pojo/pojo-client/src/test/java/org/apache/servicecomb/demo/pojo/PojoIT.java
index 0f3101b25..c0c4f7542 100644
--- a/demo/demo-pojo/pojo-client/src/test/java/org/apache/servicecomb/demo/pojo/PojoIT.java
+++ b/demo/demo-pojo/pojo-client/src/test/java/org/apache/servicecomb/demo/pojo/PojoIT.java
@@ -22,7 +22,12 @@ import org.apache.servicecomb.demo.pojo.client.PojoClient;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+@ExtendWith(SpringExtension.class)
+@SpringBootTest(classes = PojoClient.class)
public class PojoIT {
@BeforeEach
@@ -32,7 +37,7 @@ public class PojoIT {
@Test
public void clientGetsNoError() throws Exception {
- PojoClient.main(new String[0]);
+ PojoClient.run();
Assertions.assertTrue(TestMgr.errors().isEmpty());
}
diff --git a/demo/demo-pojo/pojo-server/pom.xml b/demo/demo-pojo/pojo-server/pom.xml
index 12a6a142b..b74b717f1 100644
--- a/demo/demo-pojo/pojo-server/pom.xml
+++ b/demo/demo-pojo/pojo-server/pom.xml
@@ -44,8 +44,8 @@
<build>
<plugins>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
diff --git a/demo/demo-pojo/pojo-server/src/main/java/org/apache/servicecomb/demo/pojo/server/PojoServer.java b/demo/demo-pojo/pojo-server/src/main/java/org/apache/servicecomb/demo/pojo/server/PojoServer.java
index 25b1b9e69..1d9162b4b 100644
--- a/demo/demo-pojo/pojo-server/src/main/java/org/apache/servicecomb/demo/pojo/server/PojoServer.java
+++ b/demo/demo-pojo/pojo-server/src/main/java/org/apache/servicecomb/demo/pojo/server/PojoServer.java
@@ -17,10 +17,13 @@
package org.apache.servicecomb.demo.pojo.server;
-import org.apache.servicecomb.foundation.common.utils.BeanUtils;
+import org.apache.servicecomb.springboot2.starter.EnableServiceComb;
+import org.springframework.boot.WebApplicationType;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+@EnableServiceComb
public class PojoServer {
public static void main(String[] args) throws Exception {
- BeanUtils.init();
+ new SpringApplicationBuilder(PojoServer.class).web(WebApplicationType.NONE).run(args);
}
}
diff --git a/demo/demo-pojo/pom.xml b/demo/demo-pojo/pom.xml
index 20544afa8..a2c471ee9 100644
--- a/demo/demo-pojo/pom.xml
+++ b/demo/demo-pojo/pom.xml
@@ -40,6 +40,10 @@
<groupId>org.apache.servicecomb</groupId>
<artifactId>handler-publickey-auth</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.servicecomb</groupId>
+ <artifactId>java-chassis-spring-boot-starter-standalone</artifactId>
+ </dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
diff --git a/demo/demo-schema/src/main/resources/microservice.yaml b/demo/demo-schema/src/main/resources/microservice.yaml
index 97db791f5..684d88dd6 100644
--- a/demo/demo-schema/src/main/resources/microservice.yaml
+++ b/demo/demo-schema/src/main/resources/microservice.yaml
@@ -16,15 +16,7 @@
## ---------------------------------------------------------------------------
servicecomb-config-order: -1
-cse:
- test:
- duplicate1: older
-
-servicecomb:
- test:
- duplicate2: older
-
demo.multi.service.center.serverB:
key1: key1
key2: key2
- key3: key3
\ No newline at end of file
+ key3: key3
diff --git a/demo/demo-spring-boot-provider/demo-spring-boot-jaxrs-client/pom.xml b/demo/demo-spring-boot-provider/demo-spring-boot-jaxrs-client/pom.xml
deleted file mode 100644
index f1fa09d32..000000000
--- a/demo/demo-spring-boot-provider/demo-spring-boot-jaxrs-client/pom.xml
+++ /dev/null
@@ -1,72 +0,0 @@
-<?xml version="1.0"?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one or more
- ~ contributor license agreements. See the NOTICE file distributed with
- ~ this work for additional information regarding copyright ownership.
- ~ The ASF licenses this file to You under the Apache License, Version 2.0
- ~ (the "License"); you may not use this file except in compliance with
- ~ the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-
-<project
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
- xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <modelVersion>4.0.0</modelVersion>
- <artifactId>demo-spring-boot-jaxrs-client</artifactId>
- <name>Java Chassis::Demo::Spring Boot::JAXRS Client</name>
- <parent>
- <groupId>org.apache.servicecomb.demo</groupId>
- <artifactId>demo-spring-boot</artifactId>
- <version>2.9.0-SNAPSHOT</version>
- </parent>
- <dependencies>
- <dependency>
- <groupId>org.apache.servicecomb.demo</groupId>
- <artifactId>jaxrs-client</artifactId>
- <exclusions>
- <exclusion>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-slf4j-impl</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- </dependencies>
-
- <profiles>
- <profile>
- <id>docker</id>
- <properties>
- <demo.service.name>demo-spring-boot-jaxrs-server</demo.service.name>
- </properties>
- <build>
- <plugins>
- <plugin>
- <groupId>io.fabric8</groupId>
- <artifactId>docker-maven-plugin</artifactId>
- </plugin>
- <plugin>
- <groupId>com.github.odavid.maven.plugins</groupId>
- <artifactId>mixin-maven-plugin</artifactId>
- <configuration>
- <mixins>
- <mixin>
- <groupId>org.apache.servicecomb.demo</groupId>
- <artifactId>docker-run-config</artifactId>
- <version>${project.version}</version>
- </mixin>
- </mixins>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-</project>
diff --git a/demo/demo-spring-boot-provider/demo-spring-boot-jaxrs-client/src/main/java/org/apache/servicecomb/springboot/jaxrs/client/JaxrsClient.java b/demo/demo-spring-boot-provider/demo-spring-boot-jaxrs-client/src/main/java/org/apache/servicecomb/springboot/jaxrs/client/JaxrsClient.java
deleted file mode 100644
index 216539149..000000000
--- a/demo/demo-spring-boot-provider/demo-spring-boot-jaxrs-client/src/main/java/org/apache/servicecomb/springboot/jaxrs/client/JaxrsClient.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.servicecomb.springboot.jaxrs.client;
-
-import org.apache.servicecomb.common.rest.codec.RestObjectMapperFactory;
-import org.apache.servicecomb.demo.RestObjectMapperWithStringMapper;
-import org.apache.servicecomb.demo.RestObjectMapperWithStringMapperNotWriteNull;
-import org.apache.servicecomb.demo.TestMgr;
-import org.apache.servicecomb.springboot2.starter.EnableServiceComb;
-import org.springframework.boot.WebApplicationType;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.builder.SpringApplicationBuilder;
-
-@SpringBootApplication
-@EnableServiceComb
-public class JaxrsClient {
-
- public static void main(String[] args) throws Exception {
- RestObjectMapperFactory.setDefaultRestObjectMapper(new RestObjectMapperWithStringMapper());
- RestObjectMapperFactory.setConsumerWriterMapper(new RestObjectMapperWithStringMapperNotWriteNull());
-
- new SpringApplicationBuilder().sources(JaxrsClient.class).web(WebApplicationType.NONE).build().run(args);
- org.apache.servicecomb.demo.jaxrs.JaxrsClient.run();
- TestMgr.summary();
- }
-}
diff --git a/demo/demo-spring-boot-provider/demo-spring-boot-jaxrs-client/src/main/resources/application.yml b/demo/demo-spring-boot-provider/demo-spring-boot-jaxrs-client/src/main/resources/application.yml
deleted file mode 100644
index 8631c2a7c..000000000
--- a/demo/demo-spring-boot-provider/demo-spring-boot-jaxrs-client/src/main/resources/application.yml
+++ /dev/null
@@ -1,35 +0,0 @@
-## ---------------------------------------------------------------------------
-## Licensed to the Apache Software Foundation (ASF) under one or more
-## contributor license agreements. See the NOTICE file distributed with
-## this work for additional information regarding copyright ownership.
-## The ASF licenses this file to You under the Apache License, Version 2.0
-## (the "License"); you may not use this file except in compliance with
-## the License. You may obtain a copy of the License at
-##
-## http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing, software
-## distributed under the License is distributed on an "AS IS" BASIS,
-## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-## See the License for the specific language governing permissions and
-## limitations under the License.
-## ---------------------------------------------------------------------------
-
-server:
- port: 8999
-
-# java-chassis configuration
-
-servicecomb-config-order: 1
-APPLICATION_ID: spring-boot-jaxrstest
-service_description:
- name: jaxrsClient
- version: 0.0.1
-servicecomb:
- service:
- registry:
- address: http://127.0.0.1:30100
- handler:
- chain:
- Consumer:
- default: loadbalance,instance-isolation-consumer,instance-bulkhead-consumer
diff --git a/demo/demo-spring-boot-provider/demo-spring-boot-jaxrs-client/src/test/java/org/apache/servicecomb/springboot/jaxrs/SpringBootJaxrsIT.java b/demo/demo-spring-boot-provider/demo-spring-boot-jaxrs-client/src/test/java/org/apache/servicecomb/springboot/jaxrs/SpringBootJaxrsIT.java
deleted file mode 100644
index 283b39dad..000000000
--- a/demo/demo-spring-boot-provider/demo-spring-boot-jaxrs-client/src/test/java/org/apache/servicecomb/springboot/jaxrs/SpringBootJaxrsIT.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.servicecomb.springboot.jaxrs;
-
-import org.apache.servicecomb.demo.TestMgr;
-import org.apache.servicecomb.springboot.jaxrs.client.JaxrsClient;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-public class SpringBootJaxrsIT {
-
- @BeforeEach
- public void setUp() throws Exception {
- TestMgr.errors().clear();
- }
-
- @Test
- public void clientGetsNoError() throws Exception {
- try {
- JaxrsClient.main(new String[0]);
- Assertions.assertTrue(TestMgr.errors().isEmpty());
- } catch (Throwable e) {
- e.printStackTrace();
- Assertions.fail("test case failed, message=" + e.getMessage());
- }
- }
-}
diff --git a/demo/demo-spring-boot-provider/demo-spring-boot-jaxrs-server/pom.xml b/demo/demo-spring-boot-provider/demo-spring-boot-jaxrs-server/pom.xml
deleted file mode 100644
index 7cedad3ec..000000000
--- a/demo/demo-spring-boot-provider/demo-spring-boot-jaxrs-server/pom.xml
+++ /dev/null
@@ -1,89 +0,0 @@
-<?xml version="1.0"?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one or more
- ~ contributor license agreements. See the NOTICE file distributed with
- ~ this work for additional information regarding copyright ownership.
- ~ The ASF licenses this file to You under the Apache License, Version 2.0
- ~ (the "License"); you may not use this file except in compliance with
- ~ the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-
-<project
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
- xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <modelVersion>4.0.0</modelVersion>
- <artifactId>demo-spring-boot-jaxrs-server</artifactId>
- <name>Java Chassis::Demo::Spring Boot::JAXRS Server</name>
- <parent>
- <groupId>org.apache.servicecomb.demo</groupId>
- <artifactId>demo-spring-boot</artifactId>
- <version>2.9.0-SNAPSHOT</version>
- </parent>
- <properties>
- <demo.main>org.apache.servicecomb.springboot.jaxrs.server.JaxrsServer</demo.main>
- </properties>
- <dependencies>
- <dependency>
- <groupId>org.apache.servicecomb.demo</groupId>
- <artifactId>jaxrs-server</artifactId>
- <exclusions>
- <exclusion>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-slf4j-impl</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.servicecomb</groupId>
- <artifactId>inspector</artifactId>
- </dependency>
-
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-maven-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
-
- <profiles>
- <profile>
- <id>docker</id>
- <build>
- <plugins>
- <plugin>
- <groupId>io.fabric8</groupId>
- <artifactId>docker-maven-plugin</artifactId>
- </plugin>
- <plugin>
- <groupId>org.commonjava.maven.plugins</groupId>
- <artifactId>directory-maven-plugin</artifactId>
- </plugin>
- <plugin>
- <groupId>com.github.odavid.maven.plugins</groupId>
- <artifactId>mixin-maven-plugin</artifactId>
- <configuration>
- <mixins>
- <mixin>
- <groupId>org.apache.servicecomb.demo</groupId>
- <artifactId>docker-build-config</artifactId>
- <version>${project.version}</version>
- </mixin>
- </mixins>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-</project>
diff --git a/demo/demo-spring-boot-provider/demo-spring-boot-jaxrs-server/src/main/java/org/apache/servicecomb/springboot/jaxrs/server/JaxrsServer.java b/demo/demo-spring-boot-provider/demo-spring-boot-jaxrs-server/src/main/java/org/apache/servicecomb/springboot/jaxrs/server/JaxrsServer.java
deleted file mode 100644
index 385c1b0c5..000000000
--- a/demo/demo-spring-boot-provider/demo-spring-boot-jaxrs-server/src/main/java/org/apache/servicecomb/springboot/jaxrs/server/JaxrsServer.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.servicecomb.springboot.jaxrs.server;
-
-import org.apache.servicecomb.common.rest.codec.RestObjectMapperFactory;
-import org.apache.servicecomb.demo.RestObjectMapperWithStringMapper;
-import org.apache.servicecomb.demo.RestObjectMapperWithStringMapperNotWriteNull;
-import org.apache.servicecomb.springboot2.starter.EnableServiceComb;
-import org.springframework.boot.WebApplicationType;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.builder.SpringApplicationBuilder;
-
-@SpringBootApplication
-@EnableServiceComb
-public class JaxrsServer {
- public static void main(final String[] args) throws Exception {
- RestObjectMapperFactory.setDefaultRestObjectMapper(new RestObjectMapperWithStringMapper());
- RestObjectMapperFactory.setConsumerWriterMapper(new RestObjectMapperWithStringMapperNotWriteNull());
-
- new SpringApplicationBuilder().sources(JaxrsServer.class).web(WebApplicationType.NONE).build().run(args);
- }
-}
diff --git a/demo/demo-spring-boot-provider/demo-spring-boot-jaxrs-server/src/main/resources/application.yml b/demo/demo-spring-boot-provider/demo-spring-boot-jaxrs-server/src/main/resources/application.yml
deleted file mode 100644
index c13f2f8ed..000000000
--- a/demo/demo-spring-boot-provider/demo-spring-boot-jaxrs-server/src/main/resources/application.yml
+++ /dev/null
@@ -1,34 +0,0 @@
-## ---------------------------------------------------------------------------
-## Licensed to the Apache Software Foundation (ASF) under one or more
-## contributor license agreements. See the NOTICE file distributed with
-## this work for additional information regarding copyright ownership.
-## The ASF licenses this file to You under the Apache License, Version 2.0
-## (the "License"); you may not use this file except in compliance with
-## the License. You may obtain a copy of the License at
-##
-## http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing, software
-## distributed under the License is distributed on an "AS IS" BASIS,
-## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-## See the License for the specific language governing permissions and
-## limitations under the License.
-## ---------------------------------------------------------------------------
-
-server:
- port: 0
-
-# java-chassis configuration
-servicecomb-config-order: 1
-APPLICATION_ID: spring-boot-jaxrstest
-service_description:
- name: jaxrs
- version: 0.0.1
-servicecomb:
- service:
- registry:
- address: http://127.0.0.1:30100
- rest:
- address: 0.0.0.0:8080
- highway:
- address: 0.0.0.0:7070
\ No newline at end of file
diff --git a/demo/demo-spring-boot-provider/pom.xml b/demo/demo-spring-boot-provider/pom.xml
deleted file mode 100644
index 5df293f30..000000000
--- a/demo/demo-spring-boot-provider/pom.xml
+++ /dev/null
@@ -1,64 +0,0 @@
-<?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.demo</groupId>
- <artifactId>demo-parent</artifactId>
- <version>2.9.0-SNAPSHOT</version>
- </parent>
- <artifactId>demo-spring-boot</artifactId>
- <name>Java Chassis::Demo::Spring Boot</name>
- <packaging>pom</packaging>
- <modules>
- <module>demo-spring-boot-jaxrs-server</module>
- <module>demo-spring-boot-jaxrs-client</module>
- </modules>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.servicecomb</groupId>
- <artifactId>registry-service-center</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.servicecomb</groupId>
- <artifactId>java-chassis-spring-boot-starter-standalone</artifactId>
- <exclusions>
- <exclusion>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-logging</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <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>
- </dependencies>
-
-</project>
diff --git a/demo/demo-spring-boot-transport/demo-spring-boot-pojo-client/src/main/java/org/apache/servicecomb/springboot/pojo/client/PojoClient.java b/demo/demo-spring-boot-transport/demo-spring-boot-pojo-client/src/main/java/org/apache/servicecomb/springboot/pojo/client/PojoClient.java
index b642d161a..d5ff1a7d6 100644
--- a/demo/demo-spring-boot-transport/demo-spring-boot-pojo-client/src/main/java/org/apache/servicecomb/springboot/pojo/client/PojoClient.java
+++ b/demo/demo-spring-boot-transport/demo-spring-boot-pojo-client/src/main/java/org/apache/servicecomb/springboot/pojo/client/PojoClient.java
@@ -17,6 +17,7 @@
package org.apache.servicecomb.springboot.pojo.client;
+import org.apache.servicecomb.demo.pojo.client.PojoClientTest;
import org.apache.servicecomb.springboot2.starter.EnableServiceComb;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -34,6 +35,6 @@ public class PojoClient {
public static void main(final String[] args) throws Exception {
new SpringApplicationBuilder().sources(PojoClient.class).web(WebApplicationType.SERVLET).build().run(args);
- org.apache.servicecomb.demo.pojo.client.PojoClientTest.runTest();
+ PojoClientTest.runTest();
}
}
diff --git a/demo/demo-spring-boot-transport/demo-spring-boot-pojo-client/src/main/resources/application.yml b/demo/demo-spring-boot-transport/demo-spring-boot-pojo-client/src/main/resources/application.yml
index 91c08652b..31528e354 100644
--- a/demo/demo-spring-boot-transport/demo-spring-boot-pojo-client/src/main/resources/application.yml
+++ b/demo/demo-spring-boot-transport/demo-spring-boot-pojo-client/src/main/resources/application.yml
@@ -31,8 +31,7 @@ servicecomb:
handler:
chain:
Consumer:
- #default: loadbalance
- default: bizkeeper-consumer,loadbalance
+ default: loadbalance
isolation:
Consumer:
enabled: false
diff --git a/demo/demo-spring-boot-transport/demo-spring-boot-pojo-client/src/test/java/org/apache/servicecomb/springboot/pojo/client/PojoClientIT.java b/demo/demo-spring-boot-transport/demo-spring-boot-pojo-client/src/test/java/org/apache/servicecomb/springboot/pojo/client/PojoClientIT.java
index befe5a008..ecf507821 100644
--- a/demo/demo-spring-boot-transport/demo-spring-boot-pojo-client/src/test/java/org/apache/servicecomb/springboot/pojo/client/PojoClientIT.java
+++ b/demo/demo-spring-boot-transport/demo-spring-boot-pojo-client/src/test/java/org/apache/servicecomb/springboot/pojo/client/PojoClientIT.java
@@ -18,11 +18,16 @@
package org.apache.servicecomb.springboot.pojo.client;
import org.apache.servicecomb.demo.TestMgr;
+import org.apache.servicecomb.demo.pojo.client.PojoClientTest;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import org.springframework.boot.SpringApplication;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+@ExtendWith(SpringExtension.class)
+@SpringBootTest(classes = PojoClient.class)
public class PojoClientIT {
@BeforeEach
@@ -32,8 +37,7 @@ public class PojoClientIT {
@Test
public void clientGetsNoError() throws Exception {
- SpringApplication.run(PojoClient.class);
-
+ PojoClientTest.runTest();
Assertions.assertTrue(TestMgr.errors().isEmpty());
}
}
diff --git a/demo/demo-spring-boot-transport/demo-spring-boot-pojo-server/pom.xml b/demo/demo-spring-boot-transport/demo-spring-boot-pojo-server/pom.xml
index 41275da5c..ae5924830 100644
--- a/demo/demo-spring-boot-transport/demo-spring-boot-pojo-server/pom.xml
+++ b/demo/demo-spring-boot-transport/demo-spring-boot-pojo-server/pom.xml
@@ -31,6 +31,7 @@
<properties>
<demo.main>org.apache.servicecomb.springboot.pojo.server.PojoServer</demo.main>
</properties>
+
<dependencies>
<dependency>
<groupId>jakarta.ws.rs</groupId>
@@ -40,8 +41,8 @@
<groupId>org.apache.servicecomb</groupId>
<artifactId>inspector</artifactId>
</dependency>
-
</dependencies>
+
<build>
<plugins>
<plugin>
diff --git a/demo/demo-spring-boot-transport/demo-spring-boot-springmvc-client/pom.xml b/demo/demo-spring-boot-transport/demo-spring-boot-springmvc-client/pom.xml
index 59abc304e..05d73ce6e 100644
--- a/demo/demo-spring-boot-transport/demo-spring-boot-springmvc-client/pom.xml
+++ b/demo/demo-spring-boot-transport/demo-spring-boot-springmvc-client/pom.xml
@@ -28,23 +28,13 @@
<artifactId>demo-spring-boot-transport</artifactId>
<version>2.9.0-SNAPSHOT</version>
</parent>
+
<dependencies>
<dependency>
<groupId>org.apache.servicecomb.demo</groupId>
- <artifactId>springmvc-client</artifactId>
- <exclusions>
- <exclusion>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- </exclusion>
- </exclusions>
+ <artifactId>demo-schema</artifactId>
</dependency>
</dependencies>
-
<profiles>
<profile>
<id>docker</id>
diff --git a/demo/demo-spring-boot-transport/demo-spring-boot-springmvc-client/src/main/java/org/apache/servicecomb/springboot/springmvc/client/PlaceHolderSchemaTest.java b/demo/demo-spring-boot-transport/demo-spring-boot-springmvc-client/src/main/java/org/apache/servicecomb/springboot/springmvc/client/PlaceHolderSchemaTest.java
index dc616c6cf..7a70afa94 100644
--- a/demo/demo-spring-boot-transport/demo-spring-boot-springmvc-client/src/main/java/org/apache/servicecomb/springboot/springmvc/client/PlaceHolderSchemaTest.java
+++ b/demo/demo-spring-boot-transport/demo-spring-boot-springmvc-client/src/main/java/org/apache/servicecomb/springboot/springmvc/client/PlaceHolderSchemaTest.java
@@ -26,7 +26,7 @@ import org.springframework.web.client.RestTemplate;
@Component
public class PlaceHolderSchemaTest implements CategorizedTestCase {
@Override
- public void testAllTransport() throws Exception {
+ public void testRestTransport() throws Exception {
RestTemplate template = RestTemplateBuilder.create();
String result = template.getForObject("servicecomb://springmvc/placeholder/schema?name=test", String.class);
TestMgr.check("test", result);
diff --git a/demo/demo-spring-boot-transport/demo-spring-boot-springmvc-client/src/main/java/org/apache/servicecomb/springboot/springmvc/client/SpringmvcClient.java b/demo/demo-spring-boot-transport/demo-spring-boot-springmvc-client/src/main/java/org/apache/servicecomb/springboot/springmvc/client/SpringmvcClient.java
index a92df0f71..9135ea349 100644
--- a/demo/demo-spring-boot-transport/demo-spring-boot-springmvc-client/src/main/java/org/apache/servicecomb/springboot/springmvc/client/SpringmvcClient.java
+++ b/demo/demo-spring-boot-transport/demo-spring-boot-springmvc-client/src/main/java/org/apache/servicecomb/springboot/springmvc/client/SpringmvcClient.java
@@ -17,6 +17,7 @@
package org.apache.servicecomb.springboot.springmvc.client;
+import org.apache.servicecomb.demo.CategorizedTestCaseRunner;
import org.apache.servicecomb.demo.TestMgr;
import org.apache.servicecomb.springboot2.starter.EnableServiceComb;
import org.springframework.boot.WebApplicationType;
@@ -36,7 +37,11 @@ public class SpringmvcClient {
new SpringApplicationBuilder().sources(SpringmvcClient.class).web(WebApplicationType.SERVLET).build().run(args);
- org.apache.servicecomb.demo.springmvc.SpringmvcClient.run();
+ runTest();
+ }
+
+ public static void runTest() throws Exception {
+ CategorizedTestCaseRunner.runCategorizedTestCase("springmvc");
TestMgr.summary();
}
diff --git a/demo/demo-spring-boot-transport/demo-spring-boot-springmvc-client/src/main/resources/application.yml b/demo/demo-spring-boot-transport/demo-spring-boot-springmvc-client/src/main/resources/application.yml
index b4e5bfbb6..1142e8e87 100644
--- a/demo/demo-spring-boot-transport/demo-spring-boot-springmvc-client/src/main/resources/application.yml
+++ b/demo/demo-spring-boot-transport/demo-spring-boot-springmvc-client/src/main/resources/application.yml
@@ -17,6 +17,10 @@
APPLICATION_ID: springmvcboottest
+service_description:
+ name: springmvcclient
+ version: 0.0.3
+
server:
port: 8999
servicecomb:
diff --git a/demo/demo-spring-boot-transport/demo-spring-boot-springmvc-client/src/test/java/org/apache/servicecomb/springboot/springmvc/client/SpringmvcClientIT.java b/demo/demo-spring-boot-transport/demo-spring-boot-springmvc-client/src/test/java/org/apache/servicecomb/springboot/springmvc/client/SpringmvcClientIT.java
index 9e254066e..dbe8c352d 100644
--- a/demo/demo-spring-boot-transport/demo-spring-boot-springmvc-client/src/test/java/org/apache/servicecomb/springboot/springmvc/client/SpringmvcClientIT.java
+++ b/demo/demo-spring-boot-transport/demo-spring-boot-springmvc-client/src/test/java/org/apache/servicecomb/springboot/springmvc/client/SpringmvcClientIT.java
@@ -21,7 +21,12 @@ import org.apache.servicecomb.demo.TestMgr;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+@ExtendWith(SpringExtension.class)
+@SpringBootTest(classes = SpringmvcClient.class)
public class SpringmvcClientIT {
@BeforeEach
public void setUp() throws Exception {
@@ -31,7 +36,7 @@ public class SpringmvcClientIT {
@Test
public void clientGetsNoError() throws Exception {
try {
- SpringmvcClient.main(new String[0]);
+ SpringmvcClient.runTest();
Assertions.assertTrue(TestMgr.errors().isEmpty());
} catch (Throwable e) {
diff --git a/demo/demo-spring-boot-transport/demo-spring-boot-springmvc-server/pom.xml b/demo/demo-spring-boot-transport/demo-spring-boot-springmvc-server/pom.xml
index 0f6a3961f..6c4101f42 100644
--- a/demo/demo-spring-boot-transport/demo-spring-boot-springmvc-server/pom.xml
+++ b/demo/demo-spring-boot-transport/demo-spring-boot-springmvc-server/pom.xml
@@ -31,7 +31,7 @@
<dependencies>
<dependency>
<groupId>org.apache.servicecomb.demo</groupId>
- <artifactId>springmvc-server</artifactId>
+ <artifactId>demo-schema</artifactId>
</dependency>
</dependencies>
<build>
diff --git a/demo/demo-spring-boot-transport/demo-spring-boot-springmvc-server/src/main/resources/application.yml b/demo/demo-spring-boot-transport/demo-spring-boot-springmvc-server/src/main/resources/application.yml
index 41650780c..29c424bbb 100644
--- a/demo/demo-spring-boot-transport/demo-spring-boot-springmvc-server/src/main/resources/application.yml
+++ b/demo/demo-spring-boot-transport/demo-spring-boot-springmvc-server/src/main/resources/application.yml
@@ -17,6 +17,10 @@
APPLICATION_ID: springmvcboottest
+service_description:
+ name: springmvc
+ version: 0.0.3
+
server:
port: 8080
@@ -28,4 +32,4 @@ test:
servicecomb:
test:
vert:
- transport: false
\ No newline at end of file
+ transport: false
diff --git a/demo/demo-spring-boot-transport/demo-spring-boot-springmvc-server/src/main/resources/microservice.yaml b/demo/demo-spring-boot-transport/demo-spring-boot-springmvc-server/src/main/resources/microservice.yaml
index 141c0d4f1..c3738a1dd 100644
--- a/demo/demo-spring-boot-transport/demo-spring-boot-springmvc-server/src/main/resources/microservice.yaml
+++ b/demo/demo-spring-boot-transport/demo-spring-boot-springmvc-server/src/main/resources/microservice.yaml
@@ -17,4 +17,25 @@
servicecomb:
config:
- ignoreResolveFailure: true
\ No newline at end of file
+ ignoreResolveFailure: true
+
+ service:
+ registry:
+ registerPath: true
+ address: http://127.0.0.1:9980,http://127.0.0.1:30100
+ client:
+ timeout:
+ idle: 60
+ watch: 60
+ instance:
+ healthCheck:
+ interval: 3
+ pull:
+ interval: 10
+ watch: true
+ autodiscovery: true
+ uploads:
+ directory: target
+
+ rest:
+ address: 0.0.0.0:8080?sslEnabled=false
diff --git a/demo/demo-springmvc/pom.xml b/demo/demo-springmvc/pom.xml
index 5701295d2..a039929be 100644
--- a/demo/demo-springmvc/pom.xml
+++ b/demo/demo-springmvc/pom.xml
@@ -36,6 +36,10 @@
<groupId>org.apache.servicecomb</groupId>
<artifactId>registry-service-center</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.servicecomb</groupId>
+ <artifactId>java-chassis-spring-boot-starter-standalone</artifactId>
+ </dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
diff --git a/demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/SpringmvcClient.java b/demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/SpringmvcClient.java
index 0c7cbdb10..c44c1de0e 100644
--- a/demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/SpringmvcClient.java
+++ b/demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/SpringmvcClient.java
@@ -36,9 +36,12 @@ import org.apache.servicecomb.provider.springmvc.reference.CseRestTemplate;
import org.apache.servicecomb.provider.springmvc.reference.RestTemplateBuilder;
import org.apache.servicecomb.provider.springmvc.reference.UrlWithProviderPrefixClientHttpRequestFactory;
import org.apache.servicecomb.provider.springmvc.reference.UrlWithServiceNameClientHttpRequestFactory;
+import org.apache.servicecomb.springboot2.starter.EnableServiceComb;
import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.boot.WebApplicationType;
+import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
@@ -50,6 +53,7 @@ import org.springframework.web.client.RestTemplate;
import com.netflix.config.DynamicPropertyFactory;
+@EnableServiceComb
public class SpringmvcClient {
private static final Logger LOGGER = LoggerFactory.getLogger(SpringmvcClient.class);
@@ -63,7 +67,7 @@ public class SpringmvcClient {
public static void main(String[] args) throws Exception {
try {
- BeanUtils.init();
+ new SpringApplicationBuilder(SpringmvcClient.class).web(WebApplicationType.NONE).run(args);
run();
} catch (Throwable e) {
@@ -82,7 +86,6 @@ public class SpringmvcClient {
public static void run() throws Exception {
testHttpClientsIsOk();
- testConfigurationDuplicate();
templateUrlWithServiceName.setRequestFactory(new UrlWithServiceNameClientHttpRequestFactory());
restTemplate = RestTemplateBuilder.create();
@@ -351,17 +354,6 @@ public class SpringmvcClient {
TestMgr.check("ha world", controller.saySomething("ha", user));
}
- private static void testConfigurationDuplicate() {
- // this configuration will give warning messages:
- // Key servicecomb.test.duplicate2 with an ambiguous item cse.test.duplicate2 exists, please use the same prefix or will get unexpected merged value.
- // Key servicecomb.test.duplicate1 with an ambiguous item cse.test.duplicate1 exists, please use the same prefix or will get unexpected merged value.
- // and the expected value is not quite determined. But will not get wrong value like 'older,newer' or 'newer,older'
- TestMgr.check(DynamicPropertyFactory.getInstance().getStringProperty("cse.test.duplicate2", "wrong").get(),
- "newer");
- TestMgr.check(DynamicPropertyFactory.getInstance().getStringProperty("cse.test.duplicate1", "wrong").get(),
- "older");
- }
-
private static void testRequiredBody(RestTemplate template, String microserviceName) {
String prefix = "cse://" + microserviceName;
Person user = new Person();
diff --git a/demo/demo-springmvc/springmvc-client/src/main/resources/microservice.yaml b/demo/demo-springmvc/springmvc-client/src/main/resources/microservice.yaml
index 7d9707ac9..e3628dc16 100644
--- a/demo/demo-springmvc/springmvc-client/src/main/resources/microservice.yaml
+++ b/demo/demo-springmvc/springmvc-client/src/main/resources/microservice.yaml
@@ -108,8 +108,6 @@ servicecomb:
abort:
httpStatus: 421
percent: 50
- test:
- duplicate1: newer
# test governance retry
matchGroup:
@@ -136,9 +134,7 @@ cse:
testTimeout:
timeout:
enabled: true
- timeoutInMilliseconds: 1000
- test:
- duplicate2: newer
+ timeoutInMilliseconds: 1000S
3rd-svc:
urls:
diff --git a/demo/demo-springmvc/springmvc-client/src/test/java/org/apache/servicecomb/demo/springmvc/SpringMvcIT.java b/demo/demo-springmvc/springmvc-client/src/test/java/org/apache/servicecomb/demo/springmvc/SpringMvcIT.java
index 414273ab9..e39f55eb2 100644
--- a/demo/demo-springmvc/springmvc-client/src/test/java/org/apache/servicecomb/demo/springmvc/SpringMvcIT.java
+++ b/demo/demo-springmvc/springmvc-client/src/test/java/org/apache/servicecomb/demo/springmvc/SpringMvcIT.java
@@ -21,7 +21,12 @@ import org.apache.servicecomb.demo.TestMgr;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+@ExtendWith(SpringExtension.class)
+@SpringBootTest(classes = SpringmvcClient.class)
public class SpringMvcIT {
@BeforeEach
@@ -31,7 +36,7 @@ public class SpringMvcIT {
@Test
public void clientGetsNoError() throws Exception {
- SpringmvcClient.main(new String[0]);
+ SpringmvcClient.run();
Assertions.assertTrue(TestMgr.errors().isEmpty());
}
diff --git a/demo/demo-springmvc/springmvc-server/pom.xml b/demo/demo-springmvc/springmvc-server/pom.xml
index 429bd3034..9cd18130f 100644
--- a/demo/demo-springmvc/springmvc-server/pom.xml
+++ b/demo/demo-springmvc/springmvc-server/pom.xml
@@ -65,8 +65,8 @@
<build>
<plugins>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
diff --git a/demo/demo-springmvc/springmvc-server/src/main/java/org/apache/servicecomb/demo/springmvc/SpringmvcServer.java b/demo/demo-springmvc/springmvc-server/src/main/java/org/apache/servicecomb/demo/springmvc/SpringmvcServer.java
index d0ec27631..3834cbad3 100644
--- a/demo/demo-springmvc/springmvc-server/src/main/java/org/apache/servicecomb/demo/springmvc/SpringmvcServer.java
+++ b/demo/demo-springmvc/springmvc-server/src/main/java/org/apache/servicecomb/demo/springmvc/SpringmvcServer.java
@@ -17,10 +17,13 @@
package org.apache.servicecomb.demo.springmvc;
-import org.apache.servicecomb.foundation.common.utils.BeanUtils;
+import org.apache.servicecomb.springboot2.starter.EnableServiceComb;
+import org.springframework.boot.WebApplicationType;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+@EnableServiceComb
public class SpringmvcServer {
public static void main(String[] args) throws Exception {
- BeanUtils.init();
+ new SpringApplicationBuilder(SpringmvcServer.class).web(WebApplicationType.NONE).run(args);
}
}
diff --git a/demo/demo-zeroconfig-schemadiscovery-registry/demo-zeroconfig-schemadiscovery-registry-tests/pom.xml b/demo/demo-zeroconfig-schemadiscovery-registry/demo-zeroconfig-schemadiscovery-registry-tests/pom.xml
index 714776b33..89f843849 100644
--- a/demo/demo-zeroconfig-schemadiscovery-registry/demo-zeroconfig-schemadiscovery-registry-tests/pom.xml
+++ b/demo/demo-zeroconfig-schemadiscovery-registry/demo-zeroconfig-schemadiscovery-registry-tests/pom.xml
@@ -45,7 +45,7 @@
<artifactId>demo-schema</artifactId>
</dependency>
</dependencies>
-
+
<profiles>
<profile>
<id>docker</id>
diff --git a/demo/pom.xml b/demo/pom.xml
index fb6c12c2e..1c240008d 100644
--- a/demo/pom.xml
+++ b/demo/pom.xml
@@ -49,7 +49,6 @@
<module>demo-local-registry</module>
<module>demo-multi-registries</module>
<module>demo-zeroconfig-schemadiscovery-registry</module>
- <module>demo-spring-boot-provider</module>
<module>demo-spring-boot-transport</module>
<module>demo-edge</module>
<module>demo-multiple</module>
diff --git a/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/utils/BeanUtils.java b/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/utils/BeanUtils.java
index 4f0b91770..dfbd3e272 100644
--- a/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/utils/BeanUtils.java
+++ b/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/utils/BeanUtils.java
@@ -17,107 +17,25 @@
package org.apache.servicecomb.foundation.common.utils;
-import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
-import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
-import java.util.Set;
-import org.apache.commons.lang3.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.aop.framework.AopProxyUtils;
import org.springframework.context.ApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
public final class BeanUtils {
- private static final Logger LOGGER = LoggerFactory.getLogger(BeanUtils.class);
-
public static final String DEFAULT_BEAN_CORE_RESOURCE = "classpath*:META-INF/spring/scb-core-bean.xml";
public static final String DEFAULT_BEAN_NORMAL_RESOURCE = "classpath*:META-INF/spring/*.bean.xml";
- public static final String[] DEFAULT_BEAN_RESOURCE = new String[] {DEFAULT_BEAN_CORE_RESOURCE
- , DEFAULT_BEAN_NORMAL_RESOURCE};
-
- public static final String SCB_SCAN_PACKAGE = "scb-scan-package";
-
- private static final String SCB_PACKAGE = "org.apache.servicecomb";
-
private static ApplicationContext context;
private BeanUtils() {
}
- public static void init() {
- init(DEFAULT_BEAN_RESOURCE);
- }
-
- public static void init(String... configLocations) {
- prepareServiceCombScanPackage();
-
- Set<String> locationSet = new LinkedHashSet<>();
- addBeanLocation(locationSet, DEFAULT_BEAN_RESOURCE);
- addBeanLocation(locationSet, configLocations);
- context = new ClassPathXmlApplicationContext(locationSet.toArray(new String[0]));
- }
-
- public static void addBeanLocation(Set<String> locationSet, String... location) {
- Arrays.stream(location).forEach(loc -> addBeanLocation(locationSet, loc));
- }
-
- public static void addBeanLocation(Set<String> locationSet, String location) {
- if (location == null) {
- return;
- }
-
- location = location.trim();
- if (StringUtils.isNotEmpty(location)) {
- locationSet.add(location);
- }
- }
-
- private static void addItem(Set<String> set, String item) {
- for (String it : set) {
- if (item.startsWith(it)) {
- return;
- }
- }
- set.add(item);
- }
-
- public static void prepareServiceCombScanPackage() {
- Set<String> scanPackages = new LinkedHashSet<>();
- // add exists settings
- String exists = System.getProperty(SCB_SCAN_PACKAGE);
- if (exists != null) {
- for (String exist : exists.trim().split(",")) {
- if (!exist.isEmpty()) {
- addItem(scanPackages, exist.trim());
- }
- }
- }
-
- // ensure servicecomb package exist
- addItem(scanPackages, SCB_PACKAGE);
-
- // add main class package
- for (Class<?> mainClass : new Class<?>[] {JvmUtils.findMainClass(), JvmUtils.findMainClassByStackTrace()}) {
- if (mainClass != null && mainClass.getPackage() != null) {
- String pkg = mainClass.getPackage().getName();
- addItem(scanPackages, pkg);
- }
- }
-
- // finish
- String scbScanPackages = StringUtils.join(scanPackages, ",");
- System.setProperty(SCB_SCAN_PACKAGE, scbScanPackages);
- LOGGER.info("Scb scan package list: " + scbScanPackages);
- }
-
public static ApplicationContext getContext() {
return context;
}
diff --git a/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/utils/ResourceUtil.java b/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/utils/ResourceUtil.java
index 4aa7e33be..037900d9a 100644
--- a/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/utils/ResourceUtil.java
+++ b/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/utils/ResourceUtil.java
@@ -68,8 +68,7 @@ public final class ResourceUtil {
Enumeration<URL> dirURLs = JvmUtils.findClassLoader().getResources(resourceLocation);
while (dirURLs.hasMoreElements()) {
URL dirURL = dirURLs.nextElement();
-
- if (dirURL.getProtocol().equals("file")) {
+ if ("file".equals(dirURL.getProtocol())) {
Path dirPath = Paths.get(dirURL.toURI());
collectResourcesFromPath(dirPath, filter, result);
continue;
@@ -77,7 +76,16 @@ public final class ResourceUtil {
try (FileSystem fileSystem = FileSystems.newFileSystem(dirURL.toURI(), Collections.emptyMap())) {
Path dirPath = fileSystem.getPath(resourceLocation);
- collectResourcesFromPath(dirPath, filter, result);
+ if (Files.exists(dirPath)) {
+ // normal jar files like : xxx.jar!/resourceLocation
+ collectResourcesFromPath(dirPath, filter, result);
+ } else {
+ // spring boot fat jar files like : xxx.jar!/BOOT-INF/!classes/resourceLocation
+ dirPath = fileSystem.getPath("BOOT-INF", "classes", resourceLocation);
+ if (Files.exists(dirPath)) {
+ collectResourcesFromPath(dirPath, filter, result);
+ }
+ }
}
}
diff --git a/foundations/foundation-common/src/test/java/TestNoPackageMain.java b/foundations/foundation-common/src/test/java/TestNoPackageMain.java
deleted file mode 100644
index 22b57e48b..000000000
--- a/foundations/foundation-common/src/test/java/TestNoPackageMain.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import org.apache.servicecomb.foundation.common.utils.BeanUtils;
-import org.apache.servicecomb.foundation.common.utils.JvmUtils;
-
-import mockit.Expectations;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.condition.EnabledOnJre;
-import org.junit.jupiter.api.condition.JRE;
-
-public class TestNoPackageMain {
- @Test
- @EnabledOnJre(JRE.JAVA_8)
- public void prepareServiceCombScanPackage_mainNoPackage() {
- System.clearProperty(BeanUtils.SCB_SCAN_PACKAGE);
- new Expectations(JvmUtils.class) {
- {
- JvmUtils.findMainClass();
- result = TestNoPackageMain.class;
- JvmUtils.findMainClassByStackTrace();
- result = null;
- }
- };
-
- BeanUtils.prepareServiceCombScanPackage();
-
- Assertions.assertEquals("org.apache.servicecomb", System.getProperty(BeanUtils.SCB_SCAN_PACKAGE));
- }
-}
diff --git a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/ResourceUtilTest.java b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/ResourceUtilTest.java
index c5e7a1fd9..9982eca92 100644
--- a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/ResourceUtilTest.java
+++ b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/ResourceUtilTest.java
@@ -27,18 +27,6 @@ import org.junit.jupiter.api.Test;
public class ResourceUtilTest {
- /**
- * This case is coupled with the Spring dependency, but in order to check the ability to read resources inside the
- * jar packs, this may be the simplest way.
- */
- @Test
- public void loadResources_in_jar() throws IOException, URISyntaxException {
- List<URI> uris = ResourceUtil.findResources("META-INF", p -> p.toString().endsWith("spring.factories"));
- Assertions.assertEquals(1, uris.size());
- Assertions.assertTrue(uris.get(0).toString().startsWith("jar:file:"));
- Assertions.assertTrue(uris.get(0).toString().endsWith("!/META-INF/spring.factories"));
- }
-
@Test
public void loadResources_in_disk() throws IOException, URISyntaxException {
List<URI> uris = ResourceUtil.findResourcesBySuffix("META-INF/spring", ".xml");
diff --git a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestBeanUtils.java b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestBeanUtils.java
deleted file mode 100644
index 31d1f9cfa..000000000
--- a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestBeanUtils.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.servicecomb.foundation.common.utils;
-
-import java.math.BigDecimal;
-
-import mockit.MockUp;
-import org.aspectj.lang.annotation.Aspect;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.Test;
-import org.springframework.aop.SpringProxy;
-import org.springframework.aop.aspectj.annotation.AspectJProxyFactory;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-import mockit.Expectations;
-
-public class TestBeanUtils {
- interface Intf {
-
- }
-
- static class Impl implements Intf {
-
- }
-
- // 被代理的类
- static class TestBean{
-
- }
-
- // 模拟 CgLib 代理产生的子类
- static class TestBean$$TestBeanByCGLIB$$e1a36bab extends TestBean implements SpringProxy {
-
- }
-
- @Aspect
- static class MyAspect {
- }
-
- @BeforeAll
- public static void setup() {
- System.clearProperty(BeanUtils.SCB_SCAN_PACKAGE);
- }
-
- @AfterAll
- public static void tearDown() {
- System.clearProperty(BeanUtils.SCB_SCAN_PACKAGE);
- }
-
- @Test
- public void test() {
- Intf target = new Impl();
- AspectJProxyFactory factory = new AspectJProxyFactory(target);
- MyAspect aspect = new MyAspect();
- factory.addAspect(aspect);
- Intf proxy = factory.getProxy();
-
- Assertions.assertEquals(Impl.class, BeanUtils.getImplClassFromBean(proxy));
- Assertions.assertEquals(Impl.class, BeanUtils.getImplClassFromBean(new Impl()));
- }
-
- @Test
- public void prepareServiceCombScanPackage_noExist_noMain() {
- System.clearProperty(BeanUtils.SCB_SCAN_PACKAGE);
- new Expectations(JvmUtils.class) {
- {
- JvmUtils.findMainClass();
- result = null;
- JvmUtils.findMainClassByStackTrace();
- result = null;
- }
- };
-
- BeanUtils.prepareServiceCombScanPackage();
-
- Assertions.assertEquals("org.apache.servicecomb", System.getProperty(BeanUtils.SCB_SCAN_PACKAGE));
- }
-
- @Test
- public void prepareServiceCombScanPackage_noExist_scbMain() {
- System.clearProperty(BeanUtils.SCB_SCAN_PACKAGE);
- new Expectations(JvmUtils.class) {
- {
- JvmUtils.findMainClass();
- result = TestBeanUtils.class;
- JvmUtils.findMainClassByStackTrace();
- result = TestBeanUtils.class;
- }
- };
-
- BeanUtils.prepareServiceCombScanPackage();
-
- Assertions.assertEquals("org.apache.servicecomb", System.getProperty(BeanUtils.SCB_SCAN_PACKAGE));
- }
-
- @Test
- public void prepareServiceCombScanPackage_noExist_otherMain() {
- System.clearProperty(BeanUtils.SCB_SCAN_PACKAGE);
- new Expectations(JvmUtils.class) {
- {
- JvmUtils.findMainClass();
- result = String.class;
- JvmUtils.findMainClassByStackTrace();
- result = BigDecimal.class;
- }
- };
-
- BeanUtils.prepareServiceCombScanPackage();
-
- Assertions.assertEquals("org.apache.servicecomb,java.lang,java.math", System.getProperty(BeanUtils.SCB_SCAN_PACKAGE));
- }
-
- @Test
- public void prepareServiceCombScanPackage_exist() {
- System.setProperty(BeanUtils.SCB_SCAN_PACKAGE, "a.b,,c.d");
- new Expectations(JvmUtils.class) {
- {
- JvmUtils.findMainClass();
- result = null;
- JvmUtils.findMainClassByStackTrace();
- result = null;
- }
- };
-
- BeanUtils.prepareServiceCombScanPackage();
-
- Assertions.assertEquals("a.b,c.d,org.apache.servicecomb", System.getProperty(BeanUtils.SCB_SCAN_PACKAGE));
- }
-
- @Test
- public void init() {
- new MockUp<ClassPathXmlApplicationContext>() {
- };
- System.clearProperty(BeanUtils.SCB_SCAN_PACKAGE);
- new Expectations(JvmUtils.class) {
- {
- JvmUtils.findMainClass();
- result = TestBeanUtils.class;
- JvmUtils.findMainClassByStackTrace();
- result = TestBeanUtils.class;
- }
- };
- BeanUtils.init();
-
- Assertions.assertEquals("org.apache.servicecomb", System.getProperty(BeanUtils.SCB_SCAN_PACKAGE));
- }
-
- @Test
- public void testGetImplClassFromBeanFromCglib(){
- TestBean testBeanByCGLIB = new TestBean$$TestBeanByCGLIB$$e1a36bab();
- Class<?> generatedClass = BeanUtils.getImplClassFromBean(testBeanByCGLIB);
- Assertions.assertNotNull(generatedClass);
- Assertions.assertEquals(TestBean.class, generatedClass);
- }
-
-
-}
diff --git a/parents/default/pom.xml b/parents/default/pom.xml
index a1c8aefb9..610819440 100644
--- a/parents/default/pom.xml
+++ b/parents/default/pom.xml
@@ -85,12 +85,22 @@
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>
-
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-test</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
diff --git a/pom.xml b/pom.xml
index db0545ee2..a0946d979 100644
--- a/pom.xml
+++ b/pom.xml
@@ -466,6 +466,9 @@
<profiles>
<profile>
<id>release</id>
+ <modules>
+ <module>distribution</module>
+ </modules>
<properties>
<skip-remote-resource>false</skip-remote-resource>
</properties>
@@ -552,15 +555,6 @@
<module>demo</module>
</modules>
</profile>
- <profile>
- <id>distribution</id>
- <properties>
- <skip-remote-resource>false</skip-remote-resource>
- </properties>
- <modules>
- <module>distribution</module>
- </modules>
- </profile>
<profile>
<id>coverage</id>
<modules>
diff --git a/spring-boot/spring-boot-starters/java-chassis-spring-boot-starter/pom.xml b/spring-boot/spring-boot-starters/java-chassis-spring-boot-starter/pom.xml
index 8248fd53e..9f060d656 100644
--- a/spring-boot/spring-boot-starters/java-chassis-spring-boot-starter/pom.xml
+++ b/spring-boot/spring-boot-starters/java-chassis-spring-boot-starter/pom.xml
@@ -34,8 +34,8 @@
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
- <groupId>org.slf4j</groupId>
- <artifactId>log4j-over-slf4j</artifactId>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
diff --git a/transports/transport-rest/transport-rest-servlet/src/main/java/org/apache/servicecomb/transport/rest/servlet/CseDispatcherServlet.java b/transports/transport-rest/transport-rest-servlet/src/main/java/org/apache/servicecomb/transport/rest/servlet/CseDispatcherServlet.java
deleted file mode 100644
index 1b2ad7000..000000000
--- a/transports/transport-rest/transport-rest-servlet/src/main/java/org/apache/servicecomb/transport/rest/servlet/CseDispatcherServlet.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.servicecomb.transport.rest.servlet;
-
-import org.springframework.context.ApplicationContext;
-import org.springframework.web.context.WebApplicationContext;
-import org.springframework.web.servlet.DispatcherServlet;
-
-public class CseDispatcherServlet extends DispatcherServlet {
- private static final long serialVersionUID = 5755456289644038012L;
-
- @Override
- protected WebApplicationContext createWebApplicationContext(ApplicationContext parent) {
- setContextClass(CseXmlWebApplicationContext.class);
- return super.createWebApplicationContext(parent);
- }
-}
diff --git a/transports/transport-rest/transport-rest-servlet/src/main/java/org/apache/servicecomb/transport/rest/servlet/CseXmlWebApplicationContext.java b/transports/transport-rest/transport-rest-servlet/src/main/java/org/apache/servicecomb/transport/rest/servlet/CseXmlWebApplicationContext.java
deleted file mode 100644
index f8831deb6..000000000
--- a/transports/transport-rest/transport-rest-servlet/src/main/java/org/apache/servicecomb/transport/rest/servlet/CseXmlWebApplicationContext.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.servicecomb.transport.rest.servlet;
-
-import java.util.Arrays;
-import java.util.LinkedHashSet;
-import java.util.Set;
-
-import javax.servlet.ServletContext;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.servicecomb.foundation.common.utils.BeanUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
-import org.springframework.web.context.support.XmlWebApplicationContext;
-
-public class CseXmlWebApplicationContext extends XmlWebApplicationContext {
- private static final Logger LOGGER = LoggerFactory.getLogger(CseXmlWebApplicationContext.class);
-
- static final String KEY_LOCATION = "contextConfigLocation";
-
- private String[] defaultBeanResource = BeanUtils.DEFAULT_BEAN_RESOURCE;
-
- public CseXmlWebApplicationContext() {
- }
-
- public CseXmlWebApplicationContext(ServletContext servletContext) {
- setServletContext(servletContext);
- }
-
- public void setDefaultBeanResource(String[] defaultBeanResource) {
- if (defaultBeanResource == null) {
- return;
- }
-
- this.defaultBeanResource = defaultBeanResource;
- }
-
- @Override
- protected void invokeBeanFactoryPostProcessors(ConfigurableListableBeanFactory beanFactory) {
- super.invokeBeanFactoryPostProcessors(beanFactory);
-
- // inject servlet after config installed and before transport init
- ServletUtils.init(getServletContext());
- }
-
- @Override
- public String[] getConfigLocations() {
- String contextConfigLocation = getServletContext().getInitParameter(KEY_LOCATION);
- String[] locationArray = splitLocations(contextConfigLocation);
-
- LOGGER.info("init spring context: {}.", Arrays.toString(locationArray));
- return locationArray;
- }
-
- private String[] splitLocations(String locations) {
- Set<String> locationSet = new LinkedHashSet<>();
- BeanUtils.addBeanLocation(locationSet, BeanUtils.DEFAULT_BEAN_RESOURCE);
- BeanUtils.addBeanLocation(locationSet, defaultBeanResource);
-
- if (StringUtils.isNotEmpty(locations)) {
- for (String location : locations.split("[,\n]")) {
- BeanUtils.addBeanLocation(locationSet, location);
- }
- }
-
- return locationSet.toArray(new String[0]);
- }
-}
diff --git a/transports/transport-rest/transport-rest-servlet/src/main/java/org/apache/servicecomb/transport/rest/servlet/RestServletContextListener.java b/transports/transport-rest/transport-rest-servlet/src/main/java/org/apache/servicecomb/transport/rest/servlet/RestServletContextListener.java
deleted file mode 100644
index c510f261c..000000000
--- a/transports/transport-rest/transport-rest-servlet/src/main/java/org/apache/servicecomb/transport/rest/servlet/RestServletContextListener.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.servicecomb.transport.rest.servlet;
-
-import javax.servlet.ServletContextEvent;
-import javax.servlet.ServletContextListener;
-
-import org.springframework.context.support.AbstractApplicationContext;
-
-public class RestServletContextListener implements ServletContextListener {
- private AbstractApplicationContext context;
-
- @Override
- public void contextInitialized(ServletContextEvent sce) {
- try {
- initSpring(sce);
- } catch (Exception e) {
- throw new Error(e);
- }
- }
-
- public AbstractApplicationContext initSpring(ServletContextEvent sce) {
- context = new CseXmlWebApplicationContext(sce.getServletContext());
- context.refresh();
- return context;
- }
-
- @Override
- public void contextDestroyed(ServletContextEvent sce) {
- if (context == null) {
- return;
- }
-
- context.close();
- context = null;
- }
-}
diff --git a/transports/transport-rest/transport-rest-servlet/src/test/java/org/apache/servicecomb/transport/rest/servlet/TestCseXmlWebApplicationContext.java b/transports/transport-rest/transport-rest-servlet/src/test/java/org/apache/servicecomb/transport/rest/servlet/TestCseXmlWebApplicationContext.java
deleted file mode 100644
index e80d8bb6d..000000000
--- a/transports/transport-rest/transport-rest-servlet/src/test/java/org/apache/servicecomb/transport/rest/servlet/TestCseXmlWebApplicationContext.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.servicecomb.transport.rest.servlet;
-
-import javax.servlet.ServletContext;
-import javax.servlet.ServletRegistration.Dynamic;
-
-import org.apache.servicecomb.foundation.common.Holder;
-import org.apache.servicecomb.foundation.common.utils.BeanUtils;
-import org.hamcrest.MatcherAssert;
-import org.hamcrest.Matchers;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.jupiter.api.Assertions;
-import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
-
-import mockit.Expectations;
-import mockit.Mock;
-import mockit.MockUp;
-import mockit.Mocked;
-
-public class TestCseXmlWebApplicationContext {
- @Mocked
- ServletContext servletContext;
-
- CseXmlWebApplicationContext context;
-
- @Before
- public void setup() {
- context = new CseXmlWebApplicationContext(servletContext);
- }
-
- @Test
- public void testGetConfigLocationsEmpty() {
- String[] result = context.getConfigLocations();
- MatcherAssert.assertThat(result,
- Matchers.arrayContaining(BeanUtils.DEFAULT_BEAN_CORE_RESOURCE, BeanUtils.DEFAULT_BEAN_NORMAL_RESOURCE));
- }
-
- @Test
- public void testGetConfigLocationsEmptyAndDefaultEmpty() {
- context.setDefaultBeanResource(null);
- String[] result = context.getConfigLocations();
- MatcherAssert.assertThat(result,
- Matchers.arrayContaining(BeanUtils.DEFAULT_BEAN_CORE_RESOURCE, BeanUtils.DEFAULT_BEAN_NORMAL_RESOURCE));
- }
-
- @Test
- public void testGetConfigLocationsComma() {
- new Expectations() {
- {
- servletContext.getInitParameter(CseXmlWebApplicationContext.KEY_LOCATION);
- result = "a,b";
- }
- };
-
- String[] result = context.getConfigLocations();
- MatcherAssert.assertThat(result, Matchers
- .arrayContaining(BeanUtils.DEFAULT_BEAN_CORE_RESOURCE, BeanUtils.DEFAULT_BEAN_NORMAL_RESOURCE, "a", "b"));
- }
-
- @Test
- public void testGetConfigLocationsPartEmpty() {
- new Expectations() {
- {
- servletContext.getInitParameter(CseXmlWebApplicationContext.KEY_LOCATION);
- result = "a,,b";
- }
- };
- String[] result = context.getConfigLocations();
- MatcherAssert.assertThat(result, Matchers
- .arrayContaining(BeanUtils.DEFAULT_BEAN_CORE_RESOURCE, BeanUtils.DEFAULT_BEAN_NORMAL_RESOURCE, "a", "b"));
- }
-
- @Test
- public void testGetConfigLocationsLine() {
- new Expectations() {
- {
- servletContext.getInitParameter(CseXmlWebApplicationContext.KEY_LOCATION);
- result = "a\r\nb";
- }
- };
- String[] result = context.getConfigLocations();
- MatcherAssert.assertThat(result, Matchers
- .arrayContaining(BeanUtils.DEFAULT_BEAN_CORE_RESOURCE, BeanUtils.DEFAULT_BEAN_NORMAL_RESOURCE, "a", "b"));
- }
-
- @Test
- public void testGetConfigLocationsMix() {
- new Expectations() {
- {
- servletContext.getInitParameter(CseXmlWebApplicationContext.KEY_LOCATION);
- result = "a\r\nb,,c";
- }
- };
- String[] result = context.getConfigLocations();
- MatcherAssert.assertThat(result, Matchers
- .arrayContaining(BeanUtils.DEFAULT_BEAN_CORE_RESOURCE, BeanUtils.DEFAULT_BEAN_NORMAL_RESOURCE, "a", "b", "c"));
- }
-
- @Test
- public void testInjectServlet(@Mocked ConfigurableListableBeanFactory beanFactory) {
- Holder<Boolean> holder = new Holder<>();
- new MockUp<RestServletInjector>() {
- @Mock
- public Dynamic defaultInject(ServletContext servletContext) {
- holder.value = true;
- return null;
- }
- };
-
- context.invokeBeanFactoryPostProcessors(beanFactory);
-
- Assertions.assertTrue(holder.value);
- }
-}
diff --git a/transports/transport-rest/transport-rest-servlet/src/test/java/org/apache/servicecomb/transport/rest/servlet/TestRestServletContextListener.java b/transports/transport-rest/transport-rest-servlet/src/test/java/org/apache/servicecomb/transport/rest/servlet/TestRestServletContextListener.java
deleted file mode 100644
index 75187b0f1..000000000
--- a/transports/transport-rest/transport-rest-servlet/src/test/java/org/apache/servicecomb/transport/rest/servlet/TestRestServletContextListener.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.servicecomb.transport.rest.servlet;
-
-import javax.servlet.ServletContext;
-import javax.servlet.ServletContextEvent;
-
-import org.junit.Test;
-import org.junit.jupiter.api.Assertions;
-import org.mockito.Mockito;
-
-public class TestRestServletContextListener {
- @Test
- public void testcontextInitializedException() {
- boolean status = true;
- RestServletContextListener listener = new RestServletContextListener();
- ServletContextEvent sce = Mockito.mock(ServletContextEvent.class);
-
- try {
- listener.contextInitialized(sce);
- } catch (Exception | Error e) {
- status = false;
- }
- Assertions.assertFalse(status);
- }
-
- @Test
- public void testInitSpring() {
- boolean status = true;
- RestServletContextListener listener = new RestServletContextListener();
- ServletContextEvent sce = Mockito.mock(ServletContextEvent.class);
- ServletContext context = Mockito.mock(ServletContext.class);
- Mockito.when(sce.getServletContext()).thenReturn(context);
- Mockito.when(sce.getServletContext().getInitParameter("contextConfigLocation")).thenReturn("locations");
- try {
- listener.initSpring(sce);
- } catch (Exception e) {
- status = false;
- }
- Assertions.assertFalse(status);
- }
-}