Skip to content

Spring Boot AOP Sample -- @around(value = "@annotation(anchor)", argNames="anchor")

Notifications You must be signed in to change notification settings

panlw/using-springboot-aop

Repository files navigation

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

}

About

Spring Boot AOP Sample -- @around(value = "@annotation(anchor)", argNames="anchor")

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages