标签:super ring com 设计模式 eal conf 分享 blog 模式
staticproxy ---静态代理
package com.bjsxt.proxy.staticProxy; public interface Star { /** * 面谈 */ void confer(); /** * 签合同 */ void signContract(); /** * 订票 */ void bookTicket(); /** * 唱歌 */ void sing(); /** * 收钱 */ void collectMoney(); }
package com.bjsxt.proxy.staticProxy; public class RealStar implements Star { @Override public void bookTicket() { System.out.println("RealStar.bookTicket()"); } @Override public void collectMoney() { System.out.println("RealStar.collectMoney()"); } @Override public void confer() { System.out.println("RealStar.confer()"); } @Override public void signContract() { System.out.println("RealStar.signContract()"); } @Override public void sing() { System.out.println("RealStar(周杰伦本人).sing()"); } }
package com.bjsxt.proxy.staticProxy; public class ProxyStar implements Star { private Star star; public ProxyStar(Star star) { super(); this.star = star; } @Override public void bookTicket() { System.out.println("ProxyStar.bookTicket()"); } @Override public void collectMoney() { System.out.println("ProxyStar.collectMoney()"); } @Override public void confer() { System.out.println("ProxyStar.confer()"); } @Override public void signContract() { System.out.println("ProxyStar.signContract()"); } @Override public void sing() { star.sing(); } }
package com.bjsxt.proxy.staticProxy; public class Client { public static void main(String[] args) { Star real = new RealStar(); Star proxy = new ProxyStar(real); proxy.confer(); proxy.signContract(); proxy.bookTicket(); proxy.sing(); proxy.collectMoney(); } }
dynamicproxy动态代理
标签:super ring com 设计模式 eal conf 分享 blog 模式
原文地址:http://www.cnblogs.com/ou-pc/p/7668206.html