Class MethodWrapper<T extends Annotation>

java.lang.Object
enterprises.iwakura.sigewine.aop.MethodWrapper<T>
Type Parameters:
T - The type of the annotation that this wrapper handles

public abstract class MethodWrapper<T extends Annotation> extends Object
A wrapper for methods that are annotated with a specific annotation. This class provides a way to handle method invocations before and after they are executed, allowing for custom behavior based on the annotation.
  • Constructor Details

    • MethodWrapper

      public MethodWrapper(Class<T> annotationClass)
      Constructor that initializes the wrapper with the specified annotation class.
      Parameters:
      annotationClass - The class of the annotation that this wrapper handles
  • Method Details

    • beforeInvocation

      protected abstract void beforeInvocation(Object target, Method method, Object[] args, T annotation, Object proxy)
      Method to be called before the annotated method is invoked.
      Parameters:
      target - The target object on which the method is invoked
      method - The method that is being invoked
      args - The arguments passed to the method
      annotation - The annotation instance that is present on the method
      proxy - The proxy object that is used to invoke the method
    • afterInvocation

      protected abstract void afterInvocation(Object target, Method method, Object[] args, T annotation, Optional<Object> optionalResult, Optional<Throwable> optionalThrowable, Object proxy)
      Method to be called after the annotated method is invoked. This is called regardless of whether the method throws an exception or not.
      Parameters:
      target - The target object on which the method was invoked
      method - Method that was invoked
      args - Arguments passed to the method
      annotation - The annotation instance that is present on the method
      optionalResult - Optional result of the method invocation, if any
      optionalThrowable - Optional throwable that was thrown during the method invocation, if any
      proxy - The proxy object that was used to invoke the method
    • getAnnotatedMethods

      public Map<String,Annotation> getAnnotatedMethods(Object target)
      Gets all methods that are affected by this method wrapper.
      Parameters:
      target - The target object to get the methods from
      Returns:
      A map of method names to annotations