目次 > 第2章 Server(Rich)版チュートリアル > 2.4 データベースアクセス > 2.4.4 トランザクションの設定

2.4.4 トランザクションの設定

本項では、トランザクションの設定方法について説明する。

手順

本項では以下の作業が必要になる。

(1) AOPのSpring設定ファイルの編集

  1. “terasoluna-spring-rich-blank/webapps/WEB-INF/commonContext.xml”を開き、以下のように編集する。
    ・・・略・・・
    
    <!-- ======================================== トランザクション・AOP定義 -->
      <!-- AOPの定義 -->
      <!-- 
        下記で指定したパターンのBeanに対してインタセプタを適用する。
        BLogicからデータベースアクセスを行う場合は、下記のコメントアウトを解除して
        BLogicに対するトランザクションの設定を有効にする。
       -->
    
      <aop:config>
        <aop:pointcut id="serviceBeans" expression="bean(*Service)"/>
        <aop:pointcut id="blogicBeans"  expression="bean(*BLogic)"/>
        <aop:advisor 
             pointcut-ref="serviceBeans" 
             advice-ref="transactionInterceptor"/>
        <aop:advisor 
             pointcut-ref="blogicBeans" 
             advice-ref="transactionInterceptor"/>
      </aop:config>
    
    </beans>
    

ここで、AOPでトランザクションをかける対象とするBeanのBean定義IDを指定する。上記の設定では、Bean定義IDの接尾辞が「BLogic」「Service」のBeanに対して適用している。


次項:2.4.5 動作確認

Copyright (C) 2009 NTT DATA CORPORATION