2011-05-13 2 views
0

나는 프로젝트를 업그레이드하려고하고있어 거래를하기 위해왔다. 이것이 내가 지금까지 한 일이다. 서비스를 봄에서 특정 txAdvice를 사용하는 방법?

<bean id="userServiceTarget" class="com.forgin.service.UserServiceImpl"> 
    <property name="userDAO" ref="userDAO" /> 
</bean> 

<bean id="userService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"> 
     <property name="target" ref="userServiceTarget" /> 
     <property name="transactionManager" ref="transactionManager" /> 
     <property name="transactionAttributes"> 
      <props> 
       <prop key="get*">PROPAGATION_SUPPORTS</prop> 
       <prop key="is*">PROPAGATION_SUPPORTS</prop> 
       <prop key="save*">PROPAGATION_REQUIRED</prop> 
       <prop key="remove*">PROPAGATION_REQUIRED</prop> 
      </props> 
     </property> 
</bean> 

나는 트랜잭션이 울부 짖는 소리와 같은 속성을 변경,하지만 난 정확히 txAdvice와 서비스를 연결할 수있는 방법을 아주 확실하지 않다. 왜냐하면 나는 일반적으로 다른 서비스에 대해 서로 다른 트랜잭션 속성을 가지고 있기 때문에 하나 이상의 txAdvice이되어야한다. 이 특정 txAdvice를 사용하여 @Transactional을 말하는 방법이 있습니까?

<tx:advice id="txAdvice"> 
    <tx:attributes> 
     <tx:method name="get*" read-only="true" /> 
     <tx:method name="is*" read-only="true" /> 
     <tx:method name="save*" propagation="REQUIRED" /> 
     <tx:method name="remove*" propagation="REQUIRED" /> 
    </tx:attributes> 
</tx:advice> 

답변

0

좋아요, 알아 냈습니다. 방금 나에게 왔습니다. 하하 .. 난 단지 aop:advisoraop:pointcut을 추가로 제공해야합니다. 저것과 같이 쉬운.

<aop:config> 
    <aop:pointcut id="userOperation" 
      expression="execution(* com.forgin.service.UserServiceImpl.*(..))" /> 
    <aop:advisor advice-ref="txAdvice" pointcut-ref="serviceOperation" /> 
     <aop:pointcut id="differentOperation" 
      expression="execution(* com.forgin.service.DifferentServiceImpl.*(..))" /> 
    <aop:advisor advice-ref="txAdviceDifferent" pointcut-ref="differentOperation" /> 
</aop:config> 
관련 문제