01: package groovy.lang;
02:
03: /**
04: * Implementers of this interface can be registered in the ProxyMetaClass for
05: * notifications about method calls for objects managed by the ProxyMetaClass.
06: * See groovy/lang/InterceptorTest.groovy for details.
07: * @author Dierk Koenig
08: */
09: public interface Interceptor {
10: /**
11: * This code is executed before the method is optionally called.
12: * @param object receiver object for the method call
13: * @param methodName name of the method to call
14: * @param arguments arguments to the method call
15: * @return any arbitrary result that replaces the result of the
16: * original method call only if doInvoke() returns false and afterInvoke()
17: * relays this result.
18: */
19: Object beforeInvoke(Object object, String methodName,
20: Object[] arguments);
21:
22: /**
23: * This code is executed after the method is optionally called.
24: * @param object receiver object for the called method
25: * @param methodName name of the called method
26: * @param arguments arguments to the called method
27: * @param result result of the executed method call or result of beforeInvoke if method was not called
28: * @return any arbitrary result that can replace the result of the
29: * original method call. Typically, the result parameter is returned.
30: */
31: Object afterInvoke(Object object, String methodName,
32: Object[] arguments, Object result);
33:
34: /**
35: * @return whether the target method should be invoked at all.
36: */
37: boolean doInvoke();
38: }
|