论坛首页 Java企业应用论坛

Spring 事务简化配置

浏览 67731 次
该帖已经被评为精华帖
作者 正文
   发表时间:2006-04-04  
如果想PROPAGATION_REQUIRED,readOnly,写了接口也不方便,支持feiing
0 请登录后投票
   发表时间:2006-04-07  
autowire="byName" 不是必需的吧
0 请登录后投票
   发表时间:2006-04-07  
autowire="byName"会自动根据你的属性的名字帮你注入你要的bean,要不就要手动写明。
0 请登录后投票
   发表时间:2007-01-25  
Feiing 写道
呵呵, 想不到大家反响这么激烈, 我说一下自己的想法
3. 说到事务控制, 其实我的项目是放在 Action 做的, 可能要被鄙视了, 我们用 xwork Interceptor 实现, 再加上 webwork
   <default-interceptor-ref name="defaultStack" /> 的功能, 基本上完全不用再管事务, 当然策略只能是 PROPAGATION_REQUIRED 了


不是有意挖坟,确实有问题想交流。

为了尽量使接口简洁点,尝试把事务放在action中 (webwork),但是对action外面包一层事务处理后,action就不能用了,现在想到的也是自己做个拦截器,所有的方法都是 PROPAGATION_REQUIRED ,总觉得不太好,不知道有没有人有在action中处理事务的经验给介绍下。
0 请登录后投票
   发表时间:2007-01-31  
<!-- 
     增加新的 Interceptor 
--> 

请问这个是用来干什么的?
0 请登录后投票
   发表时间:2007-01-31  
<bean
class="org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor">
<property name="transactionInterceptor"
ref="transactionInterceptor" />
</bean>

是多余的吧?
0 请登录后投票
   发表时间:2007-01-31  
xml 代码
  1. <bean  
  2.         class="org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor">  
  3.         <property name="transactionInterceptor"  
  4.             ref="transactionInterceptor" />  
  5.     </bean>  

是多余的吧?
0 请登录后投票
   发表时间:2007-02-01  
<bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">   
                <property name="beanNames"> 
                    <value>*Service,*Manager</value> 
                </property> 
                <property name="interceptorNames">   
                        <list>   
                                <value>transactionInterceptor</value>   
                                <!--  
                                此处增加新的Interceptor 
                                -->   
                        </list>   
                </property>   
        </bean>   
其实你只是这儿<value>*Service,*Manager</value> 用了通配符而已
0 请登录后投票
   发表时间:2007-02-02  
org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor

这个起到什么用处
0 请登录后投票
   发表时间:2007-02-03  
    <aop:config>
        
        <aop:advisor id="managerTx" advice-ref="txAdvice" pointcut="execution(* *..service.*Manager.*(..))" order="2"/>
    </aop:config>
   
    <tx:advice id="txAdvice">
        <tx:attributes>
            <tx:method name="get*" read-only="true"/>
            <tx:method name="*"/>
        </tx:attributes>
    </tx:advice>

上面是appfuse里的,我觉得比LZ的要简洁点
下面的service也好配置

<bean id="roleManager" class="org.appfuse.service.impl.RoleManagerImpl">
        <property name="roleDao" ref="roleDao"/>
    </bean>
这样就可以了

0 请登录后投票
论坛首页 Java企业应用版

跳转论坛:
Global site tag (gtag.js) - Google Analytics