This is an automated email from the ASF dual-hosted git repository.
liubao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-samples.git
The following commit(s) were added to refs/heads/master by this push:
new 906cfdf update BMI sample to fill latest docs (#130)
906cfdf is described below
commit 906cfdff822e62ff80eacc61375b0f27ea0708df
Author: liubao68 <[email protected]>
AuthorDate: Mon Nov 20 17:11:41 2023 +0800
update BMI sample to fill latest docs (#130)
---
bmi/calculator/pom.xml | 60 +++++-------
.../servicecomb/samples/CalculatorApplication.java | 10 +-
.../servicecomb/samples/CalculatorServiceImpl.java | 12 ++-
bmi/calculator/src/main/resources/application.yml | 17 +++-
bmi/calculator/src/main/resources/log4j2.xml | 71 ++++++++++++++
bmi/pom.xml | 81 ++++++----------
bmi/webapp/pom.xml | 54 +++++------
bmi/webapp/src/main/resources/application.yml | 63 ++++++++++++-
bmi/webapp/src/main/resources/log4j2.xml | 71 ++++++++++++++
bmi/webapp/src/main/resources/static/index.html | 9 +-
java-chassis-samples/bmi/README.md | 53 -----------
java-chassis-samples/bmi/build.gradle | 60 ------------
java-chassis-samples/bmi/calculator/build.gradle | 52 -----------
java-chassis-samples/bmi/calculator/pom.xml | 61 ------------
.../servicecomb/samples/bmi/BMIViewObject.java | 60 ------------
.../samples/bmi/CalculatorApplication.java | 31 ------
.../samples/bmi/CalculatorEndpoint.java | 29 ------
.../samples/bmi/CalculatorRestEndpoint.java | 53 -----------
.../servicecomb/samples/bmi/CalculatorService.java | 29 ------
.../samples/bmi/CalculatorServiceImpl.java | 44 ---------
.../samples/bmi/InstanceInfoService.java | 26 ------
.../samples/bmi/InstanceInfoServiceImpl.java | 40 --------
.../calculator/src/main/resources/application.yml | 35 -------
java-chassis-samples/bmi/pom.xml | 52 -----------
java-chassis-samples/bmi/settings.gradle | 23 -----
java-chassis-samples/bmi/webapp/build.gradle | 50 ----------
java-chassis-samples/bmi/webapp/pom.xml | 50 ----------
.../samples/bmi/GatewayApplication.java | 31 ------
.../samples/bmi/StaticWebpageDispatcher.java | 51 ----------
...cecomb.transport.rest.vertx.VertxHttpDispatcher | 18 ----
.../bmi/webapp/src/main/resources/application.yml | 51 ----------
.../webapp/src/main/resources/static/index.html | 104 ---------------------
.../src/main/resources/static/jquery-1.11.1.min.js | 4 -
java-chassis-samples/pom.xml | 1 -
34 files changed, 313 insertions(+), 1143 deletions(-)
diff --git a/bmi/calculator/pom.xml b/bmi/calculator/pom.xml
index f6bced8..6326efa 100644
--- a/bmi/calculator/pom.xml
+++ b/bmi/calculator/pom.xml
@@ -17,42 +17,28 @@
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <parent>
- <artifactId>bmi</artifactId>
- <groupId>org.apache.servicecomb.samples</groupId>
- <version>3.0.0-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
-
- <artifactId>bmi-calculator</artifactId>
- <name>Java Chassis::Samples::BMI::Calculator</name>
-
- <dependencies>
-
- <dependency>
- <groupId>org.apache.servicecomb</groupId>
- <artifactId>java-chassis-spring-boot-starter-servlet</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.servicecomb</groupId>
- <artifactId>handler-flowcontrol-qps</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.servicecomb</groupId>
- <artifactId>handler-tracing-zipkin</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-maven-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>bmi</artifactId>
+ <groupId>org.apache.servicecomb.samples</groupId>
+ <version>3.0.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>bmi-calculator</artifactId>
+ <name>Java Chassis::Samples::BMI::Calculator</name>
+
+ <properties>
+
<start-class>org.apache.servicecomb.samples.CalculatorApplication</start-class>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
</project>
diff --git
a/bmi/calculator/src/main/java/org/apache/servicecomb/samples/CalculatorApplication.java
b/bmi/calculator/src/main/java/org/apache/servicecomb/samples/CalculatorApplication.java
index 388d4f2..4ccf47d 100644
---
a/bmi/calculator/src/main/java/org/apache/servicecomb/samples/CalculatorApplication.java
+++
b/bmi/calculator/src/main/java/org/apache/servicecomb/samples/CalculatorApplication.java
@@ -17,13 +17,17 @@
package org.apache.servicecomb.samples;
-import org.springframework.boot.SpringApplication;
+import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.builder.SpringApplicationBuilder;
@SpringBootApplication
public class CalculatorApplication {
-
public static void main(String[] args) {
- SpringApplication.run(CalculatorApplication.class, args);
+ try {
+ new
SpringApplicationBuilder().web(WebApplicationType.NONE).sources(CalculatorApplication.class).run(args);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
}
}
diff --git
a/bmi/calculator/src/main/java/org/apache/servicecomb/samples/CalculatorServiceImpl.java
b/bmi/calculator/src/main/java/org/apache/servicecomb/samples/CalculatorServiceImpl.java
index d0b865b..0df11cf 100644
---
a/bmi/calculator/src/main/java/org/apache/servicecomb/samples/CalculatorServiceImpl.java
+++
b/bmi/calculator/src/main/java/org/apache/servicecomb/samples/CalculatorServiceImpl.java
@@ -17,19 +17,27 @@
package org.apache.servicecomb.samples;
-import org.springframework.stereotype.Service;
-
import java.math.BigDecimal;
import java.math.RoundingMode;
+import org.apache.servicecomb.swagger.invocation.exception.CommonExceptionData;
+import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
@Service
public class CalculatorServiceImpl implements CalculatorService {
+ @Value("${bmi.mock.error:false}")
+ private boolean mockError = false;
/**
* {@inheritDoc}
*/
@Override
public double calculate(double height, double weight) {
+ if (mockError) {
+ throw new InvocationException(503, "mock error.", new
CommonExceptionData("mock error."));
+ }
if (height <= 0 || weight <= 0) {
throw new IllegalArgumentException("Arguments must be above 0");
}
diff --git a/bmi/calculator/src/main/resources/application.yml
b/bmi/calculator/src/main/resources/application.yml
index 879c927..dca58c1 100644
--- a/bmi/calculator/src/main/resources/application.yml
+++ b/bmi/calculator/src/main/resources/application.yml
@@ -16,9 +16,6 @@
## limitations under the License.
## ---------------------------------------------------------------------------
-server:
- port: 7777
-
servicecomb:
registry:
sc:
@@ -29,4 +26,16 @@ servicecomb:
version: 0.0.1
rest:
- address: 0.0.0.0:7777
\ No newline at end of file
+ address: 0.0.0.0:7777
+
+ matchGroup:
+ bmi-operation: |
+ matches:
+ - apiPath:
+ exact: "/bmi"
+# rateLimiting:
+# bmi-operation: |
+# timeoutDuration: 0
+# limitRefreshPeriod: 1000
+# rate: 1
+
diff --git a/bmi/calculator/src/main/resources/log4j2.xml
b/bmi/calculator/src/main/resources/log4j2.xml
new file mode 100644
index 0000000..6cc0d98
--- /dev/null
+++ b/bmi/calculator/src/main/resources/log4j2.xml
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+ http://www.apache.org/licenses/LICENSE-2.0
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<Configuration>
+ <Properties>
+ <property name="FILE_PATH" value="./logs/calculator"/>
+ </Properties>
+
+ <Appenders>
+ <Console name="Console" target="SYSTEM_OUT">
+ <PatternLayout pattern="%d [%p][%t][%c:%L] %m%n"/>
+ </Console>
+
+ <RollingFile name="AccessLog" fileName="${FILE_PATH}/access.log"
+ filePattern="${FILE_PATH}/access-%d{yyyy-MM-dd}_%i.log.gz">
+ <PatternLayout pattern="%d [%t] %m%n"/>
+ <Policies>
+ <SizeBasedTriggeringPolicy size="20MB"/>
+ </Policies>
+ <DefaultRolloverStrategy max="100"/>
+ </RollingFile>
+
+ <RollingFile name="MetricsLog" fileName="${FILE_PATH}/metrics.log"
+ filePattern="${FILE_PATH}/metrics-%d{yyyy-MM-dd}_%i.log.gz">
+ <PatternLayout pattern="%d [%t] %m%n"/>
+ <Policies>
+ <SizeBasedTriggeringPolicy size="20MB"/>
+ </Policies>
+ <DefaultRolloverStrategy max="100"/>
+ </RollingFile>
+
+ <RollingFile name="SlowLog" fileName="${FILE_PATH}/slow.log"
+ filePattern="${FILE_PATH}/slow-%d{yyyy-MM-dd}_%i.log.gz">
+ <PatternLayout pattern="%d [%t] %m%n"/>
+ <Policies>
+ <SizeBasedTriggeringPolicy size="20MB"/>
+ </Policies>
+ <DefaultRolloverStrategy max="100"/>
+ </RollingFile>
+ </Appenders>
+
+ <Loggers>
+ <Logger name="scb-access" level="INFO" additivity="false">
+ <AppenderRef ref="AccessLog"/>
+ </Logger>
+ <Logger name="scb-metrics" level="INFO" additivity="false">
+ <AppenderRef ref="MetricsLog"/>
+ </Logger>
+ <Logger name="scb-slow" level="INFO" additivity="false">
+ <AppenderRef ref="SlowLog"/>
+ </Logger>
+
+ <Root level="INFO">
+ <AppenderRef ref="Console"/>
+ </Root>
+ </Loggers>
+</Configuration>
diff --git a/bmi/pom.xml b/bmi/pom.xml
index 2698b97..7e204e2 100644
--- a/bmi/pom.xml
+++ b/bmi/pom.xml
@@ -16,7 +16,7 @@
-->
<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">
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.servicecomb.samples</groupId>
@@ -28,7 +28,8 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<servicecomb.version>3.0.0-SNAPSHOT</servicecomb.version>
- <argLine>-Dfile.encoding=UTF-8</argLine>
+ <spring-boot-maven-plugin.version>3.1.3</spring-boot-maven-plugin.version>
+ <maven-compiler-plugin.version>3.11.0</maven-compiler-plugin.version>
<java.version>17</java.version>
</properties>
@@ -49,6 +50,27 @@
<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>solution-basic</artifactId>
+ </dependency>
+ <!-- using log4j2 -->
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-slf4j-impl</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-core</artifactId>
+ </dependency>
</dependencies>
<modules>
@@ -59,14 +81,14 @@
<description>Quick Start Demo for Using ServiceComb Java
Chassis</description>
<build>
-
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
- <version>3.1</version>
+ <version>${maven-compiler-plugin.version}</version>
<configuration>
+ <compilerArgument>-parameters</compilerArgument>
<source>17</source>
<target>17</target>
</configuration>
@@ -74,7 +96,7 @@
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
- <version>2.1.2.RELEASE</version>
+ <version>${spring-boot-maven-plugin.version}</version>
<executions>
<execution>
<goals>
@@ -88,54 +110,5 @@
</plugin>
</plugins>
</pluginManagement>
-
- <plugins>
- <!-- 配置项目使用jdk1.8编译 -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>3.1</version>
- <configuration>
- <compilerArgument>-parameters</compilerArgument>
- <encoding>UTF-8</encoding>
- <source>17</source>
- <target>17</target>
- <compilerArgs>
- <arg>-Werror</arg>
- <arg>-Xlint:all</arg>
- <!--not care for jdk8/jdk7 compatible problem-->
- <arg>-Xlint:-classfile</arg>
- <!--not care for annotation not processed-->
- <arg>-Xlint:-processing</arg>
- </compilerArgs>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-deploy-plugin</artifactId>
- <version>2.8.2</version>
- <configuration>
- <skip>true</skip>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.rat</groupId>
- <artifactId>apache-rat-plugin</artifactId>
- <version>0.13</version>
- <configuration>
- <excludes>
- <exclude>.travis.yml</exclude>
- <exclude>**/*.md</exclude>
- <exclude>**/target/*</exclude>
- <!-- Skip the ssl configuration files -->
- <exculde>**/resources/ssl/**</exculde>
- <!-- Skip the protobuf files -->
- <exclude>**/*.proto</exclude>
- <!-- Skip the idl files -->
- <exclude>**/*.idl</exclude>
- </excludes>
- </configuration>
- </plugin>
- </plugins>
</build>
</project>
diff --git a/bmi/webapp/pom.xml b/bmi/webapp/pom.xml
index fc82d4e..46ba20c 100644
--- a/bmi/webapp/pom.xml
+++ b/bmi/webapp/pom.xml
@@ -17,34 +17,34 @@
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <parent>
- <artifactId>bmi</artifactId>
- <groupId>org.apache.servicecomb.samples</groupId>
- <version>3.0.0-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>bmi</artifactId>
+ <groupId>org.apache.servicecomb.samples</groupId>
+ <version>3.0.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
- <artifactId>webapp</artifactId>
- <name>Java Chassis::Samples::BMI::Webapp</name>
+ <artifactId>webapp</artifactId>
+ <name>Java Chassis::Samples::BMI::Webapp</name>
- <dependencies>
- <dependency>
- <groupId>org.apache.servicecomb</groupId>
-
<artifactId>java-chassis-spring-boot-starter-standalone</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.servicecomb</groupId>
- <artifactId>edge-core</artifactId>
- </dependency>
- </dependencies>
+ <properties>
+
<start-class>org.apache.servicecomb.samples.GatewayApplication</start-class>
+ </properties>
- <build>
- <plugins>
- <plugin>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-maven-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.servicecomb</groupId>
+ <artifactId>edge-core</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
</project>
diff --git a/bmi/webapp/src/main/resources/application.yml
b/bmi/webapp/src/main/resources/application.yml
index 230022a..c995d1d 100644
--- a/bmi/webapp/src/main/resources/application.yml
+++ b/bmi/webapp/src/main/resources/application.yml
@@ -30,6 +30,67 @@ servicecomb:
tracing:
enabled: false
+ matchGroup:
+ bmi-operation: |
+ matches:
+ - apiPath:
+ exact: "/bmi"
+ bmi-operation-heavy: |
+ matches:
+ - apiPath:
+ exact: "/bmi"
+ queries:
+ weight:
+ compare: ">=60"
+ bmi-operation-thin: |
+ matches:
+ - apiPath:
+ exact: "/bmi"
+ queries:
+ weight:
+ compare: "<60"
+ mapper:
+ bmi-operation-heavy: |
+ target:
+ x-gray: "1"
+ bmi-operation-thin: |
+ target:
+ x-gray: "0"
+# instanceIsolation:
+# bmi-operation: |
+# minimumNumberOfCalls: 5
+# slidingWindowSize: 10
+# slidingWindowType: COUNT_BASED
+# failureRateThreshold: 50
+# slowCallRateThreshold: 100
+# slowCallDurationThreshold: 3000
+# recordFailureStatus: [503]
+# waitDurationInOpenState: 10000
+# permittedNumberOfCallsInHalfOpenState: 10
+
+ # enable router for edge service
+ router:
+ type: router
+ globalRouteRule: |
+ - precedence: 2
+ match:
+ headers:
+ x-gray:
+ exact: "1"
+ route:
+ - weight: 100
+ tags:
+ version: 0.0.2
+ - precedence: 1
+ match:
+ headers:
+ x-gray:
+ exact: "0"
+ route:
+ - weight: 100
+ tags:
+ version: 0.0.1
+
http:
dispatcher:
edge:
@@ -49,4 +110,4 @@ servicecomb:
# This is web root for windows server, change this path according to where you
put your source code
gateway:
- webroot:
/code/servicecomb-samples/java-chassis-samples/bmi/webapp/src/main/resources/static
\ No newline at end of file
+ webroot: /code/servicecomb-samples/bmi/webapp/src/main/resources/static
diff --git a/bmi/webapp/src/main/resources/log4j2.xml
b/bmi/webapp/src/main/resources/log4j2.xml
new file mode 100644
index 0000000..7bfc22e
--- /dev/null
+++ b/bmi/webapp/src/main/resources/log4j2.xml
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+ http://www.apache.org/licenses/LICENSE-2.0
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<Configuration>
+ <Properties>
+ <property name="FILE_PATH" value="./logs/webapp"/>
+ </Properties>
+
+ <Appenders>
+ <Console name="Console" target="SYSTEM_OUT">
+ <PatternLayout pattern="%d [%p][%t][%c:%L] %m%n"/>
+ </Console>
+
+ <RollingFile name="AccessLog" fileName="${FILE_PATH}/access.log"
+ filePattern="${FILE_PATH}/access-%d{yyyy-MM-dd}_%i.log.gz">
+ <PatternLayout pattern="%d [%t] %m%n"/>
+ <Policies>
+ <SizeBasedTriggeringPolicy size="20MB"/>
+ </Policies>
+ <DefaultRolloverStrategy max="100"/>
+ </RollingFile>
+
+ <RollingFile name="MetricsLog" fileName="${FILE_PATH}/metrics.log"
+ filePattern="${FILE_PATH}/metrics-%d{yyyy-MM-dd}_%i.log.gz">
+ <PatternLayout pattern="%d [%t] %m%n"/>
+ <Policies>
+ <SizeBasedTriggeringPolicy size="20MB"/>
+ </Policies>
+ <DefaultRolloverStrategy max="100"/>
+ </RollingFile>
+
+ <RollingFile name="SlowLog" fileName="${FILE_PATH}/slow.log"
+ filePattern="${FILE_PATH}/slow-%d{yyyy-MM-dd}_%i.log.gz">
+ <PatternLayout pattern="%d [%t] %m%n"/>
+ <Policies>
+ <SizeBasedTriggeringPolicy size="20MB"/>
+ </Policies>
+ <DefaultRolloverStrategy max="100"/>
+ </RollingFile>
+ </Appenders>
+
+ <Loggers>
+ <Logger name="scb-access" level="INFO" additivity="false">
+ <AppenderRef ref="AccessLog"/>
+ </Logger>
+ <Logger name="scb-metrics" level="INFO" additivity="false">
+ <AppenderRef ref="MetricsLog"/>
+ </Logger>
+ <Logger name="scb-slow" level="INFO" additivity="false">
+ <AppenderRef ref="SlowLog"/>
+ </Logger>
+
+ <Root level="INFO">
+ <AppenderRef ref="Console"/>
+ </Root>
+ </Loggers>
+</Configuration>
diff --git a/bmi/webapp/src/main/resources/static/index.html
b/bmi/webapp/src/main/resources/static/index.html
index 8dcbd56..91524c1 100644
--- a/bmi/webapp/src/main/resources/static/index.html
+++ b/bmi/webapp/src/main/resources/static/index.html
@@ -89,13 +89,8 @@
return;
}
var resp = JSON.parse(xhr.responseText);
- if (xhr.status == 429) {
- $("#error_message").text(resp.message);
-
$("#error").removeClass().addClass("alert").addClass("alert-danger").show();
- } else {
- $("#error_message").text(resp.error + ": " + resp.exception)
-
$("#error").removeClass().addClass("alert").addClass("alert-danger").show();
- }
+ $("#error_message").text(resp.message);
+
$("#error").removeClass().addClass("alert").addClass("alert-danger").show();
}
});
});
diff --git a/java-chassis-samples/bmi/README.md
b/java-chassis-samples/bmi/README.md
deleted file mode 100644
index ed2eb0c..0000000
--- a/java-chassis-samples/bmi/README.md
+++ /dev/null
@@ -1,53 +0,0 @@
-# Body Mass Index(BMI) Calculator Microservice Demo
-
-Check this
[document](https://docs.servicecomb.io/java-chassis/zh_CN/featured-topics/application-bmi/)
for details explanations about this demo.
-
-## Architecture of BMI Calculator
-There are two microservices in this demo.
-* Webapp (API Gateway)
-* BMI Calculator (computing service)
-
-## Prerequisite
-1. [Oracle JDK
1.8+](https://docs.oracle.com/javase/8/docs/technotes/guides/install/install_overview.html)
-2. [Maven 3.x](https://maven.apache.org/install.html)
-3. [Gradle 4.x](https://gradle.org/install/)(Optional)
-## Precondition
-see [Precondition](../../README.md)
-
-## Quick Start(Linux)
-* Run the service center
-
- - [how to start the service
center](http://servicecomb.apache.org/docs/products/service-center/install/)
-
-
-* Run microservices
-
- * via maven
- * Run the **BMI calculator service**
-
- ```bash
- cd bmi/calculator; mvn spring-boot:run
- ```
-
- * Run the **webapp service**
-
- ```bash
- cd bmi/webapp; mvn spring-boot:run
- ```
-
- * via gradle
-
- * Run the **BMI calculator service**
-
- ```bash
- cd bmi/calculator; gradle bootRun
- ```
-
- * Run the **webapp service**
-
- ```bash
- cd bmi/webapp; gradle bootRun
- ```
-
-* Visit the services via **<a>http://127.0.0.1:8889</a>**.
-
diff --git a/java-chassis-samples/bmi/build.gradle
b/java-chassis-samples/bmi/build.gradle
deleted file mode 100644
index 910663e..0000000
--- a/java-chassis-samples/bmi/build.gradle
+++ /dev/null
@@ -1,60 +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.
- */
-
-apply plugin: 'java'
-
-compileJava {
- options.compilerArgs << '-parameters'
-}
-
-allprojects {
- apply plugin: 'maven'
-
- group = 'org.apache.servicecomb.samples'
- version = '1.0.0-SNAPSHOT'
-}
-
-buildscript {
- dependencies {
-
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.12.RELEASE")
- }
- repositories {
- mavenLocal()
- mavenCentral()
- }
-}
-
-subprojects {
- apply plugin: 'java'
- apply plugin: 'org.springframework.boot'
-
- sourceCompatibility = 1.8
- targetCompatibility = 1.8
-
- tasks.withType(JavaCompile) {
- options.encoding = 'UTF-8'
- }
-
- repositories {
- mavenLocal()
- mavenCentral()
- }
-
- dependencies {
- compile group: 'org.hibernate', name: 'hibernate-validator',
version:'5.2.4.Final'
- }
-}
diff --git a/java-chassis-samples/bmi/calculator/build.gradle
b/java-chassis-samples/bmi/calculator/build.gradle
deleted file mode 100644
index 9b9dc06..0000000
--- a/java-chassis-samples/bmi/calculator/build.gradle
+++ /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.
- */
-
-description = 'Java Chassis::Samples::BMI::Calculator'
-
-apply plugin: 'java'
-
-compileJava {
- options.compilerArgs << '-parameters'
-}
-
-dependencies {
- compile group: 'org.apache.servicecomb', name:
'java-chassis-spring-boot-starter-servlet'
- compile group: 'org.apache.servicecomb', name: 'handler-flowcontrol-qps'
- compile group: 'org.apache.servicecomb', name: 'handler-bizkeeper'
- compile group: 'org.apache.servicecomb', name: 'handler-tracing-zipkin'
-}
-
-// dependency-management-plugin is a replacement of dependencyManagement in
maven
-// we need to enable the plugin and specify the dependencyManagement in the
following form in each submodule
-// according to the official document:
https://github.com/spring-gradle-plugins/dependency-management-plugin.
-buildscript {
- dependencies {
-
classpath('io.spring.gradle:dependency-management-plugin:1.0.4.RELEASE')
- }
- repositories {
- mavenLocal()
- mavenCentral()
- }
-}
-
-apply plugin: 'io.spring.dependency-management'
-
-dependencyManagement {
- imports {
- mavenBom 'org.apache.servicecomb:java-chassis-dependencies:2.0.0'
- }
-}
diff --git a/java-chassis-samples/bmi/calculator/pom.xml
b/java-chassis-samples/bmi/calculator/pom.xml
deleted file mode 100644
index 40a7018..0000000
--- a/java-chassis-samples/bmi/calculator/pom.xml
+++ /dev/null
@@ -1,61 +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">
- <parent>
- <artifactId>bmi</artifactId>
- <groupId>org.apache.servicecomb.samples</groupId>
- <version>2.6.0</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
-
- <artifactId>bmi-calculator</artifactId>
- <name>Java Chassis::Samples::BMI::Calculator</name>
-
- <dependencies>
-
- <dependency>
- <groupId>org.apache.servicecomb</groupId>
- <artifactId>java-chassis-spring-boot-starter-servlet</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.servicecomb</groupId>
- <artifactId>handler-flowcontrol-qps</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.servicecomb</groupId>
- <artifactId>handler-bizkeeper</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.servicecomb</groupId>
- <artifactId>handler-tracing-zipkin</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-maven-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
-
-</project>
diff --git
a/java-chassis-samples/bmi/calculator/src/main/java/org/apache/servicecomb/samples/bmi/BMIViewObject.java
b/java-chassis-samples/bmi/calculator/src/main/java/org/apache/servicecomb/samples/bmi/BMIViewObject.java
deleted file mode 100644
index 54f00ec..0000000
---
a/java-chassis-samples/bmi/calculator/src/main/java/org/apache/servicecomb/samples/bmi/BMIViewObject.java
+++ /dev/null
@@ -1,60 +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.samples.bmi;
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-public class BMIViewObject {
-
- private double result;
-
- private String instanceId;
-
- private String callTime;
-
- public BMIViewObject(double result, String instanceId, Date now) {
- this.result = result;
- this.instanceId = instanceId;
- this.callTime = new SimpleDateFormat("HH:mm:ss").format(now);
- }
-
- public double getResult() {
- return result;
- }
-
- public void setResult(double result) {
- this.result = result;
- }
-
- public String getInstanceId() {
- return instanceId;
- }
-
- public void setInstanceId(String instanceId) {
- this.instanceId = instanceId;
- }
-
- public String getCallTime() {
- return callTime;
- }
-
- public void setCallTime(String callTime) {
- this.callTime = callTime;
- }
-}
diff --git
a/java-chassis-samples/bmi/calculator/src/main/java/org/apache/servicecomb/samples/bmi/CalculatorApplication.java
b/java-chassis-samples/bmi/calculator/src/main/java/org/apache/servicecomb/samples/bmi/CalculatorApplication.java
deleted file mode 100644
index d65394f..0000000
---
a/java-chassis-samples/bmi/calculator/src/main/java/org/apache/servicecomb/samples/bmi/CalculatorApplication.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.samples.bmi;
-
-import org.apache.servicecomb.springboot2.starter.EnableServiceComb;
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-
-@SpringBootApplication
-@EnableServiceComb
-public class CalculatorApplication {
-
- public static void main(String[] args) {
- SpringApplication.run(CalculatorApplication.class, args);
- }
-}
diff --git
a/java-chassis-samples/bmi/calculator/src/main/java/org/apache/servicecomb/samples/bmi/CalculatorEndpoint.java
b/java-chassis-samples/bmi/calculator/src/main/java/org/apache/servicecomb/samples/bmi/CalculatorEndpoint.java
deleted file mode 100644
index 8be9b40..0000000
---
a/java-chassis-samples/bmi/calculator/src/main/java/org/apache/servicecomb/samples/bmi/CalculatorEndpoint.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.servicecomb.samples.bmi;
-
-/**
- * {@link CalculatorEndpoint} provides the common interface for different
endpoint implementations.
- * It needs to be declared as public.
- */
-public interface CalculatorEndpoint {
- /**
- * Calculate the BMI(Body Mass Index).
- */
- BMIViewObject calculate(double height, double weight);
-}
diff --git
a/java-chassis-samples/bmi/calculator/src/main/java/org/apache/servicecomb/samples/bmi/CalculatorRestEndpoint.java
b/java-chassis-samples/bmi/calculator/src/main/java/org/apache/servicecomb/samples/bmi/CalculatorRestEndpoint.java
deleted file mode 100644
index de899fb..0000000
---
a/java-chassis-samples/bmi/calculator/src/main/java/org/apache/servicecomb/samples/bmi/CalculatorRestEndpoint.java
+++ /dev/null
@@ -1,53 +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.samples.bmi;
-
-import java.util.Date;
-
-import org.apache.servicecomb.provider.rest.common.RestSchema;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-
-/**
- * {@link CalculatorRestEndpoint} provides the rest implementation of {@link
CalculatorEndpoint}.
- * The rest endpoint is accessed by /bmi?height={value}&weight={value} with
HTTP GET.
- */
-@RestSchema(schemaId = "calculatorRestEndpoint")
-@RequestMapping(path = "/")
-public class CalculatorRestEndpoint implements CalculatorEndpoint {
-
- private final CalculatorService calculatorService;
-
- private final InstanceInfoService instanceInfoService;
-
- @Autowired
- public CalculatorRestEndpoint(CalculatorService calculatorService,
InstanceInfoService instanceInfoService) {
- this.calculatorService = calculatorService;
- this.instanceInfoService = instanceInfoService;
- }
-
- @GetMapping(path = "/bmi")
- @Override
- public BMIViewObject calculate(double height, double weight) {
-
- String instanceId = instanceInfoService.getInstanceId();
- double bmiResult = calculatorService.calculate(height, weight);
- return new BMIViewObject(bmiResult, instanceId, new Date());
- }
-}
diff --git
a/java-chassis-samples/bmi/calculator/src/main/java/org/apache/servicecomb/samples/bmi/CalculatorService.java
b/java-chassis-samples/bmi/calculator/src/main/java/org/apache/servicecomb/samples/bmi/CalculatorService.java
deleted file mode 100644
index 4d0fc8d..0000000
---
a/java-chassis-samples/bmi/calculator/src/main/java/org/apache/servicecomb/samples/bmi/CalculatorService.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.servicecomb.samples.bmi;
-
-/**
- * {@link CalculatorService} provides interface of actual BMI calculation.
- */
-public interface CalculatorService {
-
- /**
- * @see CalculatorEndpoint#calculate(double, double)
- */
- double calculate(double height, double weight);
-}
diff --git
a/java-chassis-samples/bmi/calculator/src/main/java/org/apache/servicecomb/samples/bmi/CalculatorServiceImpl.java
b/java-chassis-samples/bmi/calculator/src/main/java/org/apache/servicecomb/samples/bmi/CalculatorServiceImpl.java
deleted file mode 100644
index 1d70a18..0000000
---
a/java-chassis-samples/bmi/calculator/src/main/java/org/apache/servicecomb/samples/bmi/CalculatorServiceImpl.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.servicecomb.samples.bmi;
-
-import java.math.BigDecimal;
-import java.math.RoundingMode;
-
-import org.springframework.stereotype.Service;
-
-@Service
-public class CalculatorServiceImpl implements CalculatorService {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public double calculate(double height, double weight) {
- if (height <= 0 || weight <= 0) {
- throw new IllegalArgumentException("Arguments must be above 0");
- }
- double heightInMeter = height / 100;
- double bmi = weight / (heightInMeter * heightInMeter);
- return roundToOnePrecision(bmi);
- }
-
- private double roundToOnePrecision(double value) {
- return BigDecimal.valueOf(value).setScale(1,
RoundingMode.HALF_UP).doubleValue();
- }
-}
diff --git
a/java-chassis-samples/bmi/calculator/src/main/java/org/apache/servicecomb/samples/bmi/InstanceInfoService.java
b/java-chassis-samples/bmi/calculator/src/main/java/org/apache/servicecomb/samples/bmi/InstanceInfoService.java
deleted file mode 100644
index d6fad32..0000000
---
a/java-chassis-samples/bmi/calculator/src/main/java/org/apache/servicecomb/samples/bmi/InstanceInfoService.java
+++ /dev/null
@@ -1,26 +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.samples.bmi;
-
-/**
- * {@link InstanceInfoService} provides interface of instance information.
- */
-public interface InstanceInfoService {
-
- String getInstanceId();
-}
diff --git
a/java-chassis-samples/bmi/calculator/src/main/java/org/apache/servicecomb/samples/bmi/InstanceInfoServiceImpl.java
b/java-chassis-samples/bmi/calculator/src/main/java/org/apache/servicecomb/samples/bmi/InstanceInfoServiceImpl.java
deleted file mode 100644
index 8a960a2..0000000
---
a/java-chassis-samples/bmi/calculator/src/main/java/org/apache/servicecomb/samples/bmi/InstanceInfoServiceImpl.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.servicecomb.samples.bmi;
-
-import org.apache.servicecomb.registry.RegistrationManager;
-import org.apache.servicecomb.registry.api.registry.MicroserviceInstance;
-import org.springframework.stereotype.Service;
-
-@Service
-public class InstanceInfoServiceImpl implements InstanceInfoService {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getInstanceId() {
-
- MicroserviceInstance instance =
RegistrationManager.INSTANCE.getMicroserviceInstance();
- if (instance == null) {
- throw new IllegalStateException(
- "unable to find any service instances, maybe there is problem
registering in service center?");
- }
- return instance.getInstanceId();
- }
-}
diff --git
a/java-chassis-samples/bmi/calculator/src/main/resources/application.yml
b/java-chassis-samples/bmi/calculator/src/main/resources/application.yml
deleted file mode 100644
index 5bd55ef..0000000
--- a/java-chassis-samples/bmi/calculator/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: 7777
-
-servicecomb:
- service:
- application: bmi
- name: calculator
- version: 0.0.1
-
- registry:
- address: http://127.0.0.1:30100
- rest:
- address: 0.0.0.0:7777
- handler:
- chain:
- Provider:
- default: bizkeeper-provider
\ No newline at end of file
diff --git a/java-chassis-samples/bmi/pom.xml b/java-chassis-samples/bmi/pom.xml
deleted file mode 100644
index a0352bb..0000000
--- a/java-chassis-samples/bmi/pom.xml
+++ /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.
- -->
-
-<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.samples</groupId>
- <artifactId>samples</artifactId>
- <version>2.6.0</version>
- </parent>
-
- <artifactId>bmi</artifactId>
- <name>Java Chassis::Samples::BMI</name>
- <packaging>pom</packaging>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.servicecomb</groupId>
- <artifactId>registry-service-center</artifactId>
- </dependency>
- </dependencies>
-
- <modules>
- <module>calculator</module>
- <module>webapp</module>
- </modules>
-
- <description>Quick Start Demo for Using ServiceComb Java
Chassis</description>
-
- <properties>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
- <java.version>1.8</java.version>
- </properties>
-
-</project>
diff --git a/java-chassis-samples/bmi/settings.gradle
b/java-chassis-samples/bmi/settings.gradle
deleted file mode 100644
index 308a503..0000000
--- a/java-chassis-samples/bmi/settings.gradle
+++ /dev/null
@@ -1,23 +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.
- */
-
-rootProject.name = 'bmi'
-include ':bmi-calculator'
-include ':webapp'
-
-project(':bmi-calculator').projectDir = "$rootDir/calculator" as File
-project(':webapp').projectDir = "$rootDir/webapp" as File
\ No newline at end of file
diff --git a/java-chassis-samples/bmi/webapp/build.gradle
b/java-chassis-samples/bmi/webapp/build.gradle
deleted file mode 100644
index 46abe15..0000000
--- a/java-chassis-samples/bmi/webapp/build.gradle
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-description = 'Java Chassis::Samples::BMI::Webapp'
-
-apply plugin: 'java'
-
-compileJava {
- options.compilerArgs << '-parameters'
-}
-
-dependencies {
- compile group: 'org.apache.servicecomb', name:
'java-chassis-spring-boot-starter-standalone'
- compile group: 'org.apache.servicecomb', name: 'edge-core'
-}
-
-// dependency-management-plugin is a replacement of dependencyManagement in
maven
-// we need to enable the plugin and specify the dependencyManagement in the
following form in each submodule
-// according to the official document:
https://github.com/spring-gradle-plugins/dependency-management-plugin.
-buildscript {
- dependencies {
-
classpath('io.spring.gradle:dependency-management-plugin:1.0.4.RELEASE')
- }
- repositories {
- mavenLocal()
- mavenCentral()
- }
-}
-
-apply plugin: 'io.spring.dependency-management'
-
-dependencyManagement {
- imports {
- mavenBom 'org.apache.servicecomb:java-chassis-dependencies:2.0.0'
- }
-}
diff --git a/java-chassis-samples/bmi/webapp/pom.xml
b/java-chassis-samples/bmi/webapp/pom.xml
deleted file mode 100644
index 525c004..0000000
--- a/java-chassis-samples/bmi/webapp/pom.xml
+++ /dev/null
@@ -1,50 +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">
- <parent>
- <artifactId>bmi</artifactId>
- <groupId>org.apache.servicecomb.samples</groupId>
- <version>2.6.0</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
-
- <artifactId>webapp</artifactId>
- <name>Java Chassis::Samples::BMI::Webapp</name>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.servicecomb</groupId>
- <artifactId>java-chassis-spring-boot-starter-standalone</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.servicecomb</groupId>
- <artifactId>edge-core</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-maven-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git
a/java-chassis-samples/bmi/webapp/src/main/java/org/apache/servicecomb/samples/bmi/GatewayApplication.java
b/java-chassis-samples/bmi/webapp/src/main/java/org/apache/servicecomb/samples/bmi/GatewayApplication.java
deleted file mode 100644
index 6de14dd..0000000
---
a/java-chassis-samples/bmi/webapp/src/main/java/org/apache/servicecomb/samples/bmi/GatewayApplication.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.samples.bmi;
-
-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 GatewayApplication {
- public static void main(String[] args) {
- new
SpringApplicationBuilder().web(WebApplicationType.NONE).sources(GatewayApplication.class).run(args);
- }
-}
diff --git
a/java-chassis-samples/bmi/webapp/src/main/java/org/apache/servicecomb/samples/bmi/StaticWebpageDispatcher.java
b/java-chassis-samples/bmi/webapp/src/main/java/org/apache/servicecomb/samples/bmi/StaticWebpageDispatcher.java
deleted file mode 100644
index 780c7fd..0000000
---
a/java-chassis-samples/bmi/webapp/src/main/java/org/apache/servicecomb/samples/bmi/StaticWebpageDispatcher.java
+++ /dev/null
@@ -1,51 +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.samples.bmi;
-
-import org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.netflix.config.DynamicPropertyFactory;
-
-import io.vertx.ext.web.Router;
-import io.vertx.ext.web.handler.StaticHandler;
-
-public class StaticWebpageDispatcher implements VertxHttpDispatcher {
- private static final Logger LOGGER =
LoggerFactory.getLogger(StaticWebpageDispatcher.class);
-
- private static final String WEB_ROOT = DynamicPropertyFactory.getInstance()
- .getStringProperty("gateway.webroot", "/var/static")
- .get();
-
- @Override
- public int getOrder() {
- return Integer.MAX_VALUE / 2;
- }
-
- @Override
- public void init(Router router) {
- String regex = "/(.*)";
- StaticHandler webpageHandler = StaticHandler.create();
- webpageHandler.setWebRoot(WEB_ROOT);
- LOGGER.info("server static web page for WEB_ROOT={}", WEB_ROOT);
- router.routeWithRegex(regex).failureHandler((context) -> {
- LOGGER.error("", context.failure());
- }).handler(webpageHandler);
- }
-}
diff --git
a/java-chassis-samples/bmi/webapp/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher
b/java-chassis-samples/bmi/webapp/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher
deleted file mode 100644
index 0740ab7..0000000
---
a/java-chassis-samples/bmi/webapp/src/main/resources/META-INF/services/org.apache.servicecomb.transport.rest.vertx.VertxHttpDispatcher
+++ /dev/null
@@ -1,18 +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.
-#
-
-org.apache.servicecomb.samples.bmi.StaticWebpageDispatcher
\ No newline at end of file
diff --git a/java-chassis-samples/bmi/webapp/src/main/resources/application.yml
b/java-chassis-samples/bmi/webapp/src/main/resources/application.yml
deleted file mode 100644
index 97aee70..0000000
--- a/java-chassis-samples/bmi/webapp/src/main/resources/application.yml
+++ /dev/null
@@ -1,51 +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.
-## ---------------------------------------------------------------------------
-
-servicecomb:
- service:
- application: bmi
- name: gateway
- version: 0.0.1
-
- registry:
- address: http://127.0.0.1:30100
- rest:
- address: 0.0.0.0:8889
-
- tracing:
- enabled: false
-
- http:
- dispatcher:
- edge:
- default:
- enabled: false
- prefix: api
- withVersion: false
- prefixSegmentCount: 1
- url:
- enabled: true
- mappings:
- calculator:
- prefixSegmentCount: 1
- path: "/calculator/.*"
- microserviceName: calculator
- versionRule: 0.0.0+
-
-# This is web root for windows server, change this path according to where you
put your source code
-gateway:
- webroot:
/code/servicecomb-samples/java-chassis-samples/bmi/webapp/src/main/resources/static
\ No newline at end of file
diff --git
a/java-chassis-samples/bmi/webapp/src/main/resources/static/index.html
b/java-chassis-samples/bmi/webapp/src/main/resources/static/index.html
deleted file mode 100644
index 8dcbd56..0000000
--- a/java-chassis-samples/bmi/webapp/src/main/resources/static/index.html
+++ /dev/null
@@ -1,104 +0,0 @@
-<!DOCTYPE HTML>
-<!--
- ~ 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.
- -->
-<html>
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1,
shrink-to-fit=no">
-
- <link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css"
integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M"
crossorigin="anonymous">
- <!-- jQuery first, then Popper.js, then Bootstrap JS -->
- <script src="jquery-1.11.1.min.js"></script>
- <script
src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js"
integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4"
crossorigin="anonymous"></script>
- <script
src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js"
integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1"
crossorigin="anonymous"></script>
- </head>
- <body>
- <div class="container">
-
- <div class="col-md-1"></div>
- <div class="col-md-10">
- <h2 align="center">BMI Calculator</h2>
-
- <div class="form-group">
- <label for="height" class="col-form-label"><b>Height(cm):</b></label>
- <input type="number" class="form-control" id="height" name="height"
placeholder="Please input your height">
- </div>
- <div class="form-group">
- <label for="weight"
class="col-form-label"><b>Weight(kg):</b></label>
- <input type="number" class="form-control" id="weight"
name="weight" placeholder="Please input your weight">
- </div>
- <button type="submit" class="btn btn-primary"
id="submit">Submit</button>
-
- <br/>
- <div class="alert alert-light" role="alert" id="bmi">
- <h3>BMI Result: <span id="bmi_result"></span></h3>
- <h3>BMI Instance ID: <span id="bmi_instanceId"></span></h3>
- <h3>BMI Called Time: <span id="bmi_callTime"></span></h3>
- </div>
- <div class="alert alert-secondary" role="alert">
- <b>Note: </b>Range of healthy weight is between <b>18.5</b> and
<b>24.9</b>.
- </div>
- <div id="error" class="alert alert-danger" role="alert"><p
id="error_message"></p></div>
- </div>
- </div>
-
- </body>
- <script>
- $("#error").hide();
- $("#submit").click(function () {
- if ( !$("#height").val() || !$("#weight").val() ) {
- alert("Please input both the height and weight");
- return;
- }
- $.ajax({
- url: "/calculator/bmi?height=" + $("#height").val() + "&weight=" +
$("#weight").val(),
- type: "GET",
- success: function (data) {
- $("#error").hide();
- $("#bmi_result").text(data.result);
- $("#bmi_instanceId").text(data.instanceId);
- $("#bmi_callTime").text(data.callTime);
- if ( data.result < 18.5 || (data.result < 30 && data.result >= 25)
) {
-
$("#bmi").removeClass().addClass("alert").addClass("alert-warning");
- } else if ( data.result < 25 && data.result >= 18.5 ) {
-
$("#bmi").removeClass().addClass("alert").addClass("alert-success");
- } else {
-
$("#bmi").removeClass().addClass("alert").addClass("alert-danger");
- }
- },
- error: function (xhr) {
- $("#bmi").removeClass().addClass("alert").addClass("alert-light");
- $("#bmi_result").text('');
- if (xhr.responseText.length == 0) {
- $("#error_message").text("empty fallback called");
-
$("#error").removeClass().addClass("alert").addClass("alert-success").show();
- return;
- }
- var resp = JSON.parse(xhr.responseText);
- if (xhr.status == 429) {
- $("#error_message").text(resp.message);
-
$("#error").removeClass().addClass("alert").addClass("alert-danger").show();
- } else {
- $("#error_message").text(resp.error + ": " + resp.exception)
-
$("#error").removeClass().addClass("alert").addClass("alert-danger").show();
- }
- }
- });
- });
- </script>
-
-</html>
diff --git
a/java-chassis-samples/bmi/webapp/src/main/resources/static/jquery-1.11.1.min.js
b/java-chassis-samples/bmi/webapp/src/main/resources/static/jquery-1.11.1.min.js
deleted file mode 100644
index ab28a24..0000000
---
a/java-chassis-samples/bmi/webapp/src/main/resources/static/jquery-1.11.1.min.js
+++ /dev/null
@@ -1,4 +0,0 @@
-/*! jQuery v1.11.1 | (c) 2005, 2014 jQuery Foundation, Inc. |
jquery.org/license */
-!function(a,b){"object"==typeof module&&"object"==typeof
module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw
new Error("jQuery requires a window with a document");return
b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var
c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k={},l="1.11.1",m=function(a,b){return
new
m.fn.init(a,b)},n=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,o=/^-ms-/,p=/-([\da-z])/gi,q=function(a,b
[...]
-if(k&&j[k]&&(e||j[k].data)||void 0!==d||"string"!=typeof b)return
k||(k=i?a[h]=c.pop()||m.guid++:h),j[k]||(j[k]=i?{}:{toJSON:m.noop}),("object"==typeof
b||"function"==typeof
b)&&(e?j[k]=m.extend(j[k],b):j[k].data=m.extend(j[k].data,b)),g=j[k],e||(g.data||(g.data={}),g=g.data),void
0!==d&&(g[m.camelCase(b)]=d),"string"==typeof
b?(f=g[b],null==f&&(f=g[m.camelCase(b)])):f=g,f}}function
R(a,b,c){if(m.acceptData(a)){var
d,e,f=a.nodeType,g=f?m.cache:a,h=f?a[m.expando]:m.expando;if(g[h]){if(b&& [...]
-},cur:function(){var a=Zb.propHooks[this.prop];return
a&&a.get?a.get(this):Zb.propHooks._default.get(this)},run:function(a){var
b,c=Zb.propHooks[this.prop];return
this.pos=b=this.options.duration?m.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration):a,this.now=(this.end-this.start)*b+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),c&&c.set?c.set(this):Zb.propHooks._default.set(this),this}},Zb.prototype.init.prototype=Zb.prototype,Zb.prop
[...]
diff --git a/java-chassis-samples/pom.xml b/java-chassis-samples/pom.xml
index 7a392f1..8a48d88 100644
--- a/java-chassis-samples/pom.xml
+++ b/java-chassis-samples/pom.xml
@@ -33,7 +33,6 @@
</properties>
<modules>
- <module>bmi</module>
<module>codefirst-sample</module>
<module>custom-handler-sample</module>
<module>jaxrs-sample</module>