Spring Action TransactionManager

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:p="http://www.springframework.org/schema/p"
       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.5.xsd
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
    <bean  class="org.springframework.web.servlet.view.InternalResourceViewResolver"  p:prefix="/"   p:suffix=".jsp" />
    <bean id="paramMethodResolver" p:paramName="action" class="org.springframework.web.servlet.mvc.multiaction.ParameterMethodNameResolver"/>
    <bean id="sessionFactory1"  class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="configLocation"  value="classpath:hibernate.cfg.xml"/>
    </bean>
    <bean id="sessionFactory2"  class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="configLocation"  value="classpath:hibernate5.cfg.xml"/>
    </bean>
    <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
        <property name="sessionFactory" ref="sessionFactory1"/>
    </bean>
    <bean id="hibernateTemplate2" class="org.springframework.orm.hibernate3.HibernateTemplate">
        <property name="sessionFactory" ref="sessionFactory2"/>
    </bean>  
    <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory1"/>
    </bean>
    <!-- <tx:annotation-driven transaction-manager="transactionManager"/>
    -->
   
    <!-- 定义事务通知 --> 
    <tx:advice id="txAdvice" transaction-manager="transactionManager"> 
        <!-- 定义方法的过滤规则 --> 
        <tx:attributes> 
            <!-- 所有方法都使用事务 --> 
            <tx:method name="*" propagation="REQUIRED"/> 
            <!-- 定义所有get开头的方法都是只读的 --> 
            <tx:method name="get*" read-only="true"/> 
        </tx:attributes> 
    </tx:advice>
   
    <!-- 定义AOP配置 --> 
    <aop:config>
        <!-- 定义一个切入点
       任意公共方法的执行:
execution(public * *(..))
任何一个以“set”开始的方法的执行:
execution(* set*(..))
AccountService 接口的任意方法的执行:
execution(* com.xyz.service.AccountService.*(..))
定义在service包里的任意方法的执行:
execution(* com.xyz.service.*.*(..))
定义在service包和所有子包里的任意类的任意方法的执行:
execution(* com.xyz.service..*.*(..))
定义在pointcutexp包和所有子包里的JoinPointObjP2类的任意方法的执行:
execution(* com.test.spring.aop.pointcutexp..JoinPointObjP2.*(..))")

        --> 
        <aop:pointcut expression="execution (* com.service.*.*(..))" id="services"/> 
        <!-- 对切入点和事务的通知,进行适配 --> 
        <aop:advisor advice-ref="txAdvice" pointcut-ref="services"/> 
    </aop:config> 

    <bean name="allDao" class="com.dao.AlloyspecDao" > 
        <property name="sessionFactory" ref="sessionFactory1"/>
    </bean>
    <bean name="bomDao" class="com.dao.BomproductDao" > 
        <property name="sessionFactory" ref="sessionFactory1"/>
    </bean>

    <bean  id="tservice"  class="com.service.Tservice" > 
        <property name="allDao" ref="allDao"/>
        <property name="bomDao" ref="bomDao"/>
    </bean>  

    <bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping">
        <property name="caseSensitive" value="false" />
    </bean>  
 <!-- <a href="newsimpleform/index.do?action=update">sdfdsf</a>-->
    <bean  id="newsfct"  class="comController.NewSimpleFormController" >
        <property name="methodNameResolver">
            <ref bean="paramMethodResolver"/>
        </property>
        <property name="tserice" ref="tservice"/>
    </bean>
    <bean  class="comController.LoginController"  /> 
</beans>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值