Spring AOP

一、
1.什麼是AOP及實現方式
AOP:Aspect Oriented Programming的縮寫,就是面向切面編程,通過預編譯方式和運行期動態代理實現程序功能的統一維護的
一種技術。
主要的功能是:日誌記錄,性能統計,安全控制,事物處理,異常處理等等
AOP實現方式
預編譯
-AspectJ
運行期動態代理(JDK動態代理、CGLib動態代理)
SpringAOP、JbossAOP
2.AOP基本概念
Spring AOP
Spring AOP
3.SPring中的AOP
Spring AOP的用途
Spring AOP
Spring 的AOP實現
Spring AOP
有接口和無接口的Spring AOP實現區別
Spring AOP
4.Schema-based AOP
4.1 配置切面 aspect
Spring AOP
Spring AOP
切面aspect 類是對物體特徵的抽象,切面就是對橫切關注點的抽象
這裏就是植入需要進行執行的代碼
Spring AOP
Spring AOP
4.2配置切入點
這些是spring的 aop 和aspect 都支持的
Spring AOP
以下只支持spring 自己的
Spring AOP
Spring AOP
Spring AOP
該包下所有類的所有方法
Spring AOP
該類下的指定方法 表達式 下圖表達式有誤
execution( com.etoak.aop.TestPointCut.point(..))
execution(
com.etoak.aop.TestPointCut.*(..))
Spring AOP
一個完整的aop congif配置
Spring AOP
我的代碼配置如下
該包下的 以 Biz結尾的類下的所有方法
Spring AOP
切面類
Spring AOP
切點 就是切入對象
Spring AOP
測試類
Spring AOP

after afterReturning 根據xml配置先後 輸出 但是在before之後
after thorw 切點不能正常返回 出現異常就會執行throw 正常執行就會執行after return

如果切點方法正常執行 after return 和after 會根據在 xml先後配置順序執行
after(finally)最終執行 有無異常都會執行這個通知
Spring AOP
around 環繞通知配置文件 執行順序也是根據在 before 和 after 先後順序執行
Spring AOP
Spring AOP
環繞切面類代碼
Spring AOP
環繞通知帶參數的配置文件
Spring AOP
Spring AOP

帶註解的 通知
Spring AOP
Spring AOP
Spring AOP
Spring AOP

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章