<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
<!-- spring2.0 Transaction --> <bean id="myHibTxManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <tx:advice id="txadvice" transaction-manager="myHibTxManager"> <tx:attributes> <!-- 对查询方法要求只读事务 --> <tx:method name="login*" propagation="SUPPORTS" read-only="true" /> <tx:method name="show*" propagation="SUPPORTS" read-only="true" /> <tx:method name="search*" propagation="SUPPORTS" read-only="true" /> <tx:method name="to*" propagation="SUPPORTS" read-only="true" /> <!-- 对其它方法要求事务 --> <tx:method name="do*" propagation="REQUIRED" /> <tx:method name="*" propagation="REQUIRED" /> </tx:attributes> </tx:advice> <aop:config> <aop:pointcut id="biMethods" expression="execution(* biz.*.*(..))" /> <!-- 植入 --> <aop:advisor advice-ref="txadvice" pointcut-ref="biMethods" /> </aop:config> <aop:config> <aop:pointcut id="actionMethods" expression="execution(* web.action.*.*(..))" /> <aop:advisor advice-ref="txadvice" pointcut-ref="actionMethods" /> </aop:config> <!-- end spring2.0 Transaction -->
|