spring 1.2.X的事务配置
呵呵,用上spring2.0了,但是辛辛苦苦研究出来的1.2.x的配置方法也不忍心就这么扔了,放这里做个记录吧。
首先是基于Java5 Annotation的配置:
首先是基于Java5 Annotation的配置:
<?
xml version="1.0" encoding="UTF-8"
?>
<! DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd" >
< beans >
< import
resource ="classpath:cn/com/nec/esmpro/gserver/util/database/database.beans.xml" />
< bean
class ="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator" >
< description > Switch AOP function ON! </ description >
</ bean >
< bean
class ="org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor" >
< constructor-arg >
< bean class ="org.springframework.transaction.interceptor.TransactionInterceptor" >
< property name ="transactionManager" >
< bean class ="org.springframework.orm.hibernate3.HibernateTransactionManager" >
< property name ="sessionFactory" ref ="gserverSessionFactoryBean" />
</ bean >
</ property >
< property name ="transactionAttributeSource" >
< bean class ="org.springframework.transaction.annotation.AnnotationTransactionAttributeSource" />
</ property >
</ bean >
</ constructor-arg >
</ bean >
</ beans >
然后是只使用XML的配置:
<! DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd" >
< beans >
< import
resource ="classpath:cn/com/nec/esmpro/gserver/util/database/database.beans.xml" />
< bean
class ="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator" >
< description > Switch AOP function ON! </ description >
</ bean >
< bean
class ="org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor" >
< constructor-arg >
< bean class ="org.springframework.transaction.interceptor.TransactionInterceptor" >
< property name ="transactionManager" >
< bean class ="org.springframework.orm.hibernate3.HibernateTransactionManager" >
< property name ="sessionFactory" ref ="gserverSessionFactoryBean" />
</ bean >
</ property >
< property name ="transactionAttributeSource" >
< bean class ="org.springframework.transaction.annotation.AnnotationTransactionAttributeSource" />
</ property >
</ bean >
</ constructor-arg >
</ bean >
</ beans >
<?
xml version="1.0" encoding="UTF-8"
?>
<! DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd" >
< beans >
< import
resource ="classpath:cn/com/nec/esmpro/gserver/util/database/database.beans.xml" />
< bean
class ="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator" >
< description > Switch AOP function ON! </ description >
</ bean >
< bean
class ="org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor" >
< property name ="classFilter" >
< bean class ="???????????????????????????????????????" >
</ bean >
</ property >
< property name ="transactionInterceptor" >
< bean class ="org.springframework.transaction.interceptor.TransactionInterceptor" >
< property name ="transactionManager" >
< bean class ="org.springframework.orm.hibernate3.HibernateTransactionManager" >
< property name ="sessionFactory" ref ="gserverSessionFactoryBean" />
</ bean >
</ property >
< property name ="transactionAttributes" >
< props >
< prop key ="*" > PROPAGATION_REQUIRED </ prop >
< prop key ="find*" > PROPAGATION_REQUIRED,readOnly </ prop >
</ props >
</ property >
</ bean >
</ property >
</ bean >
</ beans >
<! DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd" >
< beans >
< import
resource ="classpath:cn/com/nec/esmpro/gserver/util/database/database.beans.xml" />
< bean
class ="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator" >
< description > Switch AOP function ON! </ description >
</ bean >
< bean
class ="org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor" >
< property name ="classFilter" >
< bean class ="???????????????????????????????????????" >
</ bean >
</ property >
< property name ="transactionInterceptor" >
< bean class ="org.springframework.transaction.interceptor.TransactionInterceptor" >
< property name ="transactionManager" >
< bean class ="org.springframework.orm.hibernate3.HibernateTransactionManager" >
< property name ="sessionFactory" ref ="gserverSessionFactoryBean" />
</ bean >
</ property >
< property name ="transactionAttributes" >
< props >
< prop key ="*" > PROPAGATION_REQUIRED </ prop >
< prop key ="find*" > PROPAGATION_REQUIRED,readOnly </ prop >
</ props >
</ property >
</ bean >
</ property >
</ bean >
</ beans >