You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by li...@apache.org on 2018/04/03 06:28:09 UTC

[incubator-servicecomb-java-chassis] 04/05: SCB-441 fix pr comment

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/incubator-servicecomb-java-chassis.git

commit 0e732773a6a6a04bfb0d276e062645b25f71df5c
Author: zhengyangyong <ya...@huawei.com>
AuthorDate: Wed Mar 28 14:29:38 2018 +0800

    SCB-441 fix pr comment
    
    Signed-off-by: zhengyangyong <ya...@huawei.com>
---
 archetypes/README.md                               | 21 +++++++++++--------
 archetypes/business-service-jaxrs/README.md        |  8 ++++----
 .../src/main/resources/microservice.yaml           | 15 +++++++++++++-
 .../servicecomb/archetypes/TestConsumer.java       | 24 ++++++++++++----------
 .../src/test/resources/localregistry.yaml          |  2 +-
 5 files changed, 44 insertions(+), 26 deletions(-)

diff --git a/archetypes/README.md b/archetypes/README.md
index 4d36b56..1e0d4fe 100644
--- a/archetypes/README.md
+++ b/archetypes/README.md
@@ -1,18 +1,21 @@
 ## ServiceComb Java Chassis Archetypes
 ### What's maven archetypes
-http://maven.apache.org/guides/introduction/introduction-to-archetypes.html
+From http://maven.apache.org/guides/introduction/introduction-to-archetypes.html :
 
-### What we will provide
+"*In short, Archetype is a Maven project templating toolkit. An archetype is defined as an original pattern or model from which all other things of the same kind are made. The name fits as we are trying to provide a system that provides a consistent means of generating Maven projects. Archetype will help authors create Maven project templates for users, and provides users with the means to generate parameterized versions of those project templates.*"
+
+"*Using archetypes provides a great way to enable developers quickly in a way consistent with best practices employed by your project or organization. Within the Maven project, we use archetypes to try and get our users up and running as quickly as possible by providing a sample project that demonstrates many of the features of Maven, while introducing new users to the best practices employed by Maven. In a matter of seconds, a new user can have a working Maven project to use as a jumpin [...]
+
+### What we provide
 1. business-service-jaxrs  
   Archetype for create a common microservice using jaxrs provider.
 
 more coming soon.. 
 
 ### How to build these archetypes
-We use **business-service-jaxrs** as example :
+We use **business-service-jaxrs** as an example :
 ```bash
-cd archetypes
-cd business-service-jaxrs
+cd archetypes/business-service-jaxrs
 mvn archetype:create-from-project
 #Wait until successed, archetype will be generated at target/generated-sources/archetype
 cd target/generated-sources/archetype
@@ -21,10 +24,10 @@ mvn install
 ```
 *Notice: The archetype ArtifactId of business-service-jaxrs is business-service-jaxrs-**archetype.***
 
-We will publish these archetypes to maven center repository when do release since 1.0.0-m2.
+We will publish these archetypes to maven center repository since 1.0.0-m2.
 
-### How to use these archetypes generate project
-We use **business-service-jaxrs** as example :
+### How to use these archetypes to generate a project
+We use **business-service-jaxrs** as an example :
 #### Generate via IntelliJ IDEA  
 New Project(Module) -> Maven -> Check "Create from archetype" -> Add Archetype... -> fill *GroupId* with value "org.apache.servicecomb.archetypes", fill *ArtifactId* with value "business-service-jaxrs-archetype", fill *Version* with current archetype version -> select this archetype that had listed, do next steps.
 
@@ -35,4 +38,4 @@ New Project(Module) -> Maven -> Next -> Add Archetype... -> fill *GroupId* with
 ```bash
 mvn archetype:generate -DarchetypeGroupId=org.apache.servicecomb.archetypes -DarchetypeArtifactId=business-service-jaxrs-archetype -DarchetypeVersion=${archetype-version}
 ```
-In console Interactive mode, input your GroupId, ArtifactId and Version of new project(module), after a short while it will be generated.
\ No newline at end of file
+In console Interactive mode, input your GroupId, ArtifactId and Version of new project(module), after a while the new project will be generated.
\ No newline at end of file
diff --git a/archetypes/business-service-jaxrs/README.md b/archetypes/business-service-jaxrs/README.md
index 7bad372..9d47cfe 100644
--- a/archetypes/business-service-jaxrs/README.md
+++ b/archetypes/business-service-jaxrs/README.md
@@ -1,12 +1,12 @@
 ## Welcome to use ServiceComb Java Chassis
-This project(module) is generate by *org.apache.servicecomb.archetypes:business-service-jaxrs-archetype*, it's use **jaxrs provider** to develop service endpoint, you can direct run test.  
+This project(module) is generate by *org.apache.servicecomb.archetypes:business-service-jaxrs-archetype*, it use **jaxrs provider** to develop service endpoint, you can run test directly.  
 ```bash
 mvn test
 ```
 
 ### More works can be done further:
-1. Modify "HelloEndpoint", add your business service logic,or create some new endpoints for provide your services.More details can be found : http://servicecomb.incubator.apache.org/users/develop-with-jax-rs/
-2. Modify "microservice.yaml", change APPLICATION_ID,service_description.name,version,and service center address,endpoints publish address etc.More details can be found : http://servicecomb.incubator.apache.org/users/service-definition/
+1. Modify "HelloEndpoint", add your business service logic, or create some new endpoints to provide your services. More details can be found : http://servicecomb.incubator.apache.org/users/develop-with-jax-rs/
+2. Modify "microservice.yaml", change APPLICATION_ID, service_description.name, version, and service center address, endpoints publish address etc. More details can be found : http://servicecomb.incubator.apache.org/users/service-definition/
 3. Add unit test for your endpoints like what we had done in "TestConsumer".
 
 ### Package your service
@@ -20,4 +20,4 @@ Then you can get outputs in target folder:
 ```bash
 java -jar xxxxxx-{version}.jar
 ```
-*Notice: If you need to modify config setting in "microservice.yaml" like service center address but don't want repackage the executable jar, **you can direct place a new "microservice.yaml" file in same folder, then settings will be overrode.***
\ No newline at end of file
+*Notice: If you need to modify config setting in "microservice.yaml" like service center address but don't want repackage the executable jar, **you can direct place a new "microservice.yaml" file in same folder, then settings will be overridden.***
\ No newline at end of file
diff --git a/archetypes/business-service-jaxrs/src/main/resources/microservice.yaml b/archetypes/business-service-jaxrs/src/main/resources/microservice.yaml
index c4b7993..ddf5f39 100644
--- a/archetypes/business-service-jaxrs/src/main/resources/microservice.yaml
+++ b/archetypes/business-service-jaxrs/src/main/resources/microservice.yaml
@@ -15,16 +15,29 @@
 ## limitations under the License.
 ## ---------------------------------------------------------------------------
 
-#More details can be found : http://servicecomb.incubator.apache.org/users/service-definition/
+#More details can be found :
+# 1.http://servicecomb.incubator.apache.org/users/service-definition/
+# 2.http://servicecomb.incubator.apache.org/users/service-configurations/
+# 3.http://servicecomb.incubator.apache.org/users/communicate-protocol/
+
+#Indicates an application name
 APPLICATION_ID: business
 service_description:
+#Indicates a microservice name
+#The microservice name should be unique within an application.
+#The name can contain digits, uppercase and lowercase letters, hyphens(-), underscores(_), and periods(.); and can neither start nor end with punctuations.
+#The naming rule is as follows: ^[a-zA-Z0-9]+$|^[a-zA-Z0-9][a-zA-Z0-9_-.]*[a-zA-Z0-9]$.
   name: business-service
+#Indicates a service version
   version: 1.0.0
 cse:
   service:
+  #Specifies the service center IP address.
     registry:
       address: http://127.0.0.1:30100
+  #Specifies the rest transport listening IP address.
   rest:
     address: 0.0.0.0:8080
+  #Specifies the highway transport listening IP address.
   highway:
     address: 0.0.0.0:7070
\ No newline at end of file
diff --git a/archetypes/business-service-jaxrs/src/test/java/org/apache/servicecomb/archetypes/TestConsumer.java b/archetypes/business-service-jaxrs/src/test/java/org/apache/servicecomb/archetypes/TestConsumer.java
index 29b10ae..230c556 100644
--- a/archetypes/business-service-jaxrs/src/test/java/org/apache/servicecomb/archetypes/TestConsumer.java
+++ b/archetypes/business-service-jaxrs/src/test/java/org/apache/servicecomb/archetypes/TestConsumer.java
@@ -20,9 +20,10 @@ package org.apache.servicecomb.archetypes;
 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.junit.After;
+import org.apache.servicecomb.serviceregistry.client.LocalServiceRegistryClientImpl;
+import org.junit.AfterClass;
 import org.junit.Assert;
-import org.junit.Before;
+import org.junit.BeforeClass;
 import org.junit.Test;
 import org.springframework.stereotype.Component;
 import org.springframework.web.client.RestTemplate;
@@ -30,16 +31,18 @@ import org.springframework.web.client.RestTemplate;
 @Component
 public class TestConsumer {
 
-  private String setting;
+  private static String setting;
+
+  private final RestTemplate restTemplate = RestTemplateBuilder.create();
 
   //use local registry for test consumer
   //more details can be found :
   // http://servicecomb.incubator.apache.org/users/develop-with-rest-template/
   // http://servicecomb.incubator.apache.org/users/develop-with-rpc/
-  @Before
-  public void setUp() {
-    setting = System.getProperty("local.registry.file");
-    System.setProperty("local.registry.file",
+  @BeforeClass
+  public static void setUp() {
+    setting = System.getProperty(LocalServiceRegistryClientImpl.LOCAL_REGISTRY_FILE_KEY);
+    System.setProperty(LocalServiceRegistryClientImpl.LOCAL_REGISTRY_FILE_KEY,
         TestConsumer.class.getProtectionDomain().getCodeSource().getLocation().getPath() + "localregistry.yaml");
   }
 
@@ -50,14 +53,13 @@ public class TestConsumer {
     BeanUtils.init();
 
     //consumer call
-    RestTemplate restTemplate = RestTemplateBuilder.create();
     String result = restTemplate.getForObject("cse://business-service/hello", String.class);
     Assert.assertEquals("Hello World!", result);
   }
 
   //recovery local.registry.file setting
-  @After
-  public void tearDown() {
-    System.setProperty("local.registry.file", setting == null ? "" : setting);
+  @AfterClass
+  public static void tearDown() {
+    System.setProperty(LocalServiceRegistryClientImpl.LOCAL_REGISTRY_FILE_KEY, setting == null ? "" : setting);
   }
 }
diff --git a/archetypes/business-service-jaxrs/src/test/resources/localregistry.yaml b/archetypes/business-service-jaxrs/src/test/resources/localregistry.yaml
index 4eea5dd..728ac91 100644
--- a/archetypes/business-service-jaxrs/src/test/resources/localregistry.yaml
+++ b/archetypes/business-service-jaxrs/src/test/resources/localregistry.yaml
@@ -15,7 +15,7 @@
 ## limitations under the License.
 ## ---------------------------------------------------------------------------
 
-# use for test consumer without service center
+# test service invocation between microservices without service center
 business-service:
   - id: "001"
     version: "1.0.0"

-- 
To stop receiving notification emails like this one, please contact
liubao@apache.org.