Skip to content

io microsphere spring cloud client service registry SimpleServiceRegistry

github-actions[bot] edited this page Jun 10, 2026 · 5 revisions

SimpleServiceRegistry

Type: Class | Module: microsphere-spring-cloud-commons | Package: io.microsphere.spring.cloud.client.service.registry | Since: 1.0.0

Source: microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/client/service/registry/SimpleServiceRegistry.java

Overview

Simple ServiceRegistry class that is based on SimpleDiscoveryProperties or SimpleReactiveDiscoveryProperties to register DefaultRegistration.

Declaration

public class SimpleServiceRegistry implements ServiceRegistry<DefaultRegistration>

Author: Mercy

Version Information

  • Introduced in: 1.0.0
  • Current Project Version: 0.2.18-SNAPSHOT

Version Compatibility

This component is tested and compatible with the following Java versions:

Java Version Status
Java 17 ✅ Compatible
Java 21 ✅ Compatible
Java 25 ✅ Compatible

Examples

Method Examples

register

SimpleDiscoveryProperties properties = new SimpleDiscoveryProperties();
SimpleServiceRegistry registry = new SimpleServiceRegistry(properties);
SimpleReactiveDiscoveryProperties reactiveProperties = ...;
SimpleServiceRegistry registry = new SimpleServiceRegistry(reactiveProperties);
Map<String, List<DefaultServiceInstance>> instancesMap = new HashMap<>();
SimpleServiceRegistry registry = new SimpleServiceRegistry(instancesMap);
SimpleServiceRegistry registry = new SimpleServiceRegistry(properties);
DefaultRegistration registration = new DefaultRegistration();
registration.setServiceId("test-service");
registry.register(registration);

deregister

SimpleServiceRegistry registry = new SimpleServiceRegistry(properties);
registry.register(registration);
registry.deregister(registration);

close

SimpleServiceRegistry registry = new SimpleServiceRegistry(properties);
registry.close();

setStatus

SimpleServiceRegistry registry = new SimpleServiceRegistry(properties);
registry.register(registration);
registry.setStatus(registration, "UP");

getStatus

SimpleServiceRegistry registry = new SimpleServiceRegistry(properties);
registry.register(registration);
registry.setStatus(registration, "UP");
String status = registry.getStatus(registration); // "UP"

Usage

Maven Dependency

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

import io.microsphere.spring.cloud.client.service.registry.SimpleServiceRegistry;

API Reference

Public Methods

Method Description
register Constructs a new SimpleServiceRegistry using the given
deregister Deregisters the given DefaultRegistration by removing it from the instances
close Closes this registry. This implementation is a no-op.
setStatus Sets the status of the given DefaultRegistration by storing it in the
getStatus Retrieves the status of the given DefaultRegistration from its metadata.

Method Details

register

public void register(DefaultRegistration registration)

Constructs a new SimpleServiceRegistry using the given SimpleDiscoveryProperties to obtain the instances map.

Example Usage:

`SimpleDiscoveryProperties properties = new SimpleDiscoveryProperties();
SimpleServiceRegistry registry = new SimpleServiceRegistry(properties);
`

deregister

public void deregister(DefaultRegistration registration)

Deregisters the given DefaultRegistration by removing it from the instances list for its service ID.

Example Usage:

`SimpleServiceRegistry registry = new SimpleServiceRegistry(properties);
registry.register(registration);
registry.deregister(registration);
`

close

public void close()

Closes this registry. This implementation is a no-op.

Example Usage:

`SimpleServiceRegistry registry = new SimpleServiceRegistry(properties);
registry.close();
`

setStatus

public void setStatus(DefaultRegistration registration, String status)

Sets the status of the given DefaultRegistration by storing it in the registration's metadata under the #STATUS_KEY key.

Example Usage:

`SimpleServiceRegistry registry = new SimpleServiceRegistry(properties);
registry.register(registration);
registry.setStatus(registration, "UP");
`

getStatus

public String getStatus(DefaultRegistration registration)

Retrieves the status of the given DefaultRegistration from its metadata.

Example Usage:

`SimpleServiceRegistry registry = new SimpleServiceRegistry(properties);
registry.register(registration);
registry.setStatus(registration, "UP");
String status = registry.getStatus(registration); // "UP"
`

See Also

  • ServiceRegistry
  • DefaultRegistration
  • SimpleDiscoveryProperties#getInstances()
  • SimpleReactiveDiscoveryProperties#getInstances()

This documentation was auto-generated from the source code of microsphere-spring-cloud.

Home

spring-cloud-commons

spring-cloud-openfeign

Clone this wiki locally