首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

AOP 那点事情_转自黄勇

2013-11-15 
AOP 那点事儿_转自黄勇http://my.oschina.net/huangyong/blog/161338?from20130922?Spring 与 AspectJ 结

AOP 那点事儿_转自黄勇

http://my.oschina.net/huangyong/blog/161338?from=20130922

?

Spring 与 AspectJ 结合的威力远远不止这些,我们来点时尚的吧,拦截指定注解的方法怎么样?

13. Spring + AspectJ(基于注解:通过 AspectJ @annotation 表达式拦截方法)?

为了拦截指定的注解的方法,我们首先需要来自定义一个注解:

再来一张表格,总结一下各类增强类型所对应的解决方案:

增强类型基于 AOP 接口基于 @Aspect基于?<aop:config>Before Advice(前置增强)MethodBeforeAdvice@Before<aop:before>AfterAdvice(后置增强)AfterReturningAdvice@After<aop:after>AroundAdvice(环绕增强)MethodInterceptor@Around<aop:around>ThrowsAdvice(抛出增强ThrowsAdvice@AfterThrowing<aop:after-throwing>IntroductionAdvice(引入增强)DelegatingIntroductionInterceptor@DeclareParents<aop:declare-parents>


最后给一张 UML 类图描述一下 Spring AOP 的整体架构:

AOP 那点事情_转自黄勇

热点排行