Package org.springframework.cloud.client
Class DefaultServiceInstance
- java.lang.Object
-
- org.springframework.cloud.client.DefaultServiceInstance
-
- All Implemented Interfaces:
ServiceInstance
public class DefaultServiceInstance extends Object implements ServiceInstance
Default implementation ofServiceInstance
.- Author:
- Spencer Gibb, Tim Ysewyn, Charu Covindane, Neil Powell
-
-
Constructor Summary
Constructors Constructor Description DefaultServiceInstance()
DefaultServiceInstance(String instanceId, String serviceId, String host, int port, boolean secure)
DefaultServiceInstance(String instanceId, String serviceId, String host, int port, boolean secure, Map<String,String> metadata)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
String
getHost()
String
getInstanceId()
Map<String,String>
getMetadata()
int
getPort()
String
getServiceId()
URI
getUri()
static URI
getUri(ServiceInstance instance)
Creates a URI from the given ServiceInstance's host:port.int
hashCode()
boolean
isSecure()
void
setHost(String host)
void
setInstanceId(String instanceId)
void
setPort(int port)
void
setServiceId(String serviceId)
void
setUri(URI uri)
String
toString()
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.springframework.cloud.client.ServiceInstance
getScheme
-
-
-
-
Constructor Detail
-
DefaultServiceInstance
public DefaultServiceInstance(String instanceId, String serviceId, String host, int port, boolean secure, Map<String,String> metadata)
- Parameters:
instanceId
- the id of the instance.serviceId
- the id of the service.host
- the host where the service instance can be found.port
- the port on which the service is running.secure
- indicates whether or not the connection needs to be secure.metadata
- a map containing metadata.
-
DefaultServiceInstance
public DefaultServiceInstance(String instanceId, String serviceId, String host, int port, boolean secure)
- Parameters:
instanceId
- the id of the instance.serviceId
- the id of the service.host
- the host where the service instance can be found.port
- the port on which the service is running.secure
- indicates whether or not the connection needs to be secure.
-
DefaultServiceInstance
public DefaultServiceInstance()
-
-
Method Detail
-
getUri
public static URI getUri(ServiceInstance instance)
Creates a URI from the given ServiceInstance's host:port.- Parameters:
instance
- the ServiceInstance.- Returns:
- URI of the form (secure)?https:http + "host:port". Scheme port default used if port not set.
-
getUri
public URI getUri()
- Specified by:
getUri
in interfaceServiceInstance
- Returns:
- The service URI address.
-
getMetadata
public Map<String,String> getMetadata()
- Specified by:
getMetadata
in interfaceServiceInstance
- Returns:
- The key / value pair metadata associated with the service instance.
-
getInstanceId
public String getInstanceId()
- Specified by:
getInstanceId
in interfaceServiceInstance
- Returns:
- The unique instance ID as registered.
-
getServiceId
public String getServiceId()
- Specified by:
getServiceId
in interfaceServiceInstance
- Returns:
- The service ID as registered.
-
getHost
public String getHost()
- Specified by:
getHost
in interfaceServiceInstance
- Returns:
- The hostname of the registered service instance.
-
getPort
public int getPort()
- Specified by:
getPort
in interfaceServiceInstance
- Returns:
- The port of the registered service instance.
-
isSecure
public boolean isSecure()
- Specified by:
isSecure
in interfaceServiceInstance
- Returns:
- Whether the port of the registered service instance uses HTTPS.
-
setInstanceId
public void setInstanceId(String instanceId)
-
setServiceId
public void setServiceId(String serviceId)
-
setHost
public void setHost(String host)
-
setPort
public void setPort(int port)
-
setUri
public void setUri(URI uri)
-
-