美文网首页
2019-03-11

2019-03-11

作者: 诅咒猎豹 | 来源:发表于2019-03-11 22:42 被阅读0次

1.什么是AOP
AOP(Aspect Oriented Programming,面向切面编程),通过提供另一种思考程序的方式来补充OOP(Object Oriented Programming,面向对象编程)。AOP是横向抽取,OOP是纵向抽象。
切面可以用于事务管理、日志等方面的模块化
2.AOP核心概念
Aspect(切面)
Join Point(连接点)
Advice(通知/增强)
Pointcut(切点)
Introduction(引入)
Target Object(目标对象)
AOP Proxy(AOP代理)
Weaving(织入)
其中,Advice的主要类型有:
Before Advice(前置通知)
After Returning Advice(返回后通知)
After Throwing Advice(抛出异常后通知)
After (finally)Advice(最后通知)
Around Advice(环绕通知)

注 :切入点和连接点的匹配,是AOP的关键

Hello的前置增强练习

pom.xml中添加AOP相关依赖

311223613.png 20190311223634.png 190311223647.png 20190311223700.png 190311223711.png 190311223720.png

Hello接口和实现类:


![311224145.png](https://img.haomeiwen.com/i16516148/4757768c13cf83b5.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 311224103.png
311224214.png

相关文章

网友评论

      本文标题:2019-03-11

      本文链接:https://www.haomeiwen.com/subject/kuzipqtx.html