DanutClapa
DanutClapa

Reputation: 642

Audit trough AOP all public methods of an annotated class

There is a possibility to audit trough AOP(using spring aop, aspectj etc.) all the public methods of a class annotated with @Service or @Repository or what ever annotation I consider that is class level and not at method level? I want to have something like this:

@Pointcut(value = "execution(public * *(..))")
public void anyPublicMethod() {} 

@Around("anyPublicMethod() && @annotation(Repository)")
public Object doLogTime(ProceedingJoinPoint joinPoint) throws Throwable {
    //do something
}

Upvotes: 0

Views: 599

Answers (1)

kriegaex
kriegaex

Reputation: 67297

The pointcut should be

execution(public * @my.package.Repository *.*(..))

which is implicitly the same as

execution(public * (@my.package.Repository *).*(..))

P.S.: Your pointcut from the question actually targets methods annotated by @Repository, which is not what you want.

Upvotes: 1

Related Questions