diff --git a/demo/demo-local-registry/demo-local-registry-client/src/main/java/org/apache/servicecomb/demo/localRegistryClient/Application.java b/demo/demo-local-registry/demo-local-registry-client/src/main/java/org/apache/servicecomb/demo/localRegistryClient/Application.java index c6ed407b0b0..5c937b674a8 100644 --- a/demo/demo-local-registry/demo-local-registry-client/src/main/java/org/apache/servicecomb/demo/localRegistryClient/Application.java +++ b/demo/demo-local-registry/demo-local-registry-client/src/main/java/org/apache/servicecomb/demo/localRegistryClient/Application.java @@ -45,6 +45,9 @@ private static void registerSchema() { RegistrationManager.INSTANCE.getSwaggerLoader().registerSwagger("demo-local-registry", "demo-local-registry-server", "CodeFirstEndpoint", CodeFirstService.class); + RegistrationManager.INSTANCE.getSwaggerLoader().registerSwagger("demo-local-registry-cross", + "demo-local-registry-server-cross", + "CodeFirstEndpoint", CodeFirstService.class); RegistrationManager.INSTANCE.getSwaggerLoader().registerSwagger("demo-local-registry", "demo-local-registry-server-bean", "CodeFirstEndpoint", CodeFirstService.class); diff --git a/demo/demo-local-registry/demo-local-registry-client/src/main/java/org/apache/servicecomb/demo/localRegistryClient/LocalRegistryServerTest.java b/demo/demo-local-registry/demo-local-registry-client/src/main/java/org/apache/servicecomb/demo/localRegistryClient/LocalRegistryServerTest.java index c50508cc0b7..f914b53ad06 100644 --- a/demo/demo-local-registry/demo-local-registry-client/src/main/java/org/apache/servicecomb/demo/localRegistryClient/LocalRegistryServerTest.java +++ b/demo/demo-local-registry/demo-local-registry-client/src/main/java/org/apache/servicecomb/demo/localRegistryClient/LocalRegistryServerTest.java @@ -33,6 +33,10 @@ public class LocalRegistryServerTest implements CategorizedTestCase { @RpcReference(microserviceName = "demo-local-registry-server", schemaId = "CodeFirstEndpoint") private CodeFirstService codeFirstService; + @RpcReference(microserviceName = "demo-local-registry-cross:demo-local-registry-server-cross", + schemaId = "CodeFirstEndpoint") + private CodeFirstService codeFirstServiceCross; + @RpcReference(microserviceName = "demo-local-registry-server-bean", schemaId = "CodeFirstEndpoint") private CodeFirstService codeFirstServiceBean; @@ -62,6 +66,7 @@ private void testGetAllMicroservice() { private void testCodeFirstGetName() { TestMgr.check("2", codeFirstService.getName("2")); + TestMgr.check("2", codeFirstServiceCross.getName("2")); TestMgr.check("2", codeFirstServiceBean.getName("2")); TestMgr.check("2", codeFirstServiceBean2.getName("2")); } @@ -71,6 +76,10 @@ private void testServerGetName() { TestMgr.check("2", template .getForObject("cse://demo-local-registry-server/register/url/prefix/getName?name=2", String.class)); + TestMgr.check("2", template + .getForObject( + "cse://demo-local-registry-cross:demo-local-registry-server-cross/register/url/prefix/getName?name=2", + String.class)); TestMgr.check("2", template .getForObject("cse://demo-local-registry-server-bean/register/url/prefix/getName?name=2", String.class)); diff --git a/demo/demo-local-registry/demo-local-registry-client/src/main/resources/applications/demo-local-registry-cross/demo-local-registry-server-cross/ServerEndpoint.yaml b/demo/demo-local-registry/demo-local-registry-client/src/main/resources/applications/demo-local-registry-cross/demo-local-registry-server-cross/ServerEndpoint.yaml new file mode 100644 index 00000000000..78c9d1bca63 --- /dev/null +++ b/demo/demo-local-registry/demo-local-registry-client/src/main/resources/applications/demo-local-registry-cross/demo-local-registry-server-cross/ServerEndpoint.yaml @@ -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. +## --------------------------------------------------------------------------- + +swagger: "2.0" +info: + version: "1.0.0" + title: "swagger definition for org.apache.servicecomb.demo.registry.ServerEndpoint" + x-java-interface: "gen.swagger.ServerEndpointIntf" +basePath: "/register/url/prefix" +schemes: +- "http" +consumes: +- "application/json" +produces: +- "application/json" +paths: + /getName: + get: + operationId: "getName" + parameters: + - name: "name" + in: "query" + required: true + type: "string" + responses: + "200": + description: "response of 200" + schema: + type: "string" \ No newline at end of file diff --git a/demo/demo-local-registry/demo-local-registry-client/src/main/resources/registry.yaml b/demo/demo-local-registry/demo-local-registry-client/src/main/resources/registry.yaml index 2ad3c23269f..f0e611e56cb 100644 --- a/demo/demo-local-registry/demo-local-registry-client/src/main/resources/registry.yaml +++ b/demo/demo-local-registry/demo-local-registry-client/src/main/resources/registry.yaml @@ -16,9 +16,19 @@ ## --------------------------------------------------------------------------- demo-local-registry-server: - - id: "001" + - id: "service-001" version: "1.0" appid: demo-local-registry + schemaIds: + - ServerEndpoint + - CodeFirstEndpoint + instances: + - endpoints: + - rest://localhost:8080 +demo-local-registry-server-cross: + - id: "service-002" + version: "1.0" + appid: demo-local-registry-cross schemaIds: - ServerEndpoint - CodeFirstEndpoint diff --git a/foundations/foundation-registry/src/main/java/org/apache/servicecomb/registry/consumer/MicroserviceVersions.java b/foundations/foundation-registry/src/main/java/org/apache/servicecomb/registry/consumer/MicroserviceVersions.java index 16744f7bc41..99bc202190f 100644 --- a/foundations/foundation-registry/src/main/java/org/apache/servicecomb/registry/consumer/MicroserviceVersions.java +++ b/foundations/foundation-registry/src/main/java/org/apache/servicecomb/registry/consumer/MicroserviceVersions.java @@ -188,7 +188,7 @@ public void pullInstances() { protected MicroserviceInstances findServiceInstances() { return DiscoveryManager.INSTANCE.findServiceInstances(appId, - microserviceName, + shortName, DefinitionConst.VERSION_RULE_ALL, revision); }