java 静态代理

interface clothFactory{
    void productCloth();
}

class NikeClothFactory implements clothFactory{

    @Override
    public void productCloth() {
        System.out.println("Nike生产了衣服");
    }
}


class ProxyClothFactory implements clothFactory{
    NikeClothFactory nc;

    public ProxyClothFactory (NikeClothFactory obj){
        this.nc=obj;
    }

    @Override
    public void productCloth() {
        System.out.println("通过了静态代理");
         nc.productCloth();

    }
}


public class TestStaticProxy {

    public static void main(String[] args) {
        NikeClothFactory  nf1 = new NikeClothFactory();
        nf1.productCloth();

        ProxyClothFactory nf2 = new ProxyClothFactory(nf1);
        nf2.productCloth();

    }
}
原文地址:https://www.cnblogs.com/MagicAsa/p/11745844.html