问题很简短:有没有办法从aspectj ProceedingJoinPoint 获取Method 对象?
目前我正在做
Class[] parameterTypes = new Class[joinPoint.getArgs().length];
Object[] args = joinPoint.getArgs();
for(int i=0; i<args.length; i++) {
if(args[i] != null) {
parameterTypes[i] = args[i].getClass();
}
else {
parameterTypes[i] = null;
}
}
String methodName = joinPoint.getSignature().getName();
Method method = joinPoint.getSignature()
.getDeclaringType().getMethod(methodName, parameterTypes);
但我不认为这是要走的路......
你的方法没有错,但是还有更好的方法。你必须投射到MethodSignature http://www.eclipse.org/aspectj/doc/released/runtime-api/org/aspectj/lang/reflect/MethodSignature.html
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
Method method = signature.getMethod();
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)