You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by wu...@apache.org on 2018/07/10 11:16:11 UTC

[incubator-servicecomb-java-chassis] branch master updated: [SCB-716] Implementation of Local Service Registry Demo (#791)

This is an automated email from the ASF dual-hosted git repository.

wujimin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-java-chassis.git


The following commit(s) were added to refs/heads/master by this push:
     new 0c61dd9  [SCB-716] Implementation of Local Service Registry Demo (#791)
0c61dd9 is described below

commit 0c61dd9b122718f75fe4845940ec6f372046078f
Author: Mahesh Raju Somalaraju <ma...@huawei.com>
AuthorDate: Tue Jul 10 16:46:09 2018 +0530

    [SCB-716] Implementation of Local Service Registry Demo (#791)
    
    * [SCB-716] Implementation of Local service registry demo
    
    * [SCB-716] Java Chassis- Implementation of Local service registry demo: moving code to sample folder
    
    * [SCB-716] Implementation of Local service registry sample: readme modification
    
    * [SCB-716] Implementation of Local service registry sample: changing to 1.0.0 version
    
    * [SCB-716] Implementation of Local service registry samples: Review comments fix
---
 samples/local-service-registry/README.md           | 49 ++++++++++++++
 .../local-registry-client/pom.xml                  | 71 ++++++++++++++++++++
 .../localregistryclient/LocalRegistryClient.java   | 68 +++++++++++++++++++
 .../src/main/resources/microservice.yaml           | 26 ++++++++
 .../resources/microservices/localserv/hello.yaml   | 69 +++++++++++++++++++
 .../src/main/resources/registry.yaml               | 27 ++++++++
 .../local-registry-server/pom.xml                  | 78 ++++++++++++++++++++++
 .../localregistryserver/LocalRegistryServer.java   | 29 ++++++++
 .../localregistryserver/LocalServerApi.java        | 46 +++++++++++++
 .../src/main/resources/microservice.yaml           | 30 +++++++++
 .../src/main/resources/registry.yaml               | 25 +++++++
 samples/local-service-registry/pom.xml             | 35 ++++++++++
 samples/pom.xml                                    |  1 +
 13 files changed, 554 insertions(+)

diff --git a/samples/local-service-registry/README.md b/samples/local-service-registry/README.md
new file mode 100644
index 0000000..2b2d694
--- /dev/null
+++ b/samples/local-service-registry/README.md
@@ -0,0 +1,49 @@
+## Local registry
+
+User can use local registry mechanisam and can connect server endpoints without using service center.
+For local registry mechanism user should provide the local registry file at consumer side.
+User can start provider service and get the provider schema file and put at the consumer side.
+Consumer will use local registry function and it will connect the server end points.
+
+Please find the details as follows.
+
+## Provider Side
+
+* run the provider with/without service center and get the schema file.
+
+## Consumer Side changes
+
+* Add local registry file registry.yaml :
+
+  ```yaml
+  localserv:
+    - id: "100"
+      version: "0.0.1"
+      appid: localservreg
+      schemaIds:
+        - localservregistry
+      instances:
+        - endpoints:
+          - rest://localhost:8080
+          - highway://localhost:7070
+  ```
+
+* Add the following code at the beginning and end of the service consumer Main function
+
+```java
+    public class xxxClient {
+      public static void main(String[] args) {
+      System.setProperty("local.registry.file", "/yourpath/registry.yaml");
+        //your code
+      System.clearProperty("local.registry.file");
+      }
+    }
+```
+   If file present in this path "local.registry.file" then registry mode is Local registry mode. It will not connect to service center.
+
+* Add provider's schema file at below location of consumer side
+
+  src/main/resources/microservices/{microserviceName}/{schemaId.yaml}
+  -here microserviceName is servers's microservice name. Like this multiple schemaId files we can put in same location.
+
+* Run the consumer and verify the API's output.
diff --git a/samples/local-service-registry/local-registry-client/pom.xml b/samples/local-service-registry/local-registry-client/pom.xml
new file mode 100644
index 0000000..0244c2e
--- /dev/null
+++ b/samples/local-service-registry/local-registry-client/pom.xml
@@ -0,0 +1,71 @@
+<?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>
+  <parent>
+    <groupId>org.apache.servicecomb.samples</groupId>
+    <artifactId>local-service-registry</artifactId>
+    <version>1.0.0-SNAPSHOT</version>
+  </parent>
+  <artifactId>local-registry-client</artifactId>
+  <name>Java Chassis::Demo::LocalServiceRegistry::Client</name>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.servicecomb.samples</groupId>
+      <artifactId>common-schema</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>provider-springmvc</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>transport-highway</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>transport-rest-vertx</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>handler-bizkeeper</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-log4j12</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>handler-loadbalance</artifactId>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-dependency-plugin</artifactId>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>
diff --git a/samples/local-service-registry/local-registry-client/src/main/java/org/apache/servicecomb/samples/localregistry/localregistryclient/LocalRegistryClient.java b/samples/local-service-registry/local-registry-client/src/main/java/org/apache/servicecomb/samples/localregistry/localregistryclient/LocalRegistryClient.java
new file mode 100644
index 0000000..3d26174
--- /dev/null
+++ b/samples/local-service-registry/local-registry-client/src/main/java/org/apache/servicecomb/samples/localregistry/localregistryclient/LocalRegistryClient.java
@@ -0,0 +1,68 @@
+/*
+ * 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.localregistry.localregistryclient;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.servicecomb.foundation.common.utils.BeanUtils;
+import org.apache.servicecomb.foundation.common.utils.Log4jUtils;
+import org.apache.servicecomb.provider.springmvc.reference.RestTemplateBuilder;
+import org.apache.servicecomb.samples.common.schema.models.Person;
+import org.springframework.web.client.RestTemplate;
+
+public class LocalRegistryClient {
+  private static RestTemplate templateNew = RestTemplateBuilder.create();
+
+  public static void main(String[] args) throws Exception {
+    System.setProperty("local.registry.file", "src/main/resources/registry.yaml");
+    init();
+
+    run();
+  }
+
+  public static void init() throws Exception {
+    Log4jUtils.init();
+    BeanUtils.init();
+  }
+
+  public static void run() throws Exception {
+    testLocalRegistry(templateNew);
+  }
+
+  private static void testLocalRegistry(RestTemplate template) throws Exception {
+    String microserviceName = "localserv";
+    String cseUrlPrefix = "cse://" + microserviceName + "/localservregistry/";
+
+    Map<String, String> params = new HashMap<>();
+    params.put("a", "5");
+    params.put("b", "20");
+    int result = template.postForObject(cseUrlPrefix + "add", params, Integer.class);
+    System.out.println(result);
+
+    Person person = new Person();
+    person.setName("local registry test");
+    Person sayHiResult = template
+        .postForObject(
+            cseUrlPrefix + "sayhi",
+            person,
+            Person.class);
+
+    System.out.println(sayHiResult.getName());
+  }
+}
diff --git a/samples/local-service-registry/local-registry-client/src/main/resources/microservice.yaml b/samples/local-service-registry/local-registry-client/src/main/resources/microservice.yaml
new file mode 100644
index 0000000..4a4da5a
--- /dev/null
+++ b/samples/local-service-registry/local-registry-client/src/main/resources/microservice.yaml
@@ -0,0 +1,26 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+APPLICATION_ID: localservreg
+service_description:
+  name: localclient
+  version: 0.0.1
+servicecomb:
+  handler:
+    chain:
+      Consumer:
+        default: bizkeeper-consumer,loadbalance
diff --git a/samples/local-service-registry/local-registry-client/src/main/resources/microservices/localserv/hello.yaml b/samples/local-service-registry/local-registry-client/src/main/resources/microservices/localserv/hello.yaml
new file mode 100644
index 0000000..de3c2d2
--- /dev/null
+++ b/samples/local-service-registry/local-registry-client/src/main/resources/microservices/localserv/hello.yaml
@@ -0,0 +1,69 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+swagger: "2.0"
+info:
+  version: "1.0.0"
+  title: "swagger definition for org.apache.servicecomb.samples.localregistry.localregistryserver.LocalServerApi"
+  x-java-interface: "cse.gen.localservreg.localserv.localservregistry.LocalServerApiIntf"
+basePath: "/localservregistry"
+consumes:
+- "application/json"
+produces:
+- "application/json"
+paths:
+  /add:
+    post:
+      operationId: "add"
+      parameters:
+      - name: "a"
+        in: "formData"
+        required: false
+        type: "integer"
+        format: "int32"
+      - name: "b"
+        in: "formData"
+        required: false
+        type: "integer"
+        format: "int32"
+      responses:
+        200:
+          description: "response of 200"
+          schema:
+            type: "integer"
+            format: "int32"
+  /sayhi:
+    post:
+      operationId: "sayHi"
+      parameters:
+      - in: "body"
+        name: "student"
+        required: false
+        schema:
+          $ref: "#/definitions/Person"
+      responses:
+        200:
+          description: "response of 200"
+          schema:
+            $ref: "#/definitions/Person"
+definitions:
+  Person:
+    type: "object"
+    properties:
+      name:
+        type: "string"
+    x-java-class: "org.apache.servicecomb.samples.common.schema.models.Person"
diff --git a/samples/local-service-registry/local-registry-client/src/main/resources/registry.yaml b/samples/local-service-registry/local-registry-client/src/main/resources/registry.yaml
new file mode 100644
index 0000000..4a27438
--- /dev/null
+++ b/samples/local-service-registry/local-registry-client/src/main/resources/registry.yaml
@@ -0,0 +1,27 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements.  See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License.  You may obtain a copy of the License at
+##
+##      http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+
+localserv:
+  - id: "100"
+    version: "0.0.1"
+    appid: localservreg
+    schemaIds:
+      - hello
+    instances:
+      - endpoints:
+        - rest://localhost:8080
+        - highway://localhost:7070
\ No newline at end of file
diff --git a/samples/local-service-registry/local-registry-server/pom.xml b/samples/local-service-registry/local-registry-server/pom.xml
new file mode 100644
index 0000000..4da2af1
--- /dev/null
+++ b/samples/local-service-registry/local-registry-server/pom.xml
@@ -0,0 +1,78 @@
+<?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>
+  <parent>
+    <groupId>org.apache.servicecomb.samples</groupId>
+    <artifactId>local-service-registry</artifactId>
+    <version>1.0.0-SNAPSHOT</version>
+  </parent>
+  <artifactId>local-registry-server</artifactId>
+  <name>Java Chassis::Demo::LocalRegistry::Server</name>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.servicecomb.samples</groupId>
+      <artifactId>common-schema</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>provider-jaxrs</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>transport-highway</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>transport-rest-vertx</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>handler-bizkeeper</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-log4j12</artifactId>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-dependency-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>1.0.0-SNAPSHOT</version>
+            </mixin>
+          </mixins>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/samples/local-service-registry/local-registry-server/src/main/java/org/apache/servicecomb/samples/localregistry/localregistryserver/LocalRegistryServer.java b/samples/local-service-registry/local-registry-server/src/main/java/org/apache/servicecomb/samples/localregistry/localregistryserver/LocalRegistryServer.java
new file mode 100644
index 0000000..82151d9
--- /dev/null
+++ b/samples/local-service-registry/local-registry-server/src/main/java/org/apache/servicecomb/samples/localregistry/localregistryserver/LocalRegistryServer.java
@@ -0,0 +1,29 @@
+/*
+ * 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.localregistry.localregistryserver;
+
+import org.apache.servicecomb.foundation.common.utils.BeanUtils;
+import org.apache.servicecomb.foundation.common.utils.Log4jUtils;
+
+public class LocalRegistryServer {
+  public static void main(String[] args) throws Exception {
+    System.setProperty("local.registry.file", "src/main/resources/registry.yaml");
+    Log4jUtils.init();
+    BeanUtils.init();
+  }
+}
diff --git a/samples/local-service-registry/local-registry-server/src/main/java/org/apache/servicecomb/samples/localregistry/localregistryserver/LocalServerApi.java b/samples/local-service-registry/local-registry-server/src/main/java/org/apache/servicecomb/samples/localregistry/localregistryserver/LocalServerApi.java
new file mode 100644
index 0000000..e5fea87
--- /dev/null
+++ b/samples/local-service-registry/local-registry-server/src/main/java/org/apache/servicecomb/samples/localregistry/localregistryserver/LocalServerApi.java
@@ -0,0 +1,46 @@
+/*
+ * 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.localregistry.localregistryserver;
+
+import javax.ws.rs.FormParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import org.apache.servicecomb.samples.common.schema.models.Person;
+import org.apache.servicecomb.provider.rest.common.RestSchema;
+
+@RestSchema(schemaId = "hello")
+@Path("/localservregistry")
+@Produces(MediaType.APPLICATION_JSON)
+public class LocalServerApi {
+
+  @Path("/add")
+  @POST
+  public int add(@FormParam("a") int a, @FormParam("b") int b) {
+    return a + b;
+  }
+
+  @Path("/sayhi")
+  @POST
+  public Person sayHi(Person student) {
+    student.setName("hello " + student.getName());
+    return student;
+  }
+}
diff --git a/samples/local-service-registry/local-registry-server/src/main/resources/microservice.yaml b/samples/local-service-registry/local-registry-server/src/main/resources/microservice.yaml
new file mode 100644
index 0000000..ed2b8fc
--- /dev/null
+++ b/samples/local-service-registry/local-registry-server/src/main/resources/microservice.yaml
@@ -0,0 +1,30 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+APPLICATION_ID: localservreg
+service_description:
+  name: localserv
+  version: 0.0.1
+servicecomb:
+  rest:
+    address: 0.0.0.0:8080
+  highway:
+    address: 0.0.0.0:7070
+  handler:
+    chain:
+      Provider:
+        default: bizkeeper-provider
diff --git a/samples/local-service-registry/local-registry-server/src/main/resources/registry.yaml b/samples/local-service-registry/local-registry-server/src/main/resources/registry.yaml
new file mode 100644
index 0000000..446814c
--- /dev/null
+++ b/samples/local-service-registry/local-registry-server/src/main/resources/registry.yaml
@@ -0,0 +1,25 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+localserv:
+  - id: "100"
+    version: "0.0.2"
+    appid: localservreg
+    instances:
+      - endpoints:
+        - rest://localhost:8080
+        - highway://localhost:7070
diff --git a/samples/local-service-registry/pom.xml b/samples/local-service-registry/pom.xml
new file mode 100644
index 0000000..01d0a55
--- /dev/null
+++ b/samples/local-service-registry/pom.xml
@@ -0,0 +1,35 @@
+<?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.samples</groupId>
+    <artifactId>samples</artifactId>
+    <version>1.0.0-SNAPSHOT</version>
+  </parent>
+  <artifactId>local-service-registry</artifactId>
+  <name>Java Chassis::Demo::Local service registry</name>
+  <packaging>pom</packaging>
+  <modules>
+    <module>local-registry-server</module>
+    <module>local-registry-client</module>
+  </modules>
+
+</project>
diff --git a/samples/pom.xml b/samples/pom.xml
index fd6f21d..c0c4c51 100644
--- a/samples/pom.xml
+++ b/samples/pom.xml
@@ -38,6 +38,7 @@
     <module>metrics-extend-healthcheck</module>
     <module>config-apollo-sample</module>
     <module>use-log4j2-sample</module>
+    <module>local-service-registry</module>
     <module>trust-sample</module>
   </modules>