public interface InvocationHandler
Proxy| Modifier and Type | Method and Description |
|---|---|
Object |
invoke(Object proxy,
Method method,
Object[] args)
Handles the method which was originally invoked on the proxy instance.
|
Object invoke(Object proxy, Method method, Object[] args) throws Throwable
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
//do some processing before the method invocation
//invoke the method
Object result = method.invoke(proxy, args);
//do some processing after the method invocation
return result;
}proxy - the proxy instance on which the method was invokedmethod - the method invoked on the proxy instanceargs - an array of objects containing the parameters passed to the
method, or null if no arguments are expected.
Primitive types are boxed.Throwable - the exception to throw from the invoked method on the proxy.
The exception must match one of the declared exception types
of the invoked method or any unchecked exception type. If not
then an UndeclaredThrowableException is thrown