<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    最愛Java

    書山有路勤為徑,學海無涯苦作舟

    《AspectJ Cookbook》讀書筆記十: 捕獲基于控制流程的連接點

        本章中描述的切入點支持捕獲另一個初始連接點作用域或環境內的所有連接點。每個連接點在程序的控制流程中都有一個具體位置,這為通過這里描述的切入點聲明捕獲的連接點提供了環境。
        一. 捕獲通過初始連接點開始的程序控制流程內的所有連接點
        使用cflow(Pointcut)切入點。cflow(Pointcut)切入點的語法如下:
        pointcut <pointcut name>(<any values to be picked up>) : cflow(<pointcut>);

        cflow(Pointcut)切入點具有3個關鍵特征:
            1.cflow(Pointcut)切入點捕獲在初始特定的連接點環境內遇到的所有連接點,這個初始連接點是通過另一個切入點選擇的。
            2.捕獲的連接點包括初始連接點。
            3.作用域是cflow(pointcut)切入點中重要的鑒別器。這個切入點將捕獲通過切入點參數捕獲的連接點的控制流程內的所有連接點。


    package com.aspectj;

    public aspect CFlowRecipe {
        
    /**
         * Specifies calling advice whenever a method
         * matching the following rules gets called:
         * 
         * Class Name:MyClass
         * Method Name:foo
         * Method Return Type:void
         * Method Parameters: an int followed by a String
         
    */

        pointcut callInitialPointcut():call(
    void MyClass.foo(int,String));
        
        
    /**
         * Specifies calling advice whenever a join point is encountered
         * including and after the initial join point triggers the pointcut
         * that is specified in the parameter:
         * 
         * Pointcut Name:callInitialPointcut
         
    */

        pointcut cflowPointcut():cflow(callInitialPointcut());
        
        
    //Advice declaration
        before() : cflowPointcut() && !within(CFlowRecipe+{
            System.out.println(
    "---------- Aspect Advice Logic ----------");
            System.out.println(
    "In the advice picked by CFlowRecipe()");
            System.out.println(
    "Join Point Kind: " + thisJoinPoint.getKind());
            System.out.println(
    "Signature: " + thisJoinPoint.getStaticPart().getSignature());
            System.out.println(
    "Source Line: " + thisJoinPoint.getStaticPart().getSourceLocation());
            System.out.println(
    "-----------------------------------------");
        }
        
        

    }



            值得更詳細研究cflow(Pointcut)做什么。這個特殊的切入點引入了連接點環境的概念。它是指每個連接點具有一個作用域,在這個用途域內,它被看成是執行程序的控制流程的一部分。
            在這個控制流程內,任何遇到的連接點都會觸發cflow(Pointcut)切入點,并調用任何關聯的通知。當初始連接點觸發指定的切入點參數時,cflow(Pointcut)切入點會起作用,并觸發其關聯的通知。然后,將為在初始連接點環境內的控制流程中遇到的每個連接點調用與cflow(Pointcut)關聯的通知。最后,捕獲的連接點集合包括初始連接點本身,這就是這個切入點與cflowbelow(Pointcut)切入點之間的主要區別。

            在cflow(Pointcut)的當前實現中,在使用它時,其實現方式會引入大量的系統開銷。在可能的地方,并且連接點重用不受影響時,可以考慮優先使用withincode(Signature)切入點。

        二.捕獲程序控制流程內的所有連接點,不包括初始連接點
        使用cflowbelow(Pointcut)切入點。cflowbelow(Pointcut)切入點的語法如下:
        pointcut <pointcut name>(<any values to be picked up>) : cflowbelow(<pointcut>);


    package com.aspectj;

    public aspect CFlowBelowRecipe {
        
    /**
         * Specifies calling advice whenever a method
         * matching the following rules gets called:
         * 
         * Class Name:MyClass
         * Method Name:foo
         * Method Return Type:void
         * Method Parameters: an int followed by a String
         
    */

        pointcut callInitialPointcut():call(
    void MyClass.foo(int,String));
        
        
    /**
         * Specifies calling advice whenever a join point is encountered
         * after the initial join point triggers the pointcut
         * that is specified in the parameter:
         * 
         * Pointcut Name:callInitialPointcut
         
    */

        pointcut cflowPointcut():cflowbelow(callInitialPointcut());
        
        
    //Advice declaration
        before() : cflowPointcut() && !within(CFlowBelowRecipe+{
            System.out.println(
    "---------- Aspect Advice Logic ----------");
            System.out.println(
    "In the advice picked by CFlowBelowRecipe()");
            System.out.println(
    "Join Point Kind: " + thisJoinPoint.getKind());
            System.out.println(
    "Signature: " + thisJoinPoint.getStaticPart().getSignature());
            System.out.println(
    "Source Line: " + thisJoinPoint.getStaticPart().getSourceLocation());
            System.out.println(
    "-----------------------------------------");
        }
        
        

    }



        這里和第一部分介紹的內容有點區別;其區別是實際捕獲的連接點數量。cflow(Pointcut)切入點會觸發在初始連接點環境內遇到的所有連接點(包括初始連接點)上的通知,而cflowbelow(Pointcut)切入點則不包括那個初始連接點。

    posted on 2008-08-25 10:36 Brian 閱讀(421) 評論(0)  編輯  收藏 所屬分類: 《AspectJ Cookbook》讀書筆記

    公告


    導航

    <2008年8月>
    272829303112
    3456789
    10111213141516
    17181920212223
    24252627282930
    31123456

    統計

    常用鏈接

    留言簿(4)

    隨筆分類

    隨筆檔案

    收藏夾

    搜索

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 成人婷婷网色偷偷亚洲男人的天堂 | 午夜视频免费成人| 亚洲国产精品综合久久20| 131美女爱做免费毛片| 亚洲麻豆精品果冻传媒| 日本亚洲免费无线码| 亚洲综合国产成人丁香五月激情| 无码av免费毛片一区二区| 精品国产成人亚洲午夜福利| 在线播放免费播放av片| 青青青亚洲精品国产| 亚洲国产精品综合久久一线| 一级特黄录像视频免费| 国产日韩亚洲大尺度高清| 久久aa毛片免费播放嗯啊| 亚洲国产精品人久久电影| 免费网站看v片在线香蕉| 在线观看亚洲精品专区| 在线观看国产区亚洲一区成人| 免费av片在线观看网站| 亚洲美女激情视频| 日本一区免费电影| 中文字幕无线码免费人妻| 亚洲小视频在线观看| 妞干网免费观看视频| 一级特黄aaa大片免费看| 内射少妇36P亚洲区| 午夜毛片不卡高清免费| 中文字幕乱码系列免费| 亚洲国产综合第一精品小说| 午夜国产大片免费观看| 久久国产精品成人免费| 亚洲欧美日韩久久精品| 亚洲乱亚洲乱妇无码麻豆| 亚洲国产精品免费观看| 春意影院午夜爽爽爽免费| 亚洲日本在线观看网址| 亚洲国产精品成人一区| 噼里啪啦免费观看高清动漫4| 免费人成视频在线播放| 亚洲欧洲日产国码www|