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

ningjiang 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 1fb0be2  [SCB-171] report type/version when register to SC (#460)
1fb0be2 is described below

commit 1fb0be25403d1bb042a699a91453ee6864f1b586
Author: weichao <30716999+weichao...@users.noreply.github.com>
AuthorDate: Tue Jan 9 14:41:02 2018 +0800

    [SCB-171] report type/version when register to SC (#460)
    
    * [JAV-566] report type/version when register to SC
    
    * [JAV-566] report type/version when register to SC
    
    * Update pom.xml
    
    * Delete GetFrameworkVersionFromXml.java
    
    * [JAV-566] report type/version when register to SC
    
    * [JAV-566] report type/version when register to SC
    
    * [JAV-566] report type/version when register to SC
    
    * [JAV-566] report type/version when register to SC
    
    * fix review comments and leave configuration items in default first
    
    * beautify ut
    
    * currently set version to empty(unknown)
---
 .../common/base/ServiceCombConstants.java          |  7 ++++
 .../io/servicecomb/serviceregistry/api/Const.java  |  2 +-
 .../serviceregistry/api/registry/Framework.java    | 44 ++++++++++++++++++++++
 .../serviceregistry/api/registry/Microservice.java | 20 ++++++++++
 .../api/registry/MicroserviceFactory.java          | 10 +++++
 .../api/registry/TestFramework.java                | 39 +++++++++++++++++++
 .../api/registry/TestMicroService.java             |  9 +++++
 7 files changed, 130 insertions(+), 1 deletion(-)

diff --git 
a/foundations/foundation-common/src/main/java/io/servicecomb/foundation/common/base/ServiceCombConstants.java
 
b/foundations/foundation-common/src/main/java/io/servicecomb/foundation/common/base/ServiceCombConstants.java
index a6eb953..de09bad 100644
--- 
a/foundations/foundation-common/src/main/java/io/servicecomb/foundation/common/base/ServiceCombConstants.java
+++ 
b/foundations/foundation-common/src/main/java/io/servicecomb/foundation/common/base/ServiceCombConstants.java
@@ -50,4 +50,11 @@ public interface ServiceCombConstants {
   String CONFIG_CSE_PREFIX = "cse.";
 
   String CONFIG_KEY_SPLITER = "_";
+
+  String CONFIG_FRAMEWORK_DEFAULT_NAME = "servicecomb-java-chassis";
+
+  String CONFIG_FRAMEWORK_DEFAULT_VERSION = "";
+  
+  String CONFIG_DEFAULT_REGISTER_BY = "SDK";
+  
 }
diff --git 
a/service-registry/src/main/java/io/servicecomb/serviceregistry/api/Const.java 
b/service-registry/src/main/java/io/servicecomb/serviceregistry/api/Const.java
index 9c4d590..90e8e61 100644
--- 
a/service-registry/src/main/java/io/servicecomb/serviceregistry/api/Const.java
+++ 
b/service-registry/src/main/java/io/servicecomb/serviceregistry/api/Const.java
@@ -148,6 +148,6 @@ public final class Const {
   public static final String PATH_CHECKSESSION = "checksession";
 
   public static final String URL_PREFIX = "urlPrefix";
-  
+
   public static final String INSTANCE_PUBKEY_PRO = "publickey";
 }
diff --git 
a/service-registry/src/main/java/io/servicecomb/serviceregistry/api/registry/Framework.java
 
b/service-registry/src/main/java/io/servicecomb/serviceregistry/api/registry/Framework.java
new file mode 100644
index 0000000..ac9c635
--- /dev/null
+++ 
b/service-registry/src/main/java/io/servicecomb/serviceregistry/api/registry/Framework.java
@@ -0,0 +1,44 @@
+/*
+ * 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 io.servicecomb.serviceregistry.api.registry;
+
+/**
+ * Created by on 2017/12/20.
+ */
+public class Framework {
+  private String name;
+
+  private String version;
+
+  public String getName() {
+    return name;
+  }
+
+  public void setName(String name) {
+    this.name = name;
+  }
+
+  public String getVersion() {
+    return version;
+  }
+
+  public void setVersion(String version) {
+    this.version = version;
+  }
+
+}
diff --git 
a/service-registry/src/main/java/io/servicecomb/serviceregistry/api/registry/Microservice.java
 
b/service-registry/src/main/java/io/servicecomb/serviceregistry/api/registry/Microservice.java
index c39eef5..8e883af 100644
--- 
a/service-registry/src/main/java/io/servicecomb/serviceregistry/api/registry/Microservice.java
+++ 
b/service-registry/src/main/java/io/servicecomb/serviceregistry/api/registry/Microservice.java
@@ -34,6 +34,10 @@ import io.servicecomb.serviceregistry.api.Const;
 public class Microservice {
   private String serviceId;
 
+  private Framework framework;
+
+  private String registerBy;
+
   private String appId;
 
   private String serviceName;
@@ -189,4 +193,20 @@ public class Microservice {
   public void setPaths(List<BasePath> paths) {
     this.paths = paths;
   }
+
+  public Framework getFramework() {
+    return framework;
+  }
+
+  public void setFramework(Framework framework) {
+    this.framework = framework;
+  }
+
+  public String getRegisterBy() {
+    return registerBy;
+  }
+
+  public void setRegisterBy(String registerBy) {
+    this.registerBy = registerBy;
+  }
 }
diff --git 
a/service-registry/src/main/java/io/servicecomb/serviceregistry/api/registry/MicroserviceFactory.java
 
b/service-registry/src/main/java/io/servicecomb/serviceregistry/api/registry/MicroserviceFactory.java
index 86e0e3d..77e0714 100644
--- 
a/service-registry/src/main/java/io/servicecomb/serviceregistry/api/registry/MicroserviceFactory.java
+++ 
b/service-registry/src/main/java/io/servicecomb/serviceregistry/api/registry/MicroserviceFactory.java
@@ -21,6 +21,9 @@ import static 
io.servicecomb.foundation.common.base.ServiceCombConstants.CONFIG_
 import static 
io.servicecomb.foundation.common.base.ServiceCombConstants.CONFIG_QUALIFIED_MICROSERVICE_NAME_KEY;
 import static 
io.servicecomb.foundation.common.base.ServiceCombConstants.CONFIG_QUALIFIED_MICROSERVICE_ROLE_KEY;
 import static 
io.servicecomb.foundation.common.base.ServiceCombConstants.CONFIG_QUALIFIED_MICROSERVICE_VERSION_KEY;
+import static 
io.servicecomb.foundation.common.base.ServiceCombConstants.CONFIG_FRAMEWORK_DEFAULT_NAME;
+import static 
io.servicecomb.foundation.common.base.ServiceCombConstants.CONFIG_FRAMEWORK_DEFAULT_VERSION;
+import static 
io.servicecomb.foundation.common.base.ServiceCombConstants.CONFIG_DEFAULT_REGISTER_BY;
 import static 
io.servicecomb.foundation.common.base.ServiceCombConstants.DEFAULT_MICROSERVICE_NAME;
 import static 
io.servicecomb.serviceregistry.definition.DefinitionConst.CONFIG_ALLOW_CROSS_APP_KEY;
 import static 
io.servicecomb.serviceregistry.definition.DefinitionConst.DEFAULT_APPLICATION_ID;
@@ -66,6 +69,13 @@ public class MicroserviceFactory {
           microservice.getServiceName()));
     }
 
+    // use default values, we can add configure item in future.
+    Framework framework = new Framework();
+    framework.setName(CONFIG_FRAMEWORK_DEFAULT_NAME);
+    framework.setVersion(CONFIG_FRAMEWORK_DEFAULT_VERSION);
+    microservice.setFramework(framework);
+    microservice.setRegisterBy(CONFIG_DEFAULT_REGISTER_BY);
+
     return microservice;
   }
 
diff --git 
a/service-registry/src/test/java/io/servicecomb/serviceregistry/api/registry/TestFramework.java
 
b/service-registry/src/test/java/io/servicecomb/serviceregistry/api/registry/TestFramework.java
new file mode 100644
index 0000000..e4a059a
--- /dev/null
+++ 
b/service-registry/src/test/java/io/servicecomb/serviceregistry/api/registry/TestFramework.java
@@ -0,0 +1,39 @@
+/*
+ * 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 io.servicecomb.serviceregistry.api.registry;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestFramework {
+  @Test
+  public void testDefaultValues() {
+    Framework framework = new Framework();
+    Assert.assertNull(framework.getName());
+    Assert.assertNull(framework.getVersion());
+  }
+
+  @Test
+  public void testInitializedValues() {
+    Framework framework = new Framework();
+    framework.setName("JAVA-CHASSIS");
+    framework.setVersion("x.x.x");
+    Assert.assertEquals("JAVA-CHASSIS", framework.getName());
+    Assert.assertEquals("x.x.x", framework.getVersion());
+  }
+}
diff --git 
a/service-registry/src/test/java/io/servicecomb/serviceregistry/api/registry/TestMicroService.java
 
b/service-registry/src/test/java/io/servicecomb/serviceregistry/api/registry/TestMicroService.java
index efc667a..9570460 100644
--- 
a/service-registry/src/test/java/io/servicecomb/serviceregistry/api/registry/TestMicroService.java
+++ 
b/service-registry/src/test/java/io/servicecomb/serviceregistry/api/registry/TestMicroService.java
@@ -61,6 +61,7 @@ public class TestMicroService {
     Assert.assertEquals(MicroserviceInstanceStatus.UP.toString(), 
oMicroservice.getStatus());
     Assert.assertNull(oMicroservice.getVersion());
     Assert.assertEquals(0, oMicroservice.getPaths().size());
+    Assert.assertNull(oMicroservice.getFramework());
   }
 
   @Test
@@ -76,6 +77,9 @@ public class TestMicroService {
     Assert.assertEquals("fakeProxy", 
oMicroservice.getProperties().get("proxy"));
     Assert.assertEquals(1, oMicroservice.getSchemas().size());
     Assert.assertEquals(1, oMicroservice.getPaths().size());
+    Assert.assertEquals("JAVA-CHASSIS", 
oMicroservice.getFramework().getName());
+    Assert.assertEquals("x.x.x", oMicroservice.getFramework().getVersion());
+    Assert.assertEquals("SDK", oMicroservice.getRegisterBy());
   }
 
   private void initMicroservice() {
@@ -91,5 +95,10 @@ public class TestMicroService {
     oMicroservice.setProperties(oMapProperties);
     oMicroservice.setSchemas(oListSchemas);
     oMicroservice.getPaths().add(new BasePath());
+    Framework framework = new Framework();
+    framework.setName("JAVA-CHASSIS");
+    framework.setVersion("x.x.x");
+    oMicroservice.setFramework(framework);
+    oMicroservice.setRegisterBy("SDK");
   }
 }

-- 
To stop receiving notification emails like this one, please contact
['"commits@servicecomb.apache.org" <commits@servicecomb.apache.org>'].

Reply via email to