Spring(5) -(14) pointcut 语法
生活随笔
收集整理的這篇文章主要介紹了
Spring(5) -(14) pointcut 语法
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
AOP的規范本應該由SUM公司提出,但是被AOP聯盟捷足先登.AOP聯盟指定AOP規范,首先就要解決一個問題,怎么表示切入點,也就是在哪些方法上增強(where)
AspectJ 是一個面向切面的框架:
AspectJ切入點語法如下:
(表示在哪些包下的哪些類的哪些方法做切入增強)
execution(modifiners-pattern?ret-type-pattern declaring-type-pattern? name-param(param-patterm)throws-pattern?) ?
表示:該參數可以出現一次或零次
翻譯成中文: execution(<修飾符>?<返回類型> <聲明類型>?<方法名>(<參數>)<異常>?)
舉例:public static Class java.lang.Class.forName(String className) throws ClassNotFoundException
通配符
*
匹配任何部分,只能表示一個單詞
..
可用于全限定名中和方法參數中,分別表示子包和0到N個參數
spring-core 文檔中的例子
Some examples of common pointcut expressions are given below.
the execution of any public method:
execution(public * *(..))
the execution of any method with a name beginning with "set":
execution(* set*(..))
the execution of any method defined by the AccountService interface:
execution(* com.xyz.service.AccountService.*(..))//常用
the execution of any method defined in the service package:
execution(* com.xyz.service.*.*(..))//常用
the execution of any method defined in the service package or a sub-package:
execution(* com.xyz.service..*.*(..))//常用
作者:小白201808
鏈接:https://www.jianshu.com/p/f82b6933d78f
來源:簡書
簡書著作權歸作者所有,任何形式的轉載都請聯系作者獲得授權并注明出處。
總結
以上是生活随笔為你收集整理的Spring(5) -(14) pointcut 语法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 从贝叶斯理论到马尔可夫随机场(MRF)-
- 下一篇: ucosiii 移植