Module bus.limiter

Class Supplier

java.lang.Object
org.miaixz.bus.limiter.Supplier

public abstract class Supplier extends Object
Abstract base class for a supplier that provides a unique identifier for a user or request. This supplier is used in limiting scenarios to identify the entity being limited. It also provides a default interception message for blocked requests.
Since:
Java 17+
Author:
Kimi Liu
  • Constructor Details

    • Supplier

      public Supplier()
  • Method Details

    • get

      public abstract Serializable get()
      Retrieves the current user or request identifier. This method must be implemented by concrete subclasses to provide the specific identification logic.
      Returns:
      A Serializable object representing the user or request identifier.
    • intercept

      public Serializable intercept(Object bean, Method method, Object[] args)
      Provides a default interception message when a request is blocked by a limiter. Subclasses can override this method to provide custom messages or actions upon interception.
      Parameters:
      bean - The target object on which the method was invoked.
      method - The Method that was attempted to be executed.
      args - The arguments passed to the method invocation.
      Returns:
      A Serializable object, typically a message, indicating the request was intercepted.