polish
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
package org.springframework.cloud.client.discovery.simple;
|
||||
|
||||
import org.springframework.cloud.client.ServiceInstance;
|
||||
import org.springframework.cloud.client.discovery.DiscoveryClient;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.cloud.client.ServiceInstance;
|
||||
import org.springframework.cloud.client.discovery.DiscoveryClient;
|
||||
import org.springframework.cloud.client.discovery.simple.SimpleDiscoveryProperties.SimpleServiceInstance;
|
||||
|
||||
/**
|
||||
* A {@link org.springframework.cloud.client.discovery.DiscoveryClient} that will use the
|
||||
* properties file as a source of service instances
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package org.springframework.cloud.client.discovery.simple;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.cloud.client.ServiceInstance;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -26,4 +28,58 @@ public class SimpleDiscoveryProperties {
|
||||
this.instances = instances;
|
||||
}
|
||||
|
||||
public static class SimpleServiceInstance implements ServiceInstance {
|
||||
|
||||
private URI resolvedUri;
|
||||
private String host;
|
||||
private int port;
|
||||
private boolean secure;
|
||||
|
||||
public SimpleServiceInstance() {
|
||||
}
|
||||
|
||||
public SimpleServiceInstance(String uri) {
|
||||
setUri(uri);
|
||||
}
|
||||
|
||||
public void setUri(String uri) {
|
||||
this.resolvedUri = URI.create(uri);
|
||||
this.host = this.resolvedUri.getHost();
|
||||
this.port = this.resolvedUri.getPort();
|
||||
String scheme = this.resolvedUri.getScheme();
|
||||
if ("https".equals(scheme)) {
|
||||
this.secure = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServiceId() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHost() {
|
||||
return this.host;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPort() {
|
||||
return this.port;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSecure() {
|
||||
return this.secure;
|
||||
}
|
||||
|
||||
@Override
|
||||
public URI getUri() {
|
||||
return this.resolvedUri;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getMetadata() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
package org.springframework.cloud.client.discovery.simple;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.cloud.client.ServiceInstance;
|
||||
|
||||
/**
|
||||
* Represents a Simple property based {@link ServiceInstance}
|
||||
*
|
||||
* @author Biju Kunjummen
|
||||
*/
|
||||
public class SimpleServiceInstance implements ServiceInstance {
|
||||
|
||||
private URI resolvedUri;
|
||||
private String host;
|
||||
private int port;
|
||||
private boolean secure;
|
||||
|
||||
public SimpleServiceInstance() {
|
||||
}
|
||||
|
||||
public SimpleServiceInstance(String uri) {
|
||||
setUri(uri);
|
||||
}
|
||||
|
||||
public void setUri(String uri) {
|
||||
this.resolvedUri = URI.create(uri);
|
||||
this.host = this.resolvedUri.getHost();
|
||||
this.port = this.resolvedUri.getPort();
|
||||
String scheme = this.resolvedUri.getScheme();
|
||||
if ("https".equals(scheme)) {
|
||||
this.secure = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServiceId() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHost() {
|
||||
return this.host;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPort() {
|
||||
return this.port;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSecure() {
|
||||
return this.secure;
|
||||
}
|
||||
|
||||
@Override
|
||||
public URI getUri() {
|
||||
return this.resolvedUri;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getMetadata() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,16 @@
|
||||
package org.springframework.cloud.client.discovery.simple;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.cloud.client.ServiceInstance;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.cloud.client.ServiceInstance;
|
||||
import org.springframework.cloud.client.discovery.simple.SimpleDiscoveryProperties.SimpleServiceInstance;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user