From b9c2b88bbb31cff3b8500df90913b823ce03f32b Mon Sep 17 00:00:00 2001 From: Spencer Gibb Date: Wed, 1 Feb 2017 13:22:59 -0700 Subject: [PATCH] Implements getServiceId --- .../zookeeper/discovery/ZookeeperServiceDiscovery.java | 5 +++++ .../serviceregistry/ServiceInstanceRegistration.java | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/discovery/ZookeeperServiceDiscovery.java b/spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/discovery/ZookeeperServiceDiscovery.java index a7233196..339b22c0 100644 --- a/spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/discovery/ZookeeperServiceDiscovery.java +++ b/spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/discovery/ZookeeperServiceDiscovery.java @@ -102,6 +102,11 @@ public class ZookeeperServiceDiscovery implements ZookeeperRegistration, Applica this.appName = resolver.getProperty("spring.application.name", "application"); } + @Override + public String getServiceId() { + return this.appName; + } + /** * Builds Service Instance - needs to be used when you want to register your application * in Zookeeper diff --git a/spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/serviceregistry/ServiceInstanceRegistration.java b/spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/serviceregistry/ServiceInstanceRegistration.java index 901f6786..36a8485f 100644 --- a/spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/serviceregistry/ServiceInstanceRegistration.java +++ b/spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/serviceregistry/ServiceInstanceRegistration.java @@ -130,6 +130,14 @@ public class ServiceInstanceRegistration implements ZookeeperRegistration { this.serviceInstance = this.builder.build(); } + @Override + public String getServiceId() { + if (this.serviceInstance == null) { + return null; + } + return this.serviceInstance.getName(); + } + public int getPort() { if (this.serviceInstance == null) { return 0;