标签:rgba print his server mic mamicode color ace div
1.代理模式的定义
2. 代理模式举例
public class NetWorkTest { public static void main(String[] args) { Server server = new Server(); ProxyServer proxyServer = new ProxyServer(server);
//虽然调用的是 proxyServer.browse() , 但是Server.browse()也执行了 proxyServer.browse(); } } //定义接口 interface NetWork { public void browse(); } //被代理类 class Server implements NetWork { @Override public void browse() { System.out.println("服务器访问网络"); } } //代理类 class ProxyServer implements NetWork { private NetWork work; public ProxyServer(NetWork work) { this.work = work; } public void check() { System.out.println("联网之前的检查工作"); } @Override public void browse() { check(); work.browse(); } }
标签:rgba print his server mic mamicode color ace div
原文地址:https://www.cnblogs.com/Anonymity-zhang/p/14307240.html