Guest User

Untitled

a guest
Jan 22nd, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  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. }
Add Comment
Please, Sign In to add comment