Interface InvocationEventHandler<C extends InvocationContext>
- Type Parameters:
C- invocation context
public interface InvocationEventHandler<C extends InvocationContext>
Interface for handing invocation events.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns true if this event handler instance is enabled, otherwise false.voidonFailure(@Nullable InvocationContext context, @NonNull Throwable cause) Invoked when an invocation fails.voidonSuccess(@Nullable InvocationContext context, @Nullable Object result) Invoked with the result of the invocation when it is successful.preInvocation(@NonNull Object instance, @NonNull Method method, @NonNull Object[] args) Invoked before invoking the method on the instance.
-
Method Details
-
isEnabled
boolean isEnabled()Returns true if this event handler instance is enabled, otherwise false.- Returns:
- true if handler is enabled
-
preInvocation
Invoked before invoking the method on the instance.- Parameters:
instance- the instance that the method was invoked on.method- theMethodcorresponding to the interface method invoked on the instance.args- an array of objects containing the values of the arguments passed in the method invocation on the instance, or empty array if interface method takes no arguments. Arguments of primitive types are wrapped in instances of the appropriate primitive wrapper class, such asjava.lang.Integerorjava.lang.Boolean.- Returns:
- the current invocation context. Null values are not recommended but are supported
-
onSuccess
Invoked with the result of the invocation when it is successful.- Parameters:
context- the current invocation context or null if preInvocation returned null, or threw an exception.result- the return value from invocation, or null ifVoid.
-
onFailure
Invoked when an invocation fails.If the invocation throws an
InvocationTargetException, then the cause is passed to this method. Any other thrown object is passed unaltered.- Parameters:
context- the current invocation context or null if preInvocation returned null, or threw an exception.cause- the throwable which caused the failure.
-