夢之天堂

          我學故我知,我思故我在;java你我,happy你我——sylilzy

          BlogJava 首頁 新隨筆 聯系 聚合 管理
            3 Posts :: 8 Stories :: 2 Comments :: 0 Trackbacks
          spring的事務處理詳解:調用一個方法后的事務處理過程
          ?
          sylilzy@163.com
          版權所有,轉載請注明出處
          ?
          spring調用一個方法后的事務處理過程:
          參照TransactionInterceptor的invoke方法:
          ?1 try ? {
          ?2 ??? // ?This?is?an?around?advice.
          ?3 ??? // ?Invoke?the?next?interceptor?in?the?chain.
          ?4 ??? // ?This?will?normally?result?in?a?target?object?being?invoked.
          ?5 ???retVal? = ?invocation.proceed();
          ?6 ??}

          ?7 ?? catch ?(Throwable?ex)? {
          ?8 ??? // ?target?invocation?exception
          ?9 ???doCloseTransactionAfterThrowing(txInfo,?ex);
          10 ??? throw ?ex;
          11 ??}

          12 ?? finally ? {
          13 ???doFinally(txInfo);
          14 ??}

          15 ??doCommitTransactionAfterReturning(txInfo);
          16 ?? return ?retVal;
          17 ?}
          ?
          調用目標方法時沒有拋出異常時會調用:
          doCommitTransactionAfterReturning(txInfo);
          然后直接提交事務
          ?
          如果拋異常則檢查是否需要回滾事務(doCloseTransactionAfterThrowing方法會根據在spring中設備的Transaction Attribute),否則提交事務.

          參考資料:
          1.Spring Reference Manual:http://static.springframework.org/spring/docs/1.2.x/reference/index.html
          2.Spring API doc:http://static.springframework.org/spring/docs/1.2.x/api/index.html
          3.Spring 的源代碼

          作者簡介:
          ????施祖陽,網名sylilzy,1979年生。
          ????2002年起從事軟件開發工作,主要研究為JAVA、Linux及相關技術。
          ????你可通過 sylilzy@163.com 與作者聯系。
          posted on 2006-06-14 18:34 sylilzy 閱讀(352) 評論(0)  編輯  收藏 所屬分類: Java
          主站蜘蛛池模板: 德庆县| 南溪县| 曲靖市| 沂南县| 广宁县| 奉贤区| 泌阳县| 格尔木市| 车致| 石台县| 天气| 宝清县| 海南省| 深水埗区| 益阳市| 剑阁县| 贵阳市| 保靖县| 崇仁县| 天津市| 沈阳市| 乐亭县| 贵州省| 连江县| 承德市| 元朗区| 剑阁县| 铁岭市| 锡林郭勒盟| 永修县| 石河子市| 富顺县| 花莲市| 涡阳县| 曲水县| 宁波市| 临沂市| 阿拉善右旗| 喀什市| 乐东| 客服|