java.lang.Object
org.miaixz.bus.limiter.proxy.ByteBuddyHandler
- All Implemented Interfaces:
InvocationHandler
An
InvocationHandler implementation that intercepts method calls to apply limiting rules based on
annotations. This handler integrates with ByteBuddy for proxying and uses Sentinel for enforcing various limiting
strategies like downgrade, hotspot, and request limiting.- Since:
- Java 17+
- Author:
- Kimi Liu
-
Constructor Summary
ConstructorsConstructorDescriptionByteBuddyHandler(ByteBuddyProxy byteBuddyProxy) Constructs a newByteBuddyHandlerwith the specifiedByteBuddyProxy. -
Method Summary
-
Constructor Details
-
ByteBuddyHandler
Constructs a newByteBuddyHandlerwith the specifiedByteBuddyProxy.- Parameters:
byteBuddyProxy- TheByteBuddyProxyinstance containing the target object.
-
-
Method Details
-
invoke
Intercepts method invocations and applies limiting rules if the method is configured for it. It resolves the real method, checks for registered limiting annotations, and then delegates toSentinelto process the method according to the defined strategy.- Specified by:
invokein interfaceInvocationHandler- Parameters:
proxy- The proxy instance that the method was invoked on.method- TheMethodinstance corresponding to the interface method invoked on the proxy instance.args- An array of objects containing the values of the arguments passed in the method invocation on the proxy instance. If an interface method has no arguments, this array will be empty. If the method is a static method, this array will be null.- Returns:
- The result of the method invocation, potentially modified by limiting strategies.
- Throws:
Throwable- if an exception occurs during method invocation or limiting processing.RuntimeException- if an unsupported annotation type is encountered.
-