Spring aop中模式符号

来源:互联网 发布:保卫萝卜网页源码 编辑:程序博客网 时间:2024/06/16 17:52

如:

<aop:config>
<aop:pointcut
expression="execution(* com.lenovo.*.*(..)) ||
 execution(public * com.lenovo.lps.farseer.avatar.purview.impl.ProductServiceImpl.*(..))"
id="ServiceOpertation" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="ServiceOpertation" />
</aop:config>

execution(modifiers-pattern? ret-type-pattern declaring-type-pattern? name-pattern(param-pattern) throws-pattern?)
其中带问号的modifiers-pattern?(public/protected) 和 declaring-type-pattern? throws-pattern? 可以不填

execution(* *..BookManager.save(..))的解读:
第一颗* 代表ret-type-pattern 返回值可任意,
*..BookManager 代表任意Pacakge里的BookManager类。
如果写成com.xyz.service.* 则代表com.xyz.service下的任意类
如果写成com.xyz.service.*.* 则代表com.xyz.service下的任意类的任意方法
com.xyz.service..* com.xyz.service则代表com.xyz.service及其子package下的任意类
save代表save方法,也可以写save* 代表saveBook()等方法
(..) 匹配0个参数或者多个参数的,任意类型
(x,..) 第一个参数的类型必须是X
(x,,,s,..) 匹配至少4个参数,第一个参数必须是x类型,第二个和第三个参数可以任意,第四个必须是s类型

0 0