项目作者: panlw

项目描述 :
Spring Boot AOP Sample -- @Around(value = "@annotation(anchor)", argNames="anchor")
高级语言: Java
项目地址: git://github.com/panlw/using-springboot-aop.git
创建时间: 2017-04-19T08:56:13Z
项目社区:https://github.com/panlw/using-springboot-aop

开源协议:

下载


Spring Boot AOP Sample

  1. @Aspect
  2. @Component
  3. public class AnchorMonitor {
  4. @Around(value = "@annotation(anchor)", argNames="anchor")
  5. // @Around(value = "@annotation(anchor)", argNames="joinPoint, anchor") // OK too.
  6. public Object replaceFirstArg(ProceedingJoinPoint joinPoint, Anchor anchor) throws Throwable {
  7. System.out.println("[AOP] joinPoint: " + joinPoint);
  8. System.out.println("[AOP] anchor.id: " + anchor.id());
  9. Object[] args = joinPoint.getArgs();
  10. if (args[0] == null) args[0] = anchor.id();
  11. return joinPoint.proceed(args);
  12. }
  13. }