Spring声明式事务

    <bean id="aService" parent="transactionProxy">
        <property name="target" >
            <bean class="AServiceImpl">
                <property name="aDao" ref="aDao" />
            </bean>
        </property>
    </bean>
    当应用从应用上下文里请求一个<span style="font-family: Arial, Helvetica, sans-serif;">aService时,它将得到一个被</span><span style="font-family: Arial, Helvetica, sans-serif;">TransactionProxyFactoryBean包裹的实例,(原来的</span><span style="font-family: Arial, Helvetica, sans-serif;">aService对象应该被重命名,否则对象的id冲突),target指向</span><span style="font-family: Arial, Helvetica, sans-serif;">AServiceImpl。即<span style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 20.799999237060547px;">在父类中有一个target属性,这个</span></span><span style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 20.799999237060547px;">target属性类似于</span><span style="font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 20.799999237060547px;">ProxyFactoryBean的</span><span style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 20.799999237060547px;">target属性-代理的目标对象:</span>
<span style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 20.799999237060547px;"></span><pre name="code" class="html">   <property name="target" >
<pre name="code" class="java"><span style="white-space:pre">	</span><ref bean="<span style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;">aServiceT</span><span style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;">arget</span>"/>
</property>
 
 
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 20.799999237060547px;">所以给这个对象赋予class指定类的对象。</span></span>

    <bean id="transactionProxy" abstract="true" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
		<property name="transactionManager">
			<ref bean="transactionManager" />
		</property>
		<property name="transactionAttributes">
			<props>
				<prop key="add*">PROPAGATION_REQUIRED,ISOLATION_DEFAULT,-tion</prop>
				<prop key="*">PROPAGATION_REQUIRED,ISOLATION_DEFAULT,readOnly,-tion</prop>
			</props>
		</property>
    </bean>

    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
       <property name="dataSource" ref="dataSource"/>
    </bean>

<pre name="code" class="html">    <bean id="aDao" class="ADaoImpl">
        <property name="sqlMapClientTemplate">
            <ref bean="sqlMapClientTemplate"/>
         </property>
    </bean>

	<!-- Spring iBatis SqlMapClient -->
<span style="white-space:pre">	</span><bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
	    <property name="configLocation" value="classpath:sqlMapConfig.xml"/>
	    <property name="dataSource" ref="dataSource"/>
	</bean>
      
	<!-- Spring iBatisTemplate -->
	<bean id="sqlMapClientTemplate" class="org.springframework.orm.ibatis.SqlMapClientTemplate">
	      <property name="sqlMapClient">
	          <ref bean="sqlMapClient"/>
	      </property>
	</bean>



 


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值