Class CircuitBreakerAdapterDecorator

java.lang.Object
org.springframework.web.service.invoker.HttpExchangeAdapterDecorator
org.springframework.cloud.client.circuitbreaker.httpservice.CircuitBreakerAdapterDecorator
All Implemented Interfaces:
org.springframework.web.service.invoker.HttpExchangeAdapter

public class CircuitBreakerAdapterDecorator extends org.springframework.web.service.invoker.HttpExchangeAdapterDecorator
Blocking implementation of HttpExchangeAdapterDecorator that wraps @HttpExchange

In the event of a CircuitBreaker fallback, this class uses the user-provided fallback class to create a proxy. The fallback method is selected by matching either:

  • A method with the same name and argument types as the original method, or
  • A method with the same name and the original arguments preceded by a Throwable, allowing the user to access the cause of failure within the fallback.
Once a matching method is found, it is invoked to provide the fallback behavior. Both the fallback class and the fallback methods must be public.

Since:
5.0.0
Author:
Olga Maciaszek-Sharma
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    CircuitBreakerAdapterDecorator(org.springframework.web.service.invoker.HttpExchangeAdapter delegate, CircuitBreaker circuitBreaker, Map<String,Class<?>> fallbackClasses)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    exchange(org.springframework.web.service.invoker.HttpRequestValues requestValues)
     
    org.springframework.http.ResponseEntity<Void>
    exchangeForBodilessEntity(org.springframework.web.service.invoker.HttpRequestValues values)
     
    <T> @Nullable T
    exchangeForBody(org.springframework.web.service.invoker.HttpRequestValues values, org.springframework.core.ParameterizedTypeReference<T> bodyType)
     
    <T> org.springframework.http.ResponseEntity<T>
    exchangeForEntity(org.springframework.web.service.invoker.HttpRequestValues values, org.springframework.core.ParameterizedTypeReference<T> bodyType)
     
    org.springframework.http.HttpHeaders
    exchangeForHeaders(org.springframework.web.service.invoker.HttpRequestValues values)
     

    Methods inherited from class org.springframework.web.service.invoker.HttpExchangeAdapterDecorator

    getHttpExchangeAdapter, supportsRequestAttributes

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CircuitBreakerAdapterDecorator

      public CircuitBreakerAdapterDecorator(org.springframework.web.service.invoker.HttpExchangeAdapter delegate, CircuitBreaker circuitBreaker, Map<String,Class<?>> fallbackClasses)
  • Method Details

    • exchange

      public void exchange(org.springframework.web.service.invoker.HttpRequestValues requestValues)
      Specified by:
      exchange in interface org.springframework.web.service.invoker.HttpExchangeAdapter
      Overrides:
      exchange in class org.springframework.web.service.invoker.HttpExchangeAdapterDecorator
    • exchangeForHeaders

      public org.springframework.http.HttpHeaders exchangeForHeaders(org.springframework.web.service.invoker.HttpRequestValues values)
      Specified by:
      exchangeForHeaders in interface org.springframework.web.service.invoker.HttpExchangeAdapter
      Overrides:
      exchangeForHeaders in class org.springframework.web.service.invoker.HttpExchangeAdapterDecorator
    • exchangeForBody

      public <T> @Nullable T exchangeForBody(org.springframework.web.service.invoker.HttpRequestValues values, org.springframework.core.ParameterizedTypeReference<T> bodyType)
      Specified by:
      exchangeForBody in interface org.springframework.web.service.invoker.HttpExchangeAdapter
      Overrides:
      exchangeForBody in class org.springframework.web.service.invoker.HttpExchangeAdapterDecorator
    • exchangeForBodilessEntity

      public org.springframework.http.ResponseEntity<Void> exchangeForBodilessEntity(org.springframework.web.service.invoker.HttpRequestValues values)
      Specified by:
      exchangeForBodilessEntity in interface org.springframework.web.service.invoker.HttpExchangeAdapter
      Overrides:
      exchangeForBodilessEntity in class org.springframework.web.service.invoker.HttpExchangeAdapterDecorator
    • exchangeForEntity

      public <T> org.springframework.http.ResponseEntity<T> exchangeForEntity(org.springframework.web.service.invoker.HttpRequestValues values, org.springframework.core.ParameterizedTypeReference<T> bodyType)
      Specified by:
      exchangeForEntity in interface org.springframework.web.service.invoker.HttpExchangeAdapter
      Overrides:
      exchangeForEntity in class org.springframework.web.service.invoker.HttpExchangeAdapterDecorator