Module bus.limiter

Class ByteBuddyProxy

java.lang.Object
org.miaixz.bus.limiter.proxy.ByteBuddyProxy

public class ByteBuddyProxy extends Object
A utility class for creating ByteBuddy proxies to intercept method calls. This class generates a subclass of a given original class and intercepts all its methods using a ByteBuddyHandler to apply limiting rules.
Since:
Java 17+
Author:
Kimi Liu
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final Object
    The target object (bean) for which the proxy is being created.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ByteBuddyProxy(Object bean, Class<?> originalClazz)
    Constructs a new ByteBuddyProxy with the specified target bean and its original class.
  • Method Summary

    Modifier and Type
    Method
    Description
    Creates and returns a ByteBuddy proxy instance for the bean.

    Methods inherited from class java.lang.Object

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

    • bean

      public final Object bean
      The target object (bean) for which the proxy is being created. Method calls on the proxy will be delegated to this bean.
  • Constructor Details

    • ByteBuddyProxy

      public ByteBuddyProxy(Object bean, Class<?> originalClazz)
      Constructs a new ByteBuddyProxy with the specified target bean and its original class.
      Parameters:
      bean - The target object to be proxied.
      originalClazz - The original class of the target object.
  • Method Details

    • proxy

      public Object proxy() throws Exception
      Creates and returns a ByteBuddy proxy instance for the bean. The proxy intercepts all method calls and delegates them to a ByteBuddyHandler for applying limiting logic.
      Returns:
      A proxied instance of the original class.
      Throws:
      Exception - if an error occurs during proxy creation.