首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 企业软件 > 行业软件 >

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

2013-03-01 
spring aop expression 匹配多个条件 多个表达式aop:config??aop:pointcut?expressionexecution(*?com

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

热点排行