-
Notifications
You must be signed in to change notification settings - Fork 31
io microsphere spring cloud client service registry RegistrationMetaData
Type: Class | Module: microsphere-spring-cloud-commons | Package: io.microsphere.spring.cloud.client.service.registry | Since: 1.0.0
A Map-based metadata container for Registration instances that synchronizes
metadata changes across all underlying registrations. This class wraps one or more
Registration objects and ensures that any metadata modifications (put, remove, clear)
are propagated to every registration in a thread-safe manner.
Example Usage:
`RegistrationMetaData metaData = new RegistrationMetaData(ofList(defaultRegistration));
metaData.put("key", "value");
String value = metaData.get("key");
metaData.remove("key");
`
public final class RegistrationMetaData implements Map<String, String>Author: 韩超
-
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 |
RegistrationMetaData metaData = new RegistrationMetaData(ofList(defaultRegistration));
metaData.put("key", "value");
String value = metaData.get("key");
metaData.remove("key");DefaultRegistration registration = new DefaultRegistration();
registration.getMetadata().put("key1", "value1");
RegistrationMetaData metaData = new RegistrationMetaData(List.of(registration));RegistrationMetaData metaData = new RegistrationMetaData(registrations);
int count = metaData.size(); // e.g. 3RegistrationMetaData metaData = new RegistrationMetaData(registrations);
boolean empty = metaData.isEmpty(); // false if registrations have metadataRegistrationMetaData metaData = new RegistrationMetaData(registrations);
boolean hasKey = metaData.containsKey("key1"); // true
boolean missing = metaData.containsKey("unknown"); // falseRegistrationMetaData metaData = new RegistrationMetaData(registrations);
boolean hasValue = metaData.containsValue("value1"); // true
boolean missing = metaData.containsValue("unknown"); // falseRegistrationMetaData metaData = new RegistrationMetaData(registrations);
String value = metaData.get("key1"); // "value1"
String missing = metaData.get("unknown"); // nullRegistrationMetaData metaData = new RegistrationMetaData(registrations);
metaData.put("key4", "value4");
String value = metaData.get("key4"); // "value4"RegistrationMetaData metaData = new RegistrationMetaData(registrations);
metaData.remove("key1");
String value = metaData.get("key1"); // nullRegistrationMetaData metaData = new RegistrationMetaData(registrations);
metaData.putAll(Map.of("key4", "value4", "key5", "value5"));RegistrationMetaData metaData = new RegistrationMetaData(registrations);
metaData.clear();
int size = metaData.size(); // 0RegistrationMetaData metaData = new RegistrationMetaData(registrations);
Set<String> keys = metaData.keySet();
boolean hasKey = keys.contains("key1"); // trueRegistrationMetaData metaData = new RegistrationMetaData(registrations);
Collection<String> values = metaData.values();
boolean hasValue = values.contains("value1"); // trueAdd 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.registry.RegistrationMetaData;| Method | Description |
|---|---|
size |
The class name of org.springframework.cloud.zookeeper.serviceregistry.ServiceInstanceRegistration
|
isEmpty |
Returns whether this metadata map is empty. |
containsKey |
Returns whether this metadata contains the specified key. |
containsValue |
Returns whether this metadata contains the specified value. |
get |
Returns the metadata value associated with the specified key. |
put |
Puts a metadata entry and synchronizes it across all underlying Registration
|
remove |
Removes the metadata entry for the specified key and synchronizes the removal |
putAll |
Copies all entries from the specified map into this metadata and synchronizes |
clear |
Clears all metadata entries and synchronizes the clearing across all underlying |
keySet |
Returns an unmodifiable Set view of the metadata keys. |
values |
Returns an unmodifiable Collection view of the metadata values. |
public int size()The class name of org.springframework.cloud.zookeeper.serviceregistry.ServiceInstanceRegistration
/
static final String ZOOKEEPER_REGISTRATION_CLASS_NAME = "org.springframework.cloud.zookeeper.serviceregistry.ServiceInstanceRegistration";
/**
The method name of org.springframework.cloud.zookeeper.serviceregistry.ServiceInstanceRegistration#getServiceInstance()
/
static final String GET_SERVICE_INSTANCE_METHOD_NAME = "getServiceInstance";
/** MetaData information manually added by the application,usually specified by configuration / private final Map applicationMetaData;
private final Collection registrations;
private final Object lock = new Object();
/**
Constructs a new RegistrationMetaData that aggregates metadata from the given
collection of Registration instances. Metadata changes are synchronized across
all registrations.
Example Usage:
`DefaultRegistration registration = new DefaultRegistration();
registration.getMetadata().put("key1", "value1");
RegistrationMetaData metaData = new RegistrationMetaData(List.of(registration));
`
public boolean isEmpty()Returns whether this metadata map is empty.
Example Usage:
`RegistrationMetaData metaData = new RegistrationMetaData(registrations); boolean empty = metaData.isEmpty(); // false if registrations have metadata `
public boolean containsKey(Object key)Returns whether this metadata contains the specified key.
Example Usage:
`RegistrationMetaData metaData = new RegistrationMetaData(registrations);
boolean hasKey = metaData.containsKey("key1"); // true
boolean missing = metaData.containsKey("unknown"); // false
`
public boolean containsValue(Object value)Returns whether this metadata contains the specified value.
Example Usage:
`RegistrationMetaData metaData = new RegistrationMetaData(registrations);
boolean hasValue = metaData.containsValue("value1"); // true
boolean missing = metaData.containsValue("unknown"); // false
`
public String get(Object key)Returns the metadata value associated with the specified key.
Example Usage:
`RegistrationMetaData metaData = new RegistrationMetaData(registrations);
String value = metaData.get("key1"); // "value1"
String missing = metaData.get("unknown"); // null
`
public String put(String key, String value)Puts a metadata entry and synchronizes it across all underlying Registration
instances.
Example Usage:
`RegistrationMetaData metaData = new RegistrationMetaData(registrations);
metaData.put("key4", "value4");
String value = metaData.get("key4"); // "value4"
`
public String remove(Object key)Removes the metadata entry for the specified key and synchronizes the removal
across all underlying Registration instances.
Example Usage:
`RegistrationMetaData metaData = new RegistrationMetaData(registrations);
metaData.remove("key1");
String value = metaData.get("key1"); // null
`
public void putAll(Map<? extends String, ? extends String> m)Copies all entries from the specified map into this metadata and synchronizes
them across all underlying Registration instances.
Example Usage:
`RegistrationMetaData metaData = new RegistrationMetaData(registrations);
metaData.putAll(Map.of("key4", "value4", "key5", "value5"));
`
public void clear()Clears all metadata entries and synchronizes the clearing across all underlying
Registration instances.
Example Usage:
`RegistrationMetaData metaData = new RegistrationMetaData(registrations); metaData.clear(); int size = metaData.size(); // 0 `
public Set<String> keySet()Returns an unmodifiable Set view of the metadata keys.
Example Usage:
`RegistrationMetaData metaData = new RegistrationMetaData(registrations);
Set keys = metaData.keySet();
boolean hasKey = keys.contains("key1"); // true
`
public Collection<String> values()Returns an unmodifiable Collection view of the metadata values.
Example Usage:
`RegistrationMetaData metaData = new RegistrationMetaData(registrations);
Collection values = metaData.values();
boolean hasValue = values.contains("value1"); // true
`
Registration
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