/** * Created by OneCoder on 2014/11/24. */ public class HouseOwner implements ISellHouse { @Override public void sellHouse() { System.out.println("Sell my house.") ; } } /** * Created by OneCoder on 2014/11/24. */ public class HouseProxy implements ISellHouse { private ISellHouse seller; public HouseProxy(ISellHouse seller) { this.seller = seller ; } @Override public void sellHouse() { System.out.println("Proxy: Publish the information."); System. out.println("Proxy: Contact the buyer."); seller.sellHouse(); System. out.println("Proxy: Get commision."); } }
原文地址:乱学设计模式——代理模式, 感谢原作者分享。