I'm trying to introduce a logger in my project using Spring AOP, but I'm new to AOP and to AspectJ syntax, so I'm having some troubles...
I've defined a basic aspect-class following some tutorial/docs:
@Aspect
public class Logger {
@Pointcut("execution(* exportdatamanager.export.ExportType.fetch(..))")
public void fetch() {
}
// ...
@AfterReturning("fetch()")
public void fetchingResult(JoinPoint joinPoint, Object result) {
System.out.println("TEST LOG " + result.toString());
}
}
But when I run my application I get this exception:
java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut
What I'm doing wrong, I suppose there's something wrong in my ApsectJ expression...
Can you also suggest me some quick reference to AspectJ syntax supported by Spring AOP?
NOTE
A snippet from my ExportType
interface
public interface ExportType {
List<Object> fetch() throws FetchingStrategyException;
// ...
}
Ok, I just solved my issue this way:
@AfterReturning(pointcut = "fetch()", returning = "results")
public void fetchingResult(JoinPoint joinPoint, List<Object> results) {
System.out.println("TEST LOG " + results.toString());
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.