#83 add servicecomb-demo (#84)
diff --git a/ServiceComb-SpringMVC/Dockerfile b/ServiceComb-SpringMVC/Dockerfile
new file mode 100644
index 0000000..43e63c8
--- /dev/null
+++ b/ServiceComb-SpringMVC/Dockerfile
@@ -0,0 +1,9 @@
+FROM openjdk:8u181-jdk-alpine
+
+WORKDIR /home/apps/
+
+COPY target/*.jar app.jar
+
+RUN sh -c 'touch app.jar'
+
+ENTRYPOINT [ "sh", "-c", "java -Djava.security.egd=file:/dev/./urandom -jar -Xmx256m app.jar" ]
\ No newline at end of file
diff --git a/ServiceComb-SpringMVC/README.md b/ServiceComb-SpringMVC/README.md
new file mode 100644
index 0000000..9c68bf3
--- /dev/null
+++ b/ServiceComb-SpringMVC/README.md
@@ -0,0 +1,39 @@
+# Java CSE Spring MVC microservice
+
+| Language | Framework | Platform
+| -------- | -------- |--------|
+| Java | CSE Spring MVC | ServiceStage Container, CCE Cluster|
+
+This sample code helps get you started with a simple Java CSE microservice
+deployed by ServiceStage Container App to a CCE Cluster.
+
+This sample includes:
+
+* README.md
+* LICENSE
+* Dockerfile
+* pom.xml - this file is the Maven Project Object Model for the microservice
+* src/main - this directory contains your Java service source files
+* src/test - this directory contains your Java service unit test files
+
+## Getting Started
+
+Clone your code repository and start developing your application on IDE of your choice
+
+1. Install maven. See https://maven.apache.org/install.html for details.
+
+2. Download local-service-center from http://servicecomb.incubator.apache.org/release/. Read README.md to start local-service-center.
+
+3. Update the service registry address in microservice.yaml according to the README.md in local-service-center.
+
+4. Build the application.
+
+ $ mvn -f pom.xml package
+
+5. Run the application in IDE or execute the jar.
+
+6. Open http://127.0.0.1:8080/rest/helloworld?name=hellworld in a web browser to view your application.
+
+if you want to deploy the sample code on servicestage, View your CI/CD pipeline and service stack on ServiceStage and customize it as per your needs
+
+## Contributing
diff --git a/ServiceComb-SpringMVC/pom.xml b/ServiceComb-SpringMVC/pom.xml
new file mode 100644
index 0000000..dbd85e5
--- /dev/null
+++ b/ServiceComb-SpringMVC/pom.xml
@@ -0,0 +1,96 @@
+<?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
+ 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>
+ <groupId>com.huawei</groupId>
+ <artifactId>servicecomb</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <packaging>jar</packaging>
+
+ <name>servicecomb</name>
+ <url>http://maven.apache.org</url>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <maven.compiler.source>1.8</maven.compiler.source>
+ <maven.compiler.target>1.8</maven.compiler.target>
+ <demo.main>com.huawei.servicecomb.ServicecombspringmvcApplication</demo.main>
+ </properties>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.servicecomb</groupId>
+ <artifactId>java-chassis-dependencies</artifactId>
+ <version>2.5.0</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.servicecomb</groupId>
+ <artifactId>solution-basic</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicecomb</groupId>
+ <artifactId>registry-service-center</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicecomb</groupId>
+ <artifactId>servicestage-environment</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicecomb</groupId>
+ <artifactId>registry-service-center</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.12</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicecomb</groupId>
+ <artifactId>java-chassis-spring-boot-starter-servlet</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ <configuration>
+ <mainClass>com.huawei.servicecomb.ServicecombspringmvcApplication</mainClass>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>repackage</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/ServiceComb-SpringMVC/src/main/java/com/huawei/servicecomb/ServicecombspringmvcApplication.java b/ServiceComb-SpringMVC/src/main/java/com/huawei/servicecomb/ServicecombspringmvcApplication.java
new file mode 100644
index 0000000..b51b5d2
--- /dev/null
+++ b/ServiceComb-SpringMVC/src/main/java/com/huawei/servicecomb/ServicecombspringmvcApplication.java
@@ -0,0 +1,13 @@
+package com.huawei.servicecomb;
+
+import org.apache.servicecomb.springboot2.starter.EnableServiceComb;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+@EnableServiceComb
+public class ServicecombspringmvcApplication {
+ public static void main(String[] args) {
+ SpringApplication.run(ServicecombspringmvcApplication.class, args);
+ }
+}
diff --git a/ServiceComb-SpringMVC/src/main/java/com/huawei/servicecomb/controller/ServicecombspringmvcDelegate.java b/ServiceComb-SpringMVC/src/main/java/com/huawei/servicecomb/controller/ServicecombspringmvcDelegate.java
new file mode 100644
index 0000000..549a126
--- /dev/null
+++ b/ServiceComb-SpringMVC/src/main/java/com/huawei/servicecomb/controller/ServicecombspringmvcDelegate.java
@@ -0,0 +1,14 @@
+package com.huawei.servicecomb.controller;
+
+import org.springframework.stereotype.Component;
+
+
+@Component
+public class ServicecombspringmvcDelegate {
+
+ public String helloworld(String name) {
+
+ // Do Some Magic Here!
+ return name;
+ }
+}
diff --git a/ServiceComb-SpringMVC/src/main/java/com/huawei/servicecomb/controller/ServicecombspringmvcImpl.java b/ServiceComb-SpringMVC/src/main/java/com/huawei/servicecomb/controller/ServicecombspringmvcImpl.java
new file mode 100644
index 0000000..fd899b0
--- /dev/null
+++ b/ServiceComb-SpringMVC/src/main/java/com/huawei/servicecomb/controller/ServicecombspringmvcImpl.java
@@ -0,0 +1,28 @@
+package com.huawei.servicecomb.controller;
+
+
+import javax.ws.rs.core.MediaType;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import org.apache.servicecomb.provider.rest.common.RestSchema;
+
+@javax.annotation.Generated(value = "io.swagger.codegen.languages.CseSpringDemoCodegen", date = "2019-08-02T08:06:28.094Z")
+
+@RestSchema(schemaId = "servicecombspringmvc")
+@RequestMapping(path = "/rest", produces = MediaType.APPLICATION_JSON)
+public class ServicecombspringmvcImpl {
+
+ @Autowired
+ private ServicecombspringmvcDelegate userServicecombspringmvcDelegate;
+
+
+ @RequestMapping(value = "/helloworld",
+ produces = {"application/json"},
+ method = RequestMethod.GET)
+ public String helloworld(@RequestParam(value = "name", required = true) String name) {
+
+ return userServicecombspringmvcDelegate.helloworld(name);
+ }
+}
diff --git a/ServiceComb-SpringMVC/src/main/resources/log4j.properties b/ServiceComb-SpringMVC/src/main/resources/log4j.properties
new file mode 100644
index 0000000..37ec70b
--- /dev/null
+++ b/ServiceComb-SpringMVC/src/main/resources/log4j.properties
@@ -0,0 +1,11 @@
+# LOG4J configuration
+log4j.rootCategory=INFO,stdout,file
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %5p %c{1}:%L - %m%n
+# save logs to file
+log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
+log4j.appender.file.file=../logs/cse.log
+log4j.appender.file.DatePattern='.'yyyy-MM-dd
+log4j.appender.file.layout=org.apache.log4j.PatternLayout
+log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %5p %c{1}:%L - %m%n
\ No newline at end of file
diff --git a/ServiceComb-SpringMVC/src/main/resources/microservice.yaml b/ServiceComb-SpringMVC/src/main/resources/microservice.yaml
new file mode 100644
index 0000000..5b0f6fc
--- /dev/null
+++ b/ServiceComb-SpringMVC/src/main/resources/microservice.yaml
@@ -0,0 +1,28 @@
+APPLICATION_ID: springmvc
+service_description:
+ name: servicecombspringmvc
+ version: 0.0.1
+ properties:
+ allowCrossApp: false
+cse:
+ service:
+ registry:
+ address: http://127.0.0.1:30100
+ instance:
+ watch: false
+ config:
+ client:
+ serverUri: http://127.0.0.1:30113
+ refreshMode: 1
+ refresh_interval: 5000
+ #monitor:
+ #client:
+ #serverUri: https://cse.cn-north-1.myhuaweicloud.com
+ rest:
+ address: 0.0.0.0:8080
+ #When a local project is deployed as a container outside a cluster, you need to delete all monitor and credentials comments and configure the AK/SK.
+ #credentials:
+ #accessKey: ak
+ #secretKey: sk
+ #akskCustomCipher: default
+ #project: cn-north-1
diff --git a/ServiceComb-SpringMVC/src/test/java/com/huawei/servicecomb/controller/TestServicecombspringmvc.java b/ServiceComb-SpringMVC/src/test/java/com/huawei/servicecomb/controller/TestServicecombspringmvc.java
new file mode 100644
index 0000000..6306714
--- /dev/null
+++ b/ServiceComb-SpringMVC/src/test/java/com/huawei/servicecomb/controller/TestServicecombspringmvc.java
@@ -0,0 +1,23 @@
+package com.huawei.servicecomb.controller;
+
+
+import static org.junit.Assert.*;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestServicecombspringmvc {
+
+ ServicecombspringmvcDelegate servicecombspringmvcDelegate = new ServicecombspringmvcDelegate();
+
+
+ @Test
+ public void testhelloworld() {
+
+ String expactReturnValue = "hello"; // You should put the expect String type value here.
+
+ String returnValue = servicecombspringmvcDelegate.helloworld("hello");
+
+ assertEquals(expactReturnValue, returnValue);
+ }
+}
\ No newline at end of file