Spring AOP中pointcut expression

来源:互联网 发布:netbeans php常用插件 编辑:程序博客网 时间:2024/05/18 23:14
1 <bean id="dataSourceAspect" class="com.test.context.datasource.DataSourceAspect" />2     <aop:config>3         <aop:aspect ref="dataSourceAspect">4             <!-- 拦截所有service方法 -->5             <aop:pointcut id="dataSourcePointcut" expression="execution(* com.cmcc.musescms.dao..*.*(..))"/>6             <aop:before pointcut-ref="dataSourcePointcut" method="intercept" />7         </aop:aspect>8     </aop:config>9 </bean>
先说下execution语法:

定义在service包和所有子包里的任意类的任意方法的执行:     

execution(* com.xyz.service..*.*(..))

第一个*表示任意返回值,service后面两个点表示“service包和所有子包”,*.*表示所有类的所有方法。

bean id为类名,class为位置;aop的execution表示筛选的类,method表示对类使用的方法。

原创粉丝点击