标签:err inter out ace 技术 info sys 类的方法 src
package day19;
interface ClothFactory{
public void show();
}
//被代理类;
class NikeFactory implements ClothFactory{
@Override
public void show() {
// TODO Auto-generated method stub
System.out.println("生产Nike衣服的工厂!");
}
}
//代理类;
class ProxyFactory implements ClothFactory{
private ClothFactory factory ;
public ProxyFactory(ClothFactory factory) {
super();
this.factory = factory;
}
@Override
public void show() {
// TODO Auto-generated method stub
factory.show(); //调用真正的被代理类的方法;
}
}
public class StaticProxy {
public static void main(String[] args) {
NikeFactory realFactory = new NikeFactory();
ProxyFactory proxyFactory = new ProxyFactory(realFactory);
proxyFactory.show();//实际是调用了NikeFactory的方法;
}
}
标签:err inter out ace 技术 info sys 类的方法 src
原文地址:https://www.cnblogs.com/SnailsRunning/p/10256604.html