Class ServiceInstanceUtils


  • public class ServiceInstanceUtils
    extends io.microsphere.util.BaseUtils
    ServiceInstance Utilities class
    Since:
    1.0.0
    Author:
    Mercy
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void attachMetadata​(java.lang.String contextPath, org.springframework.cloud.client.ServiceInstance serviceInstance, java.util.Collection<io.microsphere.spring.web.metadata.WebEndpointMapping> webEndpointMappings)  
      static java.lang.String getMetadata​(org.springframework.cloud.client.ServiceInstance serviceInstance, java.lang.String metadataName)
      Get metadata by metadataName
      static java.net.URI getUri​(org.springframework.cloud.client.ServiceInstance serviceInstance)
      Alternative method of ServiceInstance.getUri() with the better performance
      static java.lang.String getUriString​(org.springframework.cloud.client.ServiceInstance instance)
      Get the String representation of ServiceInstance.getUri()
      static java.util.Collection<io.microsphere.spring.web.metadata.WebEndpointMapping> getWebEndpointMappings​(org.springframework.cloud.client.ServiceInstance serviceInstance)
      Get WebEndpointMappings from ServiceInstance
      static java.lang.String removeMetadata​(org.springframework.cloud.client.ServiceInstance serviceInstance, java.lang.String metadataName)
      Remove metadata by metadataName
      static java.lang.String setMetadata​(org.springframework.cloud.client.ServiceInstance serviceInstance, java.lang.String metadataName, java.lang.String metadataValue)
      Set metadata by metadataName
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • attachMetadata

        public static void attachMetadata​(java.lang.String contextPath,
                                          org.springframework.cloud.client.ServiceInstance serviceInstance,
                                          java.util.Collection<io.microsphere.spring.web.metadata.WebEndpointMapping> webEndpointMappings)
      • getWebEndpointMappings

        @Nonnull
        public static java.util.Collection<io.microsphere.spring.web.metadata.WebEndpointMapping> getWebEndpointMappings​(org.springframework.cloud.client.ServiceInstance serviceInstance)
        Get WebEndpointMappings from ServiceInstance
        Parameters:
        serviceInstance - ServiceInstance
        Returns:
        WebEndpointMappings
      • getUriString

        @Nonnull
        public static java.lang.String getUriString​(org.springframework.cloud.client.ServiceInstance instance)
        Get the String representation of ServiceInstance.getUri()
        Parameters:
        instance - ServiceInstance
        Returns:
        the String representation of ServiceInstance.getUri()
      • getUri

        @Nonnull
        public static java.net.URI getUri​(org.springframework.cloud.client.ServiceInstance serviceInstance)
        Alternative method of ServiceInstance.getUri() with the better performance
        Parameters:
        serviceInstance - ServiceInstance
        Returns:
        URI instance
        See Also:
        DefaultServiceInstance.getUri(ServiceInstance)
      • getMetadata

        @Nullable
        public static java.lang.String getMetadata​(org.springframework.cloud.client.ServiceInstance serviceInstance,
                                                   java.lang.String metadataName)
        Get metadata by metadataName
        Parameters:
        serviceInstance - ServiceInstance
        metadataName - metadataName
        Returns:
        metadata value
      • setMetadata

        public static java.lang.String setMetadata​(org.springframework.cloud.client.ServiceInstance serviceInstance,
                                                   java.lang.String metadataName,
                                                   java.lang.String metadataValue)
        Set metadata by metadataName
        Parameters:
        serviceInstance - ServiceInstance
        metadataName - metadataName
        metadataValue - metadata value
        Returns:
        the previous value associated with metadataName if found, null otherwise
      • removeMetadata

        public static java.lang.String removeMetadata​(org.springframework.cloud.client.ServiceInstance serviceInstance,
                                                      java.lang.String metadataName)
        Remove metadata by metadataName
        Parameters:
        serviceInstance - ServiceInstance
        metadataName - metadataName
        Returns:
        the value associated with metadataName if found, null otherwise