Interface MethodInvocation

All Superinterfaces:
AnnotationAccess, MethodInvocationResult
All Known Implementing Classes:
AbstractMethodInvocation

A representation of the invocation of a method that allows the behavior of the method to be advised: either by changing parameter values, or by changing the return value, or by catch or throwing different exceptions. Provides access to annotations on the advised method.
See Also:
  • Method Details

    • getInstance

      The instance on which the method was originally invoked.
    • getInstanceContext

    • proceed

      Proceed with the method invocation, either chaining into the next MethodAdvice added to the method, or ultimately into the actual method implementation. The method may throw a checked exception, which will be caught and be reported as MethodInvocationResult.didThrowCheckedException().
      Returns:
      this method invocation, for a fluent API
    • setReturnValue

      Overrides the return value of the method. The value provided will be cast to the actual return type (or, if the return type is a primitive value, the value will be cast to the corresponding wrapper type and then converted to a primitive). Overriding the return value clears any checked exception.
      Parameters:
      returnValue -
      Returns:
      this method invocation, for a fluent API
      Throws:
      NullPointerException - if the method's return type is a primitive and null is provided
    • getParameter

      Object getParameter(int index)
      Returns the parameter at the given index. Primitive types will be wrapped as they are returned.
      Parameters:
      index - of parameter to access
      Returns:
      parameter value
    • setParameter

      MethodInvocation setParameter(int index, Object newValue)
      Changes a parameter value. The value will be cast to the parameter's type. For primitive types, the value will be cast to the corresponding wrapper type.
      Parameters:
      index - index of parameter to modify
      newValue - new value for parameter
      Returns:
      this method invocation, for a fluent API
    • setCheckedException

      Sets the checked exception; this can be used to indicate failure for the method, or to cancel the thrown exception (by setting the exception to null).
      Parameters:
      exception - new checked exception, or null
      Returns:
      this method invocation, for a fluent API
    • getMethod

      Returns the method being invoked.