我正在尝试从我的周围建议中的连接点 Sourcelocation 访问行号(用于记录目的)。但它给
Exception in thread "main" java.lang.UnsupportedOperationException
at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint$SourceLocationImpl.getLine(MethodInvocationProceedingJoinPoint.java:282)
我loc.getLine()
在调试时得到空值。
@Around("execution (* com.logger.rms.*.*(..))")
public void logAround(ProceedingJoinPoint procJoinpoint) throws Throwable {
StaticPart part = (procJoinpoint.getStaticPart());
org.aspectj.lang.reflect.SourceLocation loc = part.getSourceLocation();
int line = loc.getLine();
System.out.println(line);
try {
procJoinpoint.proceed();
} catch (Throwable e) {
System.out.println("checking " + procJoinpoint.getSourceLocation().getWithinType().getCanonicalName());
String str = "Aspect ConcreteTester :" + procJoinpoint.getStaticPart().getSourceLocation().getLine();
throw new BusinessLogicException("Throwing Custom business exception from around");
} finally {
}
}