I've coded this code snippet:
@Aspect
@Component
public class ApiAuditAspect {
@Pointcut(value = "execution(* net.gencat.transversal.espaidoc.api.controller.RepositoryController.*(..))")
public void anyRepositoryController() {
// Nothing to do here
}
@AfterReturning(
pointcut = "anyRepositoryController()",
returning = "result")
public void audit(JoinPoint point, Object result) throws Throwable {
// audit actions
}
@After("anyRepositoryController()")
public void flush() {
// flush all audits
}
}
I've realized flush is executed before audit.
I though @After is executed after AfterReturning.
Any ideas about how to solve that?