代理对象 商家
public interface IIBM {
public void sell();
}
public class IBM implements IIBM{
public void sell() {
System.out.println("sell a goods !");
}
}
public static void main(String[] args) {
IIBM i =(IIBM) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),
new Class[]{IIBM.class}, new InvocationHandler() {
public Object invoke(Object proxy, Method method,
Object[] args) throws Throwable {
IIBM i = new IBM();
System.out.println("sss .");
i.sell();
return i;
}
});
i.sell();
}