首页 > 编程语言 > 详细

java 静态代理

时间:2019-10-26 23:06:38      阅读:79      评论:0      收藏:0      [点我收藏+]
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();

    }
}

 

java 静态代理

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!