<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)

    隨筆分類

    隨筆檔案

    收藏夾

    搜索

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 日本黄页网址在线看免费不卡| 免费无码又爽又刺激毛片| 羞羞的视频在线免费观看| 久久狠狠高潮亚洲精品| 中文字幕亚洲日韩无线码| 日韩免费一级毛片| 四虎免费影院ww4164h| 视频免费在线观看| yellow免费网站| 国产成人亚洲精品无码AV大片| 国产色在线|亚洲| 亚洲图片校园春色| 亚洲综合色一区二区三区小说| 亚洲AV无码一区二区二三区入口| 亚洲男人在线无码视频| 日韩在线免费电影| 毛片a级毛片免费观看免下载| 一区二区免费视频| 亚洲精品视频免费观看| 又黄又大的激情视频在线观看免费视频社区在线 | 亚洲成?v人片天堂网无码| 成人免费无码大片A毛片抽搐色欲| 91嫩草免费国产永久入口| 最近中文字幕2019高清免费| 国产羞羞的视频在线观看免费| 中国一级特黄的片子免费| 一级毛片免费不卡直观看| igao激情在线视频免费| h在线看免费视频网站男男| 一道本不卡免费视频| 好吊色永久免费视频大全| 一级日本高清视频免费观看| 九九全国免费视频| 九九免费精品视频在这里| 亚洲精品黄色视频在线观看免费资源 | 国产精品亚洲精品日韩电影| 国产综合成人亚洲区| 曰批免费视频播放在线看片二| 国产一区二区三区亚洲综合| 美女黄色毛片免费看| 一级成人a免费视频|