标签:
静态代理:
1 public interface Subject 2 { 3 public void doSomething(); 4 }
1 public class RealSubject implements Subject 2 { 3 public void doSomething() 4 { 5 System.out.println( "call doSomething()" ); 6 } 7 }
1 public class SubjectProxy implements Subject 2 { 3 Subject subimpl = new RealSubject(); 4 public void doSomething() 5 { 6 subimpl.doSomething(); 7 } 8 }
1 public class TestProxy 2 { 3 public static void main(String args[]) 4 { 5 Subject sub = new SubjectProxy(); 6 sub.doSomething(); 7 } 8 }
标签:
原文地址:http://www.cnblogs.com/xh0102/p/5686071.html