标签:代理类 request rri 访问 定义 bst 模式 als 静态代理
public abstract class Subject { public abstract void request(); }
public class RealSubject extends Subject{ @Override public void request() { System.out.println("realSub"); } }
public class Proxy extends Subject{ Subject mRealSubject; @Override public void request(){ if (mRealSubject != null){ System.out.println("Proxy request"); mRealSubject.request(); } } public Proxy(Subject mRealSubject) { this.mRealSubject = mRealSubject; } }
public class Client { public static void main(String[] args){ Subject realSubject = new RealSubject(); Subject proxy = new Proxy(realSubject); proxy.request(); } }
标签:代理类 request rri 访问 定义 bst 模式 als 静态代理
原文地址:https://www.cnblogs.com/endian11/p/9139354.html