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

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

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

    posts - 431,  comments - 344,  trackbacks - 0

    1.   捕獲對構造函數的調用
           pointcut <pointcut name>(<any values to be picked up>) : call(<optional modifier> <class>.new(<parameter types>));

    2.   在執行構造函數時捕獲它
          pointcut <pointcut name>(<any values to be picked up>) : execution(<optional modifier> <class>.new(<parameter types>));

    3.   捕獲何時初始化對象
          pointcut <pointcut name>(<any values to be picked up>) : initialization(<optional modifier> <class>.new(<parameter types>));
          initialization(Signature)切入點必須包含new關鍵字,Signature必須解析成特定類的構造函數,而不是一個簡單的方法。
          由于AspectJ編譯器中的編譯器限制,當與around()通知關聯時,不能使用initialization(Signature)切入點。
          與execution(Signature)切入點相比,使用initialization(Signature)切入點最大優點是:它提供了編譯時檢查,以確保簽名實際上制定了一個構造函數。

    4.   捕獲何時將要初始化一個對象
          pointcut <pointcut name>(<any values to be picked up>) : preinitialization(<optional modifier> <class>.new(<parameter types>));

    5.   捕獲何時初始化類
          
    pointcut <pointcut name>(<any values to be picked up>) : staticinitialization(<class>);


    package com.eric.aspectj;

    public aspect CallNewRecipe {
     pointcut myClassConstructorWithIntAndStringPointcutStaticinitialization() : staticinitialization(MyClass);
     pointcut myClassConstructorWithIntAndStringPointcutCall() : call(MyClass.new(int, String));
     pointcut myClassConstructorWithIntAndStringPointcutExecution() : execution(MyClass.new(int, String));
     pointcut myClassConstructorWithIntAndStringPointcutPreinitialization() : preinitialization(MyClass.new(int, String));
     pointcut myClassConstructorWithIntAndStringPointcutInitialization() : initialization(MyClass.new(int, String));
     
     
     before() : myClassConstructorWithIntAndStringPointcutExecution() {
      System.out.println("-------------- Aspect Advice Logic Execution ---------------");
      System.out.println("In the advice picked by " + "myClassConstructorWithIntAndOthersPointcut()");
      System.out.println("The current type of object under construction is: ");
      System.out.println("getThis: " + thisJoinPoint.getThis());
      System.out.println("getTarget: " + thisJoinPoint.getTarget());
      System.out.println("getKind: " + thisJoinPoint.getKind());
      System.out.println("Signature: " + thisJoinPoint.getSignature());
      System.out.println("getName: " + thisJoinPoint.getSignature().getName());
      System.out.println("getDeclaringTypeName: " + thisJoinPoint.getSignature().getDeclaringTypeName());
      System.out.println("getDeclaringType: " + thisJoinPoint.getSignature().getDeclaringType());
      System.out.println("getModifiers: " + thisJoinPoint.getSignature().getModifiers());
      System.out.println("Source Line: " + thisJoinPoint.getSourceLocation());
      System.out.println("toString: " + thisJoinPoint.toString());
      System.out.println("--------------------------------------------------");
     }
     before() : myClassConstructorWithIntAndStringPointcutStaticinitialization() {
      System.out.println("--------------- Staticinitialization ------------------");
     }
     before() : myClassConstructorWithIntAndStringPointcutCall() {
      System.out.println("--------------- Call ------------------");
     }
     before() : myClassConstructorWithIntAndStringPointcutPreinitialization() {
      System.out.println("--------------- Preinitialization ------------------");
     }
     before() : myClassConstructorWithIntAndStringPointcutInitialization() {
      System.out.println("--------------- Initialization ------------------");
     }
    }

    package com.eric.aspectj;

    public class MyClass {

     private int number;
     private String name;
     
     public MyClass(int number, String name) {
      this.number = number;
      this.name = name;
     }
     /**
      * @param args
      */
     public static void main(String[] args) {
      // TODO Auto-generated method stub
      MyClass myObject = new MyClass(123, "Eric Chau");
     }

    }

    運行結果:
    --------------- Staticinitialization ------------------
    --------------- Call ------------------
    --------------- Preinitialization ------------------
    --------------- Initialization ------------------
    -------------- Aspect Advice Logic Execution ---------------
    In the advice picked by myClassConstructorWithIntAndOthersPointcut()
    The current type of object under construction is:
    getThis: com.eric.aspectj.MyClass@10d448
    getTarget: com.eric.aspectj.MyClass@10d448
    getKind: constructor-execution
    Signature: com.eric.aspectj.MyClass(int, String)
    getName: <init>
    getDeclaringTypeName: com.eric.aspectj.MyClass
    getDeclaringType: class com.eric.aspectj.MyClass
    getModifiers: 1
    Source Line: MyClass.java:8
    toString: execution(com.eric.aspectj.MyClass(int, String))
    --------------------------------------------------

    posted on 2007-07-04 13:56 周銳 閱讀(255) 評論(0)  編輯  收藏 所屬分類: AspectJ
    主站蜘蛛池模板: 亚洲成AV人片在线观看WWW| yy6080久久亚洲精品| 亚洲人成色777777精品| 98精品全国免费观看视频| 久久久久亚洲av无码尤物| 男人都懂www深夜免费网站| 亚洲国产精品特色大片观看完整版| 精品国产免费一区二区三区| 成全视频免费观看在线看| 成在人线AV无码免费| 亚洲AV日韩精品久久久久| 日韩免费高清大片在线| 久久国产精品亚洲综合| 最近中文字幕无免费| a级亚洲片精品久久久久久久| 中文字幕亚洲情99在线| 国产精品视_精品国产免费| 美女视频黄a视频全免费网站色 | 亚洲天堂电影在线观看| 成人免费观看一区二区| 亚洲精品无码你懂的| 亚洲一级片内射网站在线观看| 99免费精品视频| 亚洲国产成AV人天堂无码| a级毛片免费完整视频| 亚洲国产成人久久综合一 | 亚洲AV成人一区二区三区观看 | 国产成人免费网站在线观看| 黄网站色成年片大免费高清 | 亚洲字幕AV一区二区三区四区| 日韩一区二区免费视频| 亚洲精品偷拍视频免费观看| 久久噜噜噜久久亚洲va久| 国内精品乱码卡1卡2卡3免费| 另类图片亚洲校园小说区| 精品免费久久久久久成人影院| 一级毛片免费在线观看网站| 亚洲高清美女一区二区三区| 国产成人高清精品免费鸭子| 日本高清免费观看| 亚洲男同gay片|