interface Object

{

void action();

}

//代理类

class ProxyObject implements Object

{

Object obj;

public ProxyObject()

{

obj=new ObjectImpl();

System.out.Println("代理类创建成功");

 

}

public void action()

{

System.out.Println("代理类开始执行");

obj.action();

System.out.Println("代理类执行结束");

}

}

//被代理类

calss ObjectImpl implements Object

{

 

public void action()

{

System.out.println("=====被代理类开始执行======");
System.out.println("=====具体的操作======");
System.out.println("=====被代理类执行完毕======");

}

}

 

public class Test{

public statci void main(String[] args)

{

Object obj = new ProxyObject();
obj.action();

}

}

posted on 2017-05-11 23:09  为了八千块  阅读(108)  评论(0编辑  收藏  举报