Posted on 2007-10-18 18:16
G_G 閱讀(1598)
評(píng)論(3) 編輯 收藏 所屬分類:
AOP
如有錯(cuò)誤大家多指教
1.call(* *(..)) 和 execution(* *(..)) 區(qū)別
? call 和 execution 都為切面限定
? execution 進(jìn)行切面添加只能在方法定義的開始和結(jié)束。如:
??
>>>AOP 添加? ??? public String getName(){
? ??? ??? System.out.println("G_G");
??? ??? return this.name ;
??? }
??
>>>AOP 添加? call進(jìn)行切面添加沒有限定。如:
???
>>>AOP 添加? ??? public String getName(){
????????? >>>AOP 添加? ??? ??? System.out.println("G_G");
?????????
>>>AOP 添加??? ??? return this.name ;
??? }
??
>>>AOP 添加
???? 2.this 和within的區(qū)別
?? 都為范圍限定作用,如: within(Demo) && execution( * *(..)) 在類Demo中的所有..
??
區(qū)別是:this不能切靜態(tài),within沒有
?3.cflow的作用
? 我們從 1>cflow( within(DD+) && execution( * *(..)) ) 和
???????? 2>within(DD+) && execution( * *(..)) 的區(qū)別來看
? 1與2的對(duì)比是在2的切入點(diǎn)下再加 aj 文件的方法 進(jìn)行添加切入點(diǎn)。
4.方法添加
? 如:Introduction Example例中的 CloneablePoint.aj
???? Point類繼承Clonable 添加 clone() 方法???declare?parents:?Point?implements?Cloneable;
???public?Object?Point.clone() throws?CloneNotSupportedException?{
??????return?super.clone();
???}
?? point.clone()....
??