posts - 165, comments - 198, trackbacks - 0, articles - 1
  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

AOP 学习笔记

Posted on 2007-10-18 18:16 G_G 阅读(1583) 评论(3)  编辑  收藏 所属分类: AOP
如有错误大家多指教

1.call(* *(..)) 和 execution(* *(..)) 区别
 
call 和 execution 都为切面限定
  execution 进行切面添加只能在方法定义的开始和结束。如:
   >>>AOP 添加
      public String getName(){
          System.out.println("G_G");
        return this.name ;
    }
   >>>AOP 添加
  call进行切面添加没有限定。如:
    >>>AOP 添加
      public String getName(){
          >>>AOP 添加
          System.out.println("G_G");
          >>>AOP 添加
        return this.name ;
    }
   >>>AOP 添加

     2.this within区别
   都为范围限定作用,如: within(Demo) && execution( * *(..)) 在类Demo中的所有..
   区别是:this不能切静态,within没有

 3.cflow的作用

  我们从 1>cflow( within(DD+) && execution( * *(..)) )

         2>within(DD+) && execution( * *(..)) 的区别来看
  1与2的对比是在2的切入点下再加 aj 文件的方法 进行添加切入点。

4.方法添加
  如:Introduction Example例中的 CloneablePoint.aj
     Point类继承Clonable 添加
clone() 方法
   declare parents: Point implements Cloneable;

   
public Object Point.clone() throws CloneNotSupportedException {
      
return super.clone();
   }

   point.clone()....




  



评论

# re: AOP 学习笔记  回复  更多评论   

2007-10-18 18:16 by G_G
我会边学习边记录的

# re: AOP 学习笔记  回复  更多评论   

2007-10-20 02:01 by bigboy
好的!继续坚持!

# re: AOP 学习笔记  回复  更多评论   

2007-11-22 19:33 by 专注JAVA开源

http://www.agilesource.org/column_1_1.html

这个地方很多不错的JAVA AOP资料。

只有注册用户登录后才能发表评论。


网站导航: