Class ServiceInstanceUtils
java.lang.Object
io.microsphere.util.BaseUtils
io.microsphere.spring.cloud.client.service.util.ServiceInstanceUtils
public class ServiceInstanceUtils
extends io.microsphere.util.BaseUtils
ServiceInstance Utilities class- Since:
- 1.0.0
- Author:
- Mercy
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidattachMetadata(String contextPath, org.springframework.cloud.client.ServiceInstance serviceInstance, Collection<io.microsphere.spring.web.metadata.WebEndpointMapping> webEndpointMappings) static StringgetMetadata(org.springframework.cloud.client.ServiceInstance serviceInstance, String metadataName) Get metadata by metadataNamestatic URIgetUri(org.springframework.cloud.client.ServiceInstance serviceInstance) Alternative method ofServiceInstance.getUri()with the better performancestatic StringgetUriString(org.springframework.cloud.client.ServiceInstance instance) Get the String representation ofServiceInstance.getUri()static Collection<io.microsphere.spring.web.metadata.WebEndpointMapping>getWebEndpointMappings(org.springframework.cloud.client.ServiceInstance serviceInstance) GetWebEndpointMappings fromServiceInstancestatic StringremoveMetadata(org.springframework.cloud.client.ServiceInstance serviceInstance, String metadataName) Remove metadata by metadataNamestatic StringsetMetadata(org.springframework.cloud.client.ServiceInstance serviceInstance, String metadataName, String metadataValue) Set metadata by metadataNamestatic voidsetProperties(org.springframework.cloud.client.ServiceInstance source, org.springframework.cloud.client.DefaultServiceInstance target) Set properties from source to target
-
Method Details
-
attachMetadata
public static void attachMetadata(String contextPath, org.springframework.cloud.client.ServiceInstance serviceInstance, Collection<io.microsphere.spring.web.metadata.WebEndpointMapping> webEndpointMappings) -
getWebEndpointMappings
@Nonnull public static Collection<io.microsphere.spring.web.metadata.WebEndpointMapping> getWebEndpointMappings(org.springframework.cloud.client.ServiceInstance serviceInstance) GetWebEndpointMappings fromServiceInstance- Parameters:
serviceInstance-ServiceInstance- Returns:
WebEndpointMappings
-
getUriString
@Nonnull public static String getUriString(org.springframework.cloud.client.ServiceInstance instance) Get the String representation ofServiceInstance.getUri()- Parameters:
instance-ServiceInstance- Returns:
- the String representation of
ServiceInstance.getUri()
-
getUri
Alternative method ofServiceInstance.getUri()with the better performance- Parameters:
serviceInstance-ServiceInstance- Returns:
URIinstance- See Also:
-
DefaultServiceInstance.getUri(ServiceInstance)
-
getMetadata
@Nullable public static String getMetadata(org.springframework.cloud.client.ServiceInstance serviceInstance, String metadataName) Get metadata by metadataName- Parameters:
serviceInstance-ServiceInstancemetadataName- metadataName- Returns:
- metadata value
-
setMetadata
public static String setMetadata(org.springframework.cloud.client.ServiceInstance serviceInstance, String metadataName, String metadataValue) Set metadata by metadataName- Parameters:
serviceInstance-ServiceInstancemetadataName- metadataNamemetadataValue- metadata value- Returns:
- the previous value associated with
metadataNameif found,nullotherwise
-
removeMetadata
public static String removeMetadata(org.springframework.cloud.client.ServiceInstance serviceInstance, String metadataName) Remove metadata by metadataName- Parameters:
serviceInstance-ServiceInstancemetadataName- metadataName- Returns:
- the value associated with
metadataNameif found,nullotherwise
-
setProperties
public static void setProperties(org.springframework.cloud.client.ServiceInstance source, org.springframework.cloud.client.DefaultServiceInstance target) Set properties from source to target- Parameters:
source- sourceServiceInstancetarget- targetDefaultServiceInstance
-