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 a6eb9532286..de09bad77c8 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 9c4d590f17a..90e8e61fc1e 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 static final class REGISTRY_API { 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 00000000000..ac9c635287b --- /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 c39eef526ae..8e883affdf0 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 @@ public class Microservice { private String serviceId; + private Framework framework; + + private String registerBy; + private String appId; private String serviceName; @@ -189,4 +193,20 @@ public List getPaths() { public void setPaths(List 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 86e0e3d283a..77e071454fe 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_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 @@ private Microservice createMicroserviceFromDefinition(Configuration configuratio 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 00000000000..e4a059af68d --- /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 efc667a505f..957046079d6 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 void testDefaultValues() { 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 void testInitializedValues() { 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 @@ private void initMicroservice() { 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"); } }