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();

    }
}

 

posted @ 2019-10-26 22:14  MagicAsa  阅读(101)  评论(0编辑  收藏  举报