Registration now extends ServiceInstance
This allows for a true replacement of DiscoveryClient.getLocalServiceInstance(). fixes gh-265
This commit is contained in:
@@ -26,7 +26,7 @@ import java.util.Map;
|
||||
public interface ServiceInstance {
|
||||
|
||||
/**
|
||||
* @return the service id as register by the DiscoveryClient
|
||||
* @return the service id as registered.
|
||||
*/
|
||||
String getServiceId();
|
||||
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
package org.springframework.cloud.client.serviceregistry;
|
||||
|
||||
import org.springframework.cloud.client.ServiceInstance;
|
||||
|
||||
/**
|
||||
* A marker interface used by a {@link ServiceRegistry}.
|
||||
*
|
||||
* @author Spencer Gibb
|
||||
* @since 1.2.0
|
||||
*/
|
||||
public interface Registration {
|
||||
|
||||
/**
|
||||
* @return the serviceId associated with this registration
|
||||
*/
|
||||
String getServiceId();
|
||||
public interface Registration extends ServiceInstance {
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.springframework.cloud.client.serviceregistry;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.junit.Test;
|
||||
@@ -64,6 +66,31 @@ public class AbstractAutoServiceRegistrationTests {
|
||||
public String getServiceId() {
|
||||
return "testRegistration2";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHost() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPort() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSecure() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public URI getUri() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getMetadata() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static class TestMgmtRegistration extends TestRegistration {
|
||||
|
||||
@@ -20,6 +20,8 @@ import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
@@ -76,6 +78,31 @@ public class ServiceRegistryEndpointTests {
|
||||
public String getServiceId() {
|
||||
return "testRegistration1";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHost() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPort() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSecure() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public URI getUri() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getMetadata() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user