Skip to content

Latest commit

 

History

History
19 lines (16 loc) · 605 Bytes

README.md

File metadata and controls

19 lines (16 loc) · 605 Bytes

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);
    }

}