-
Notifications
You must be signed in to change notification settings - Fork 31
io microsphere spring cloud client service util ServiceInstanceUtils
Type: Class | Module: microsphere-spring-cloud-commons | Package: io.microsphere.spring.cloud.client.service.util | Since: 1.0.0
ServiceInstance Utilities class
public class ServiceInstanceUtils extends BaseUtilsAuthor: Mercy
-
Introduced in:
1.0.0 -
Current Project Version:
0.2.9-SNAPSHOT
This component is tested and compatible with the following Java versions:
| Java Version | Status |
|---|---|
| Java 17 | ✅ Compatible |
| Java 21 | ✅ Compatible |
| Java 25 | ✅ Compatible |
ServiceInstance serviceInstance = new DefaultServiceInstance("id", "service", "localhost", 8080, false);
Collection<WebEndpointMapping> mappings = new ArrayList<>();
ServiceInstanceUtils.attachMetadata("/context", serviceInstance, mappings);Add the following dependency to your pom.xml:
<dependency>
<groupId>io.github.microsphere-projects</groupId>
<artifactId>microsphere-spring-cloud-commons</artifactId>
<version>${microsphere-spring-cloud.version}</version>
</dependency>Tip: Use the BOM (
microsphere-spring-cloud-dependencies) for consistent version management. See the Getting Started guide.
import io.microsphere.spring.cloud.client.service.util.ServiceInstanceUtils;| Method | Description |
|---|---|
attachMetadata |
Attach WebEndpointMapping metadata to the given ServiceInstance. |
getWebEndpointMappings |
Get WebEndpointMappings from ServiceInstance
|
getUriString |
Get the String representation of ServiceInstance#getUri()
|
getUri |
Alternative method of ServiceInstance#getUri() with the better performance |
getMetadata |
Get metadata by metadataName |
setMetadata |
Set metadata by metadataName |
removeMetadata |
Remove metadata by metadataName |
setProperties |
Set properties from source to target |
public static void attachMetadata(String contextPath, ServiceInstance serviceInstance, Collection<WebEndpointMapping> webEndpointMappings)Attach WebEndpointMapping metadata to the given ServiceInstance.
The web endpoint mappings are serialized as JSON and stored in the service instance's
metadata under the io.microsphere.spring.cloud.client.service.registry.constants.InstanceConstants#WEB_MAPPINGS_METADATA_NAME key.
Example Usage:
`ServiceInstance serviceInstance = new DefaultServiceInstance("id", "service", "localhost", 8080, false);
Collection mappings = new ArrayList<>();
ServiceInstanceUtils.attachMetadata("/context", serviceInstance, mappings);
`
public static Collection<WebEndpointMapping> getWebEndpointMappings(ServiceInstance serviceInstance)Get WebEndpointMappings from ServiceInstance
public static String getUriString(ServiceInstance instance)Get the String representation of ServiceInstance#getUri()
public static URI getUri(ServiceInstance serviceInstance)Alternative method of ServiceInstance#getUri() with the better performance
This documentation was auto-generated from the source code of microsphere-spring-cloud.
spring-cloud-commons
- AbstractServiceRegistrationEndpoint
- CommonsPropertyConstants
- ConditionalOnAutoServiceRegistrationEnabled
- ConditionalOnFeaturesEnabled
- ConditionalOnLoadBalancerEnabled
- ConditionalOnMultipleRegistrationEnabled
- ConditionalOnUtilEnabled
- DefaultRegistration
- DiscoveryClientAutoConfiguration
- DiscoveryClientConstants
- DiscoveryUtils
- EventPublishingRegistrationAspect
- FaultTolerancePropertyConstants
- InMemoryServiceRegistry
- InstanceConstants
- LoadBalancerUtils
- MultipleAutoServiceRegistration
- MultipleRegistration
- MultipleServiceRegistry
- ReactiveDiscoveryClientAdapter
- ReactiveDiscoveryClientAutoConfiguration
- RegistrationCustomizer
- RegistrationDeregisteredEvent
- RegistrationEvent
- RegistrationMetaData
- RegistrationPreDeregisteredEvent
- RegistrationPreRegisteredEvent
- RegistrationRegisteredEvent
- ServiceDeregistrationEndpoint
- ServiceInstanceUtils
- ServiceInstancesChangedEvent
- ServiceRegistrationEndpoint
- ServiceRegistrationEndpointAutoConfiguration
- ServiceRegistryAutoConfiguration
- SimpleAutoServiceRegistration
- SimpleAutoServiceRegistrationAutoConfiguration
- SimpleServiceRegistry
- SpecificationAutoConfiguration
- SpecificationBeanPostProcessor
- SpecificationCustomizer
- SpringCloudPropertyConstants
- TomcatDynamicConfigurationListener
- TomcatFaultToleranceAutoConfiguration
- UnionDiscoveryClient
- WebFluxServiceRegistryAutoConfiguration
- WebMvcServiceRegistryAutoConfiguration
- WebServiceRegistryAutoConfiguration
- WeightedRoundRobin
spring-cloud-openfeign
- AutoRefreshCapability
- AutoRefreshCapabilityCustomizer
- CompositedRequestInterceptor
- DecoratedContract
- DecoratedDecoder
- DecoratedEncoder
- DecoratedErrorDecoder
- DecoratedFeignComponent
- DecoratedQueryMapEncoder
- DecoratedRetryer
- EnableFeignAutoRefresh
- FeignAutoConfiguration
- FeignClientAutoRefreshAutoConfiguration
- FeignClientConfigurationChangedListener
- FeignComponentRegistry
- NoOpRequestInterceptor
- Refreshable