daily pastebin goal
63%
SHARE
TWEET

Untitled

a guest Jan 22nd, 2019 42 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import org.aspectj.lang.ProceedingJoinPoint;
  2. import org.aspectj.lang.annotation.Around;
  3. import org.aspectj.lang.annotation.Aspect;
  4. import org.springframework.stereotype.Component;
  5.  
  6. @Aspect
  7. @Component
  8. public class ExampleAspect {
  9.  
  10.   @Around("@within(retry)")
  11.   public Object typeAspect(ProceedingJoinPoint joinPoint, Retry retry) throws Throwable {
  12.     return commonAspect(joinPoint, retry);
  13.   }
  14.  
  15.   @Around("@annotation(retry)")
  16.   public Object methodAspect(ProceedingJoinPoint joinPoint, Retry retry) throws Throwable {
  17.     return commonAspect(joinPoint, retry);
  18.   }
  19.  
  20.   private Object commonAspect(ProceedingJoinPoint joinPoint, Retry retry) throws Throwable {
  21.     System.out.println("Retry is :" + (retry == null ? "null" : retry.value()));
  22.     // ... do your (common) stuff here
  23.     return proceed;
  24.   }
  25.  
  26. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top