View Javadoc

    1   package groovy.lang;
    2
    3   /***
    4    * Implementers of this interface can be registered in the ProxyMetaClass for
    5    * notifications about method calls for objects managed by the ProxyMetaClass.
    6    * See groovy/lang/InterceptorTest.groovy for details.
    7    * @author Dierk Koenig
    8    */
    9   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, Object[] arguments);
    20      /***
    21       * This code is executed after the method is optionally called.
    22       * @param object        receiver object for the called method
    23       * @param methodName    name of the called method
    24       * @param arguments     arguments to the called method
    25       * @param result        result of the executed method call or result of beforeInvoke if method was not called
    26       * @return any arbitrary result that can replace the result of the
    27       * original method call. Typically, the result parameter is returned.
    28       */
    29      Object afterInvoke(Object object, String methodName, Object[] arguments, Object result);
    30      /***
    31       * @return whether the target method should be invoked at all.
    32       */
    33      boolean doInvoke();
    34  }