public static interface DynamicInterceptor.InterceptionHandler
DynamicInterceptor class must provide a DynamicInterceptor.InterceptionHandlerFactory
which will be used to create an instance of this DynamicInterceptor.InterceptionHandler for every intercepted call.
This instance is then used to notify the user before and after the actual call to the delegate object.
(If we make this interface into an abstract base class, we should move the arguments of "callReceived" to the constructor, since there is only one method invoked during the lifetime of an InterceptionHandler).
| Modifier and Type | Method and Description |
|---|---|
java.lang.Object |
callFinished(java.lang.Object retVal,
java.lang.Object[] args,
java.lang.Throwable thr) |
boolean |
callReceived(java.lang.reflect.Method method,
java.lang.Object[] args)
Notification that a call to the
DynamicInterceptor.delegate has been intercepted,
but the call has not yet been forwarded. |
boolean callReceived(java.lang.reflect.Method method,
java.lang.Object[] args)
DynamicInterceptor.delegate has been intercepted,
but the call has not yet been forwarded.method - The name of the interface method that has been called.args - The call arguments, see InvocationHandler.invoke(Object, Method, Object[]).true to continue with forwarding the call to the delegate object;
false to prohibit the call to the delegate object
(in which case #callFinished(Object, Throwable) must provide the return value or exception).java.lang.Object callFinished(java.lang.Object retVal,
java.lang.Object[] args,
java.lang.Throwable thr)
throws java.lang.Throwable
retVal - The return value received from the delegate object.args - The call arguments (same as in callReceived,
but possibly with values modified during the call, e.g. for Corba out or inout parameters).thr - The Throwable that was thrown by the delegate's method implementation, if any.
Note that wrapper exceptions InvocationTargetException and UndeclaredThrowableException
get removed automatically, so that thr is the original exception thrown,
or null if no exception/error was thrown.retVal
unless the interceptor wants to modify the return value).java.lang.Throwable - The throwable that should be forwarded to the calling client. Normally this should be the same
as the argument thr (which then must be thrown by the implementation of this method!),
but the handler is free to throw an exception even if the
delegate object did not throw any, or to throw a different exception, or to suppress the exception.