首页 > 代码库 > spring---aop(3)---Spring AOP的拦截器链
spring---aop(3)---Spring AOP的拦截器链
写在前面
时间断断续续,这次写一点关于spring aop拦截器链的记载。至于如何获取spring的拦截器,前一篇博客已经写的很清楚(spring---aop(2)---Spring AOP的JDK动态代理)
获取拦截器链
final class JdkDynamicAopProxy implements AopProxy, InvocationHandler, Serializable { public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { ...
//获取拦截器链 List<Object> chain = this.advised.getInterceptorsAndDynamicInterceptionAdvice(method, targetClass); // Check whether we have any advice. If we don‘t, we can fallback on direct if (chain.isEmpty()) { // 如果拦截器链为空,则执行目标方法 retVal = AopUtils.invokeJoinpointUsingReflection(target, method, args); } else { // 封装拦截器链的执行方法 invocation = new ReflectiveMethodInvocation(proxy, target, method, args, targetClass, chain); // 拦截器链执行 retVal = invocation.proceed(); }
... }
spring---aop(3)---Spring AOP的拦截器链
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。