标签:class bsp sys out 模式 enum 其他 ring art
为其他对象提供一种代理以控制对这个对象的访问
public class TestProxy {
public static void main(String[] args) {
Object obj = new ProxyObject();
obj.action();
}
}
interface Object {
void action();
}
class ProxyObject implements Object {
Object obj;
public ProxyObject() {
System.out.println("Creat ProxyObject");
obj = new ObjectImpl();
}
@Override
public void action() {
System.out.println("ProxyObject start");
obj.action();
System.out.println("ProxyObject end");
}
}
class ObjectImpl implements Object {
@Override
public void action() {
System.out.println("=====ObjectImpl start=====");
System.out.println("=====ObjectImpl doing=====");
System.out.println("=====ObjectImpl end=====");
}
}
标签:class bsp sys out 模式 enum 其他 ring art
原文地址:http://www.cnblogs.com/chendifan/p/6535601.html