Class DefaultServiceInstance
java.lang.Object
org.springframework.cloud.client.DefaultServiceInstance
- All Implemented Interfaces:
ServiceInstance
Default implementation of
ServiceInstance.- Author:
- Spencer Gibb, Tim Ysewyn, Charu Covindane, Neil Powell
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleangetHost()intgetPort()getUri()static URIgetUri(ServiceInstance instance) Creates a URI from the given ServiceInstance's host:port.inthashCode()booleanisSecure()voidvoidsetInstanceId(String instanceId) voidsetPort(int port) voidsetSecure(boolean secure) voidsetServiceId(String serviceId) voidtoString()Methods inherited from interface ServiceInstance
getScheme
-
Constructor Details
-
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 Details
-
getUri
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
- Specified by:
getUriin interfaceServiceInstance- Returns:
- The service URI address.
-
getMetadata
- Specified by:
getMetadatain interfaceServiceInstance- Returns:
- The key / value pair metadata associated with the service instance.
-
getInstanceId
- Specified by:
getInstanceIdin interfaceServiceInstance- Returns:
- The unique instance ID as registered.
-
getServiceId
- Specified by:
getServiceIdin interfaceServiceInstance- Returns:
- The service ID as registered.
-
getHost
- Specified by:
getHostin interfaceServiceInstance- Returns:
- The hostname of the registered service instance.
-
getPort
public int getPort()- Specified by:
getPortin interfaceServiceInstance- Returns:
- The port of the registered service instance.
-
isSecure
public boolean isSecure()- Specified by:
isSecurein interfaceServiceInstance- Returns:
- Whether the port of the registered service instance uses HTTPS.
-
setInstanceId
-
setServiceId
-
setHost
-
setPort
public void setPort(int port) -
setSecure
public void setSecure(boolean secure) -
setUri
-
toString
-
equals
-
hashCode
-