简单 spring AOP 配置文件

来源:互联网 发布:电魂网络showgirl 编辑:程序博客网 时间:2024/05/22 00:35

配置文件两种:

1、

<aop:config><aop:pointcut id="ctrlOperation"expression="execution(* com.tuniu..*Controller.*(..))" /><aop:pointcut id="ctrlAPI" expression="execution(* com.tuniu..*API.*(..))" /><aop:advisor advice-ref="loginInfoAdvice" pointcut-ref="ctrlOperation" /><aop:advisor advice-ref="loginInfoAdvice" pointcut-ref="ctrlAPI" /><aop:advisor advice-ref="dataSourceAdvice" pointcut-ref="ctrlOperation" /></aop:config><bean id="dataSourceAdvice" class="com.tuniu.scc.stock.manage.common.db.DataSourceAdvice" /><bean id="loginInfoAdvice" class="com.tuniu.scc.stock.manage.common.login.CookieAdvice" />

2、

<aop:config>          <aop:aspect id="TestAspect" ref="aspectBean">              <!--配置com.spring.service包下所有类或接口的所有方法-->              <aop:pointcut id="businessService"                  expression="execution(* com.spring.service.*.*(..))" />              <aop:before pointcut-ref="businessService" method="doBefore"/>              <aop:after pointcut-ref="businessService" method="doAfter"/>              <aop:around pointcut-ref="businessService" method="doAround"/>              <aop:after-throwing pointcut-ref="businessService" method="doThrowing" throwing="ex"/>          </aop:aspect>      </aop:config>            <bean id="aspectBean" class="com.spring.aop.TestAspect" />


0 0