(String[] args)
| 3 | public class Client { |
| 4 | |
| 5 | public static void main(String[] args) { |
| 6 | //真实角色 |
| 7 | Host host = new Host(); |
| 8 | |
| 9 | //代理角色 |
| 10 | ProxyInvocation proxyInvocation = new ProxyInvocation(); |
| 11 | |
| 12 | //通过调用程序处理角色来处理我们要调用的接口对象 |
| 13 | proxyInvocation.setRent(host); |
| 14 | |
| 15 | Rent proxy = (Rent) proxyInvocation.getProxy(); //这里的proxy是动态生成的 |
| 16 | |
| 17 | proxy.rent(); |
| 18 | |
| 19 | } |
| 20 | |
| 21 | } |