Module bus.limiter

Class FallbackProvider

java.lang.Object
org.miaixz.bus.limiter.metric.FallbackProvider
All Implemented Interfaces:
Serializable, org.miaixz.bus.core.Provider, Provider

public class FallbackProvider extends Object implements Provider
Implements the Provider interface for handling the FALLBACK strategy mode. This provider is responsible for invoking a fallback method when the primary method execution is blocked or fails due to limiting rules.
Since:
Java 17+
Author:
Kimi Liu
See Also:
  • Constructor Details

    • FallbackProvider

      public FallbackProvider()
  • Method Details

    • get

      public StrategyMode get()
      Returns the strategy mode supported by this provider, which is StrategyMode.FALLBACK.
      Specified by:
      get in interface Provider
      Returns:
      The StrategyMode.FALLBACK enum value.
    • process

      public Object process(Object bean, Method method, Object[] args)
      Processes the method invocation by attempting to find and invoke a fallback method. The fallback method is expected to have the same parameters as the original method and its name should be the original method name appended with "Fallback".
      Specified by:
      process in interface Provider
      Parameters:
      bean - The target object on which the original method was invoked.
      method - The original Method that was attempted to be executed.
      args - The arguments passed to the original method invocation.
      Returns:
      The result of the fallback method invocation.
      Throws:
      RuntimeException - if a suitable fallback method cannot be found for the given bean and method.