spring aop expression 匹配多个条件 多个表达式

aop:config>
  <aop:pointcut expression="execution(* com.travelsky.ccboy.dao..*.find*(..))
||  execution(* com.travelsky.ccboy.dao..*.query*(..))"
   id="findCachePointcut" />
  <aop:advisor advice-ref="jdbcInterceptor" pointcut-ref="findCachePointcut" />

</aop:config>

在多个表达式之间使用 ||,or表示 ,使用 &&,and表示 表示 .

上面的代码也可以改写成

<aop:config>
  <aop:pointcut expression="(execution(* com.travelsky.ccboy.dao..*.find*(..))) or(execution(* com.travelsky.ccboy.dao..*.query*(..)))"
   id="findCachePointcut" />
  <aop:advisor advice-ref="jdbcInterceptor" pointcut-ref="findCachePointcut" />

</aop:config>

注意上面两中方法的不同点出了 将 || 改成了 or ,还有就是 每个execution都被()包含起来,建议为了区分不同的表达式 最好都是用()包装。

更多请参考:http://docs.jboss.org/jbossaop/docs/2.0.0.GA/docs/aspect-framework/reference/en/html/annotated.html

 from http://hi.baidu.com/i_ccboy/item/43bab004a34fd3ce74cd3cd4

猜你喜欢

转载自fuanyu.iteye.com/blog/1816490
今日推荐