项目作者: panlw
项目描述 :
Spring Boot AOP Sample -- @Around(value = "@annotation(anchor)", argNames="anchor")
高级语言: Java
项目地址: git://github.com/panlw/using-springboot-aop.git
Spring Boot AOP Sample
@Aspect
@Component
public class AnchorMonitor {
@Around(value = "@annotation(anchor)", argNames="anchor")
// @Around(value = "@annotation(anchor)", argNames="joinPoint, anchor") // OK too.
public Object replaceFirstArg(ProceedingJoinPoint joinPoint, Anchor anchor) throws Throwable {
System.out.println("[AOP] joinPoint: " + joinPoint);
System.out.println("[AOP] anchor.id: " + anchor.id());
Object[] args = joinPoint.getArgs();
if (args[0] == null) args[0] = anchor.id();
return joinPoint.proceed(args);
}
}