Using @AfterReturning with the returnValue parameter.
Then you could interact with the returned object. This is an example when I do this in everything, but get the methods in the repository.
@AfterReturning(value = "@target(org.springframework.stereotype.Repository) && !execution(* get*(..))", returning = "returnValue") public void loggingRepositoryMethods(JoinPoint joinPoint, Object returnValue) { String classMethod = this.getClassMethod(joinPoint); if(returnValue !=null) { //test type of object get properties (could use reflection) log it out } else { //do logging here probably passing in (joinPoint, classMethod); } }
source share