Skip to content

io microsphere spring cloud openfeign autorefresh FeignComponentRegistry

github-actions[bot] edited this page Jun 21, 2026 · 6 revisions

FeignComponentRegistry

Type: Class | Module: microsphere-spring-cloud-openfeign | Package: io.microsphere.spring.cloud.openfeign.autorefresh | Since: 0.0.1

Source: microsphere-spring-cloud-openfeign/src/main/java/io/microsphere/spring/cloud/openfeign/autorefresh/FeignComponentRegistry.java

Overview

Feign Component Registry

Declaration

public class FeignComponentRegistry

Author: 韩超

Version Information

  • Introduced in: 0.0.1
  • Current Project Version: 0.2.20-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

Class<?> componentClass = FeignComponentRegistry.getComponentClass("retryer");
// returns Retryer.class
String normalized = FeignComponentRegistry.normalizeConfig("requestInterceptors[0]");
// returns "request-interceptors"
FeignComponentRegistry registry = new FeignComponentRegistry("default", beanFactory);
List<Refreshable> components = List.of(decoratedContract, decoratedDecoder);
registry.register("my-client", components);

register

registry.register("my-client", decoratedContract);

registerRequestInterceptor

RequestInterceptor interceptor = template -> template.header("X-Custom", "value");
RequestInterceptor result = registry.registerRequestInterceptor("my-client", interceptor);

refresh

registry.refresh("my-client", "retryer", "decoder");

refresh

Set<String> changed = Set.of("my-client.retryer", "my-client.decoder");
registry.refresh("my-client", changed);

Usage

Maven Dependency

Add the following dependency to your pom.xml:

<dependency>
    <groupId>io.github.microsphere-projects</groupId>
    <artifactId>microsphere-spring-cloud-openfeign</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.openfeign.autorefresh.FeignComponentRegistry;

API Reference

Public Methods

Method Description
register Returns the Feign component class corresponding to the given configuration key.
register Registers a single Refreshable component for the specified Feign client.
registerRequestInterceptor Registers a RequestInterceptor for the specified Feign client. Interceptors
refresh Refreshes the Feign components for the specified client whose configurations have changed.
refresh Refreshes the Feign components for the specified client based on a set of changed

Method Details

register

public void register(String clientName, List<Refreshable> components)

Returns the Feign component class corresponding to the given configuration key.

Example Usage:

`Class componentClass = FeignComponentRegistry.getComponentClass("retryer");
// returns Retryer.class
`

register

public void register(String clientName, Refreshable component)

Registers a single Refreshable component for the specified Feign client.

Example Usage:

`registry.register("my-client", decoratedContract);
`

registerRequestInterceptor

public RequestInterceptor registerRequestInterceptor(String clientName, RequestInterceptor requestInterceptor)

Registers a RequestInterceptor for the specified Feign client. Interceptors are collected into a CompositedRequestInterceptor per client.

Example Usage:

`RequestInterceptor interceptor = template -> template.header("X-Custom", "value");
RequestInterceptor result = registry.registerRequestInterceptor("my-client", interceptor);
`

refresh

public void refresh(String clientName, String... changedConfigs)

Refreshes the Feign components for the specified client whose configurations have changed.

Example Usage:

`registry.refresh("my-client", "retryer", "decoder");
`

refresh

public synchronized void refresh(String clientName, Set<String> changedConfigs)

Refreshes the Feign components for the specified client based on a set of changed configuration keys. If the default client configuration changed, all registered components are refreshed.

Example Usage:

`Set changed = Set.of("my-client.retryer", "my-client.decoder");
registry.refresh("my-client", changed);
`

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

Home

spring-cloud-commons

spring-cloud-openfeign

Clone this wiki locally