[ https://issues.apache.org/jira/browse/SCB-325?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16356637#comment-16356637 ]
ASF GitHub Bot commented on SCB-325: ------------------------------------ liubao68 closed pull request #544: [SCB-325] report sdk version when register to SC URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/544 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/client/SpringmvcClient.java b/demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/client/SpringmvcClient.java index 71f885f32..f2fc0d77a 100644 --- a/demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/client/SpringmvcClient.java +++ b/demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/client/SpringmvcClient.java @@ -19,15 +19,12 @@ import java.util.HashMap; import java.util.Map; -import java.util.Map.Entry; - import org.apache.servicecomb.core.CseContext; import org.apache.servicecomb.demo.DemoConst; import org.apache.servicecomb.demo.TestMgr; import org.apache.servicecomb.demo.controller.Controller; import org.apache.servicecomb.demo.controller.Person; import org.apache.servicecomb.foundation.common.utils.BeanUtils; -import org.apache.servicecomb.foundation.common.utils.JsonUtils; import org.apache.servicecomb.foundation.common.utils.Log4jUtils; import org.apache.servicecomb.metrics.common.MetricsDimension; import org.apache.servicecomb.metrics.common.MetricsPublisher; diff --git a/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/base/ServiceCombConstants.java b/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/base/ServiceCombConstants.java index 547c17279..e6613fa3e 100644 --- a/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/base/ServiceCombConstants.java +++ b/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/base/ServiceCombConstants.java @@ -59,8 +59,6 @@ String CONFIG_FRAMEWORK_DEFAULT_NAME = "servicecomb-java-chassis"; - String CONFIG_FRAMEWORK_DEFAULT_VERSION = ""; - String CONFIG_DEFAULT_REGISTER_BY = "SDK"; } diff --git a/pom.xml b/pom.xml index 51412e5f4..f0e1171ba 100644 --- a/pom.xml +++ b/pom.xml @@ -253,6 +253,18 @@ <excludeFilterFile>findbugs-exclude.xml</excludeFilterFile> </configuration> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <configuration> + <archive> + <manifest> + <addDefaultImplementationEntries>true</addDefaultImplementationEntries> + <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries> + </manifest> + </archive> + </configuration> + </plugin> </plugins> <pluginManagement> <plugins> diff --git a/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/api/Versions.java b/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/api/Versions.java new file mode 100644 index 000000000..5e4adfb61 --- /dev/null +++ b/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/api/Versions.java @@ -0,0 +1,23 @@ +/* + * 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.serviceregistry.api; + +import java.util.Map; + +public interface Versions { + public Map<String, String> loadVersion(); +} diff --git a/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/api/registry/FrameworkVersions.java b/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/api/registry/FrameworkVersions.java new file mode 100644 index 000000000..5c878552d --- /dev/null +++ b/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/api/registry/FrameworkVersions.java @@ -0,0 +1,43 @@ +/* + * 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.serviceregistry.api.registry; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; +import java.util.ServiceLoader; + +import org.apache.servicecomb.serviceregistry.api.Versions; + +public class FrameworkVersions { + private static final ServiceLoader<Versions> frameworkVersions = ServiceLoader.load(Versions.class); + + public static String allVersions() { + Map<String, String> versions = new HashMap<>(); + Entry<String, String> entry; + StringBuffer sb = new StringBuffer(); + + frameworkVersions.forEach(version -> versions.putAll(version.loadVersion())); + for (Iterator<Entry<String, String>> iterator = versions.entrySet().iterator(); iterator.hasNext();) { + entry = (Entry<String, String>) iterator.next(); + sb.append(entry.getKey()).append(":").append(entry.getValue()) + .append(iterator.hasNext() ? ";" : ""); + } + return sb.toString(); + } +} diff --git a/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/api/registry/MicroserviceFactory.java b/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/api/registry/MicroserviceFactory.java index fad8bf998..5c0c9735c 100644 --- a/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/api/registry/MicroserviceFactory.java +++ b/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/api/registry/MicroserviceFactory.java @@ -19,7 +19,6 @@ import static org.apache.servicecomb.foundation.common.base.ServiceCombConstants.CONFIG_APPLICATION_ID_KEY; import static org.apache.servicecomb.foundation.common.base.ServiceCombConstants.CONFIG_DEFAULT_REGISTER_BY; import static org.apache.servicecomb.foundation.common.base.ServiceCombConstants.CONFIG_FRAMEWORK_DEFAULT_NAME; -import static org.apache.servicecomb.foundation.common.base.ServiceCombConstants.CONFIG_FRAMEWORK_DEFAULT_VERSION; import static org.apache.servicecomb.foundation.common.base.ServiceCombConstants.CONFIG_QUALIFIED_MICROSERVICE_DESCRIPTION_KEY; import static org.apache.servicecomb.foundation.common.base.ServiceCombConstants.CONFIG_QUALIFIED_MICROSERVICE_NAME_KEY; import static org.apache.servicecomb.foundation.common.base.ServiceCombConstants.CONFIG_QUALIFIED_MICROSERVICE_ROLE_KEY; @@ -71,7 +70,7 @@ private Microservice createMicroserviceFromDefinition(Configuration configuratio // 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); + framework.setVersion(FrameworkVersions.allVersions()); microservice.setFramework(framework); microservice.setRegisterBy(CONFIG_DEFAULT_REGISTER_BY); diff --git a/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/api/registry/ServiceCombVersion.java b/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/api/registry/ServiceCombVersion.java new file mode 100644 index 000000000..1e6aa4387 --- /dev/null +++ b/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/api/registry/ServiceCombVersion.java @@ -0,0 +1,33 @@ +/* + * 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.serviceregistry.api.registry; + +import java.util.HashMap; +import java.util.Map; + +import org.apache.servicecomb.serviceregistry.api.Versions; + +public class ServiceCombVersion implements Versions { + + @Override + public Map<String, String> loadVersion() { + Map<String, String> map = new HashMap<>(); + map.put("ServiceComb", this.getClass().getPackage().getImplementationVersion()); + + return map; + } +} diff --git a/service-registry/src/main/resources/META-INF/services/org.apache.servicecomb.serviceregistry.api.Versions b/service-registry/src/main/resources/META-INF/services/org.apache.servicecomb.serviceregistry.api.Versions new file mode 100644 index 000000000..006f22970 --- /dev/null +++ b/service-registry/src/main/resources/META-INF/services/org.apache.servicecomb.serviceregistry.api.Versions @@ -0,0 +1,18 @@ +# +# 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. +# + +org.apache.servicecomb.serviceregistry.api.registry.ServiceCombVersion diff --git a/service-registry/src/test/java/org/apache/servicecomb/serviceregistry/api/registry/TestFrameworkVersions.java b/service-registry/src/test/java/org/apache/servicecomb/serviceregistry/api/registry/TestFrameworkVersions.java new file mode 100644 index 000000000..d02bd55fc --- /dev/null +++ b/service-registry/src/test/java/org/apache/servicecomb/serviceregistry/api/registry/TestFrameworkVersions.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.serviceregistry.api.registry; + +import org.junit.Assert; +import org.junit.Test; + +public class TestFrameworkVersions { + + @Test + public void testFrameworkVersions() { + Assert.assertEquals("ServiceComb:null", FrameworkVersions.allVersions()); + } +} diff --git a/service-registry/src/test/java/org/apache/servicecomb/serviceregistry/api/registry/TestServiceCombVersion.java b/service-registry/src/test/java/org/apache/servicecomb/serviceregistry/api/registry/TestServiceCombVersion.java new file mode 100644 index 000000000..62e722cd6 --- /dev/null +++ b/service-registry/src/test/java/org/apache/servicecomb/serviceregistry/api/registry/TestServiceCombVersion.java @@ -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. + */ + +package org.apache.servicecomb.serviceregistry.api.registry; + +import org.junit.Assert; +import org.junit.Test; + +public class TestServiceCombVersion { + + @Test + public void testServiceCombVersion() { + ServiceCombVersion version = new ServiceCombVersion(); + Assert.assertEquals("{ServiceComb=null}", version.loadVersion().toString()); + } +} ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > report sdk version when register to SC > -------------------------------------- > > Key: SCB-325 > URL: https://issues.apache.org/jira/browse/SCB-325 > Project: Apache ServiceComb > Issue Type: Improvement > Components: Java-Chassis > Reporter: WeiChao > Assignee: WeiChao > Priority: Major > > 1、SDK report their framework type and version when register to SC > 2、Each service with specific version has a certain framework+version > 3、Present the type/version information in console in Service+Version level > 4、In gov service, send the different command to CC according to the > type/version when doing > management -- This message was sent by Atlassian JIRA (v7.6.3#76005)