Class ReflectiveMethodInvocation

java.lang.Object
com.ultikits.ultitools.aop.ReflectiveMethodInvocation
All Implemented Interfaces:
MethodInvocation

public class ReflectiveMethodInvocation extends Object implements MethodInvocation
Implementation of MethodInvocation that uses reflection to invoke methods.

Maintains an interceptor chain and invokes them in order before calling the target method.

Since:
6.2.0
Author:
wisdomme
  • Field Details

    • target

      private final Object target
    • method

      private final Method method
    • arguments

      private final Object[] arguments
    • interceptors

      private final List<MethodInterceptor> interceptors
    • currentIndex

      private int currentIndex
  • Constructor Details

    • ReflectiveMethodInvocation

      public ReflectiveMethodInvocation(Object target, Method method, Object[] arguments, List<MethodInterceptor> interceptors)
      Creates a new reflective method invocation.
      Parameters:
      target - the target object
      method - the method to invoke
      arguments - the method arguments
      interceptors - the list of interceptors to apply
  • Method Details

    • getTarget

      public Object getTarget()
      Description copied from interface: MethodInvocation
      Gets the target object being invoked.
      Specified by:
      getTarget in interface MethodInvocation
      Returns:
      the target object
    • getMethod

      public Method getMethod()
      Description copied from interface: MethodInvocation
      Gets the method being invoked.
      Specified by:
      getMethod in interface MethodInvocation
      Returns:
      the method
    • getArguments

      public Object[] getArguments()
      Description copied from interface: MethodInvocation
      Gets the arguments passed to the method.
      Specified by:
      getArguments in interface MethodInvocation
      Returns:
      the method arguments, or an empty array if no arguments
    • proceed

      public Object proceed() throws Throwable
      Description copied from interface: MethodInvocation
      Proceeds with the next interceptor in the chain or invokes the target method if this is the last interceptor.
      Specified by:
      proceed in interface MethodInvocation
      Returns:
      the result of the invocation
      Throws:
      Throwable - if the invocation throws an exception