Advertisement
AdrakPro

Parameters and expressions

Jul 15th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.80 KB | None | 0 0
  1. @Before("execution(* com.example.xxx.*(..))")
  2. public void logInfoBefore(JoinPoint joinPoint) {}
  3.  
  4. @AfterReturning("execution(* com.example.xxx.get(..)) && args(isbn)")
  5. public void logSuccess(JoinPoint joinPoint, String isbn) {}
  6.  
  7. @AfterReturning(pointcut = "execution(* com.example.xxx.get(..)) && args(isbn)",
  8. returning = "result")
  9. public void logSuccess(JoinPoint joinPoint, String isbn, Book result) {
  10. if(result != null) {
  11.     System.out.println(result);
  12. }}
  13.  
  14. @AfterThrowing(
  15. pointcut = "com.example.xxx.AspectUtil.allBookRepositoryMethods()",
  16. throwing = "error")
  17. public void logError(JoinPoint joinPoint, Throwable error) {
  18.     System.out.println(error);
  19. }
  20.  
  21. @Aspect
  22. @Component
  23. public class AspectUtil {
  24. @Pointcut("execution(* com.example.xxx.*(..))")
  25.     public void allBookRepositoryMethods(){}
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement