afrag  
          記錄學(xué)習(xí)和成長(zhǎng)的歷程
          日歷
          <2005年11月>
          303112345
          6789101112
          13141516171819
          20212223242526
          27282930123
          45678910
          統(tǒng)計(jì)
          • 隨筆 - 9
          • 文章 - 5
          • 評(píng)論 - 2
          • 引用 - 0

          導(dǎo)航

          常用鏈接

          留言簿

          隨筆分類

          隨筆檔案

          文章檔案

          搜索

          •  

          積分與排名

          • 積分 - 10198
          • 排名 - 2381

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

           

          在Spring 的AOP中,如果一個(gè)Proxy同時(shí)實(shí)現(xiàn)MethodBeforeAdvice、AfterReturningAdvice和MethodInterceptor接口,那么這三個(gè)Advice的執(zhí)行順序是什么樣的呢?
          經(jīng)過(guò)試驗(yàn),是和xml文件中的定義順序有關(guān)的。
          如果Proxy的接口實(shí)現(xiàn)定義為
          ?????
          ?????????
          ??????????? MethodBeforeAdvice
          ??????????? AfterReturningAdvice
          ??????????? MethodInterceptor
          ?????????

          ?????

          那么執(zhí)行的結(jié)果是
          MethodBeforeAdvice

          MethodInterceptor: before call

          Really method excuting

          MethodInterceptor: after call

          AfterReturningAdvice

          也就是說(shuō),執(zhí)行順序是:MethodBeforeAdvice,MethodInterceptor的調(diào)用前的部分,目標(biāo)方法,MethodInterceptor的調(diào)用后的部分,AfterReturningAdvice。

          如果proxy的定義是
          ?????
          ?????????
          ??????????? MethodBeforeAdvice
          ??????????? MethodInterceptor
          ??????????? AfterReturningAdvice
          ?????????

          ?????

          執(zhí)行的結(jié)果是
          MethodBeforeAdvice

          MethodInterceptor: before call

          Really method excuting

          AfterReturningAdvice

          MethodInterceptor: after call
          也就是說(shuō),執(zhí)行的順序是:MethodBeforeAdvice,MethodInterceptor的調(diào)用前的部分,目標(biāo)方法,AfterReturningAdvice,MethodInterceptor的調(diào)用后的部分。

          如果proxy的定義是
          ?????
          ?????????
          ??????????? MethodInterceptor
          ??????????? MethodBeforeAdvice
          ??????????? AfterReturningAdvice
          ?????????

          ?????

          執(zhí)行的結(jié)果是:
          MethodInterceptor: before call

          MethodBeforeAdvice

          Really method excuting

          AfterReturningAdvice

          MethodInterceptor: after call
          也就是說(shuō),執(zhí)行的順序是:MethodInterceptor的調(diào)用前的部分,MethodBeforeAdvice,目標(biāo)方法,AfterReturningAdvice,MethodInterceptor的調(diào)用后的部分。
          以上的順序是在springframework 1.2.5中測(cè)試的。

          posted on 2005-11-02 18:10 afrag 閱讀(3721) 評(píng)論(1)  編輯  收藏 所屬分類: Java隨想
          評(píng)論:
          • # re: Spring AOP中MethodBeforeAdvice、AfterReturningAdvice和MethodInterceptor的執(zhí)行順序  jadmin Posted @ 2009-08-29 00:33
            是這樣的嗎?  回復(fù)  更多評(píng)論   

           
          Copyright © afrag Powered by: 博客園 模板提供:滬江博客
          主站蜘蛛池模板: 高唐县| 吴桥县| 阿克| 定安县| 壶关县| 花莲市| 玉田县| 通渭县| 太白县| 克东县| 彭水| 临湘市| 三江| 绥化市| 来宾市| 新竹市| 嘉善县| 福建省| 巩义市| 通海县| 湘西| 榆林市| 井研县| 安乡县| 乐安县| 万安县| 卫辉市| 霞浦县| 淮北市| 营口市| 乌兰浩特市| 贡嘎县| 兴义市| 滕州市| 台南县| 廉江市| 吉安县| 韩城市| 金寨县| 纳雍县| 石景山区|