使用joinpoint.getSignature().getName()只能得到方法名,而如果使用反射通过类和方法名去得到拦截的method对象很麻烦,而且容易出问题,难道在spring2.0中使用Aspect方式进行AOP没有别的方法得到拦截的method对象吗,就象spring1里一样,有个method对象参数。
1条回答 默认 最新
- iteye_521 2008-11-13 09:36关注
[url]http://www.nabble.com/Sring-AOP---ProceedingJoinPoint---Method-td20042019.html(必须用代理上)[/url]
看看这个,貌似可以这么做,
[code="java"]
Signature signature = a_joinPoint.getSignature();
MethodSignature methodSignature = (MethodSignature) signature;
Method method = methodSignature.getMethod();try { Object[] arguments = a_joinPoint.getArgs(); result = method.invoke(mock, arguments); s_logger.debug("Mocking " + formatCall(a_joinPoint)); } catch (InvocationTargetException e) { s_logger.debug("Failed to delegate to mock: " + formatCall(a_joinPoint), e); throw e.getTargetException(); }
[/code]
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报