日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

AOP 总结

發(fā)布時間:2025/6/17 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 AOP 总结 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

AOP即Aspect oriented Programing, 面向切面編程。

相關(guān)術(shù)語:

通知(Advice):

Advice defineds when to execute what action.
通知定義了切面要執(zhí)行的內(nèi)容以及在什么時候執(zhí)行該內(nèi)容。

Spring支持的5種通知類型:

  • Before - org.springframework.aop.MethodBeforeAdvice
  • After-returning - org.springframework.aop.AfterRetruningAdvice
  • After-throwing - org.springframework.aop.ThrowsAdvice
  • Arount - org.aopaliance.intercept.MethodInterceptor
  • Introduction - org.springframework.aop.IntroductionInterceptor

連接點(JoinPoint):

The time to execute advice.
連接點指明了應(yīng)用通知的時機,比如方法執(zhí)行時,異常拋出時等。

切入點(PointCut):

Where to execute the action.
定義了在什么地方去執(zhí)行織入的操作, 比如某個類名或者方法名。可以使用正則表達式表示。

切面(Aspect):

The advice and pointcut makes up the aspect to specify where and when to execute the action.
通知和切入點共同組成了切面,即為動作要執(zhí)行的時間,內(nèi)容和地點。

引入(Introduction):

Allows us to add new methods or properties to a class.
引入允許向現(xiàn)有的類添加新的方法和屬性(Spring引入類方法注入的功能)

目標(Target):

The target got adviced. If there's no AOP, the target need to execute other kind of logics like recording log, transaction controlle, and with AOP, it can focus on its own business logic.
被通知的對象。不使用AOP的時候,目標的邏輯需要交叉其它的諸如日志記錄,事務(wù)控制等事務(wù)邏輯,使用AOP的時候,則只需要關(guān)注自己的業(yè)務(wù)邏輯就可以了。

代理(Proxy):

The object to apply advice.
應(yīng)用通知的對象。

織入(Weaving):

Apply the aspect to the target to generate the proxy.
把切面應(yīng)用到目標對象來創(chuàng)建代理對象的過程,織入一般發(fā)生在如下幾個時機:

  • 編譯時: 當(dāng)一個類文件被編譯時織入,需要特殊的編譯器才能實現(xiàn),比如AspectJ的編譯器
  • 類加載時: 當(dāng)使用特殊的類加載器在目標被加載到虛擬機之前增強類的字節(jié)代碼
  • 運行時: 切面在運行的某個時刻被織入,SpringAOP就是以此種方式織入的,原理是是用了JDK的動態(tài)代理技術(shù)。

實現(xiàn)方式

  • 基于代理
  • 通過@AspectJ注解驅(qū)動
  • 純POJO切面
  • 注入式AspectJ切面
  • 轉(zhuǎn)載于:https://www.cnblogs.com/developerERA/p/7084482.html

    總結(jié)

    以上是生活随笔為你收集整理的AOP 总结的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。