spring aop实现过程之三Spring AOP中Aspect编织的实现
来源:互联网 发布:多维数组 数组的数组 编辑:程序博客网 时间:2024/04/29 08:44
1.上节我们谈到拦截器起作用时,实现代码(ReflectiveMethodInvocation.java)如下:
public Object proceed() throws Throwable { // We start with an index of -1 and increment early. if (this.currentInterceptorIndex == this.interceptorsAndDynamicMethodMatchers.size() - 1) { return invokeJoinpoint(); } Object interceptorOrInterceptionAdvice = this.interceptorsAndDynamicMethodMatchers.get(++this.currentInterceptorIndex); if (interceptorOrInterceptionAdvice instanceof InterceptorAndDynamicMethodMatcher) { // Evaluate dynamic method matcher here: static part will already have // been evaluated and found to match. InterceptorAndDynamicMethodMatcher dm = (InterceptorAndDynamicMethodMatcher) interceptorOrInterceptionAdvice; if (dm.methodMatcher.matches(this.method, this.targetClass, this.arguments)) { return dm.interceptor.invoke(this); } else { // Dynamic matching failed. // Skip this interceptor and invoke the next in the chain. return proceed(); } } else { // It's an interceptor, so we just invoke it: The pointcut will have // been evaluated statically before this object was constructed. return ((MethodInterceptor) interceptorOrInterceptionAdvice).invoke(this); } }
2.前置Advice MethodBeforeAdviceInterceptor.java
public Object invoke(MethodInvocation mi) throws Throwable { this.advice.before(mi.getMethod(), mi.getArguments(), mi.getThis() ); return mi.proceed(); }
3.后置Advice AfterReturningAdviceInterceptor.java
public Object invoke(MethodInvocation mi) throws Throwable { Object retVal = mi.proceed(); this.advice.afterReturning(retVal, mi.getMethod(), mi.getArguments(), mi.getThis()); return retVal; }
- spring aop实现过程之三Spring AOP中Aspect编织的实现
- Spring AOP 之 Aspect
- Spring AOP之@Aspect
- Spring AOP 的@Aspect
- Spring中AOP的实现 (三)
- Spring中AOP的实现 (三)
- spring Aop中aop:advisor 与 aop:aspect的区别
- spring aop实现的过程
- Spring之<aop:advisor>和<aop:aspect>的区别
- Spring之AOP实现
- Spring中AOP实现
- Spring中AOP实现
- Spring中AOP实现
- spring的aop:advisor和aop:aspect
- spring aop实现过程之二Spring AOP中拦截器链
- Spring的AOP(四):自动代理及Aspect J的方式实现Aop编程
- 【spring 5】AOP:spring中对于AOP的的实现
- Spring的AOP实现
- Aop获取bean的过程---spring debug
- cxf 实例解读
- 项目经理原则(转载)
- spring aop实现过程之一代理对象的生成
- spring aop实现过程之二Spring AOP中拦截器链
- spring aop实现过程之三Spring AOP中Aspect编织的实现
- 数据库常用面试题(SQL Server) (转载)
- spring resource
- 在Struts2中使用SiteMesh插件
- 几种华丽无比开发方式(转载)
- spring AOP策略模式使用
- tomcat源码分析(一)初始化---Debug方式
- tomcat源码分析(二)启动---Debug方式
- tomact如何处理一个http请求?