zoukankan      html  css  js  c++  java
  • 代理模式

    package com.java.exec2;
    
    /**
     * Created by zhangyanana    on 2017/3/16.
     */
    //静态代理模式
    //接口
    interface ClothFactory {
        void productCloth();
    }
    
    //被代理类
    class NikeClothFactory implements ClothFactory {
    
        @Override
        public void productCloth() {
            System.out.println("Nike工厂生产一批衣服");
        }
    }
    
    //代理类
    class ProxyFactory implements ClothFactory {
        ClothFactory cf;
        //创建代理类对象时,实际传入一个被代理类的对象
        public ProxyFactory(ClothFactory cf) {
            this.cf = cf;
        }
    
        @Override
        public void productCloth() {
            System.out.println("代理类开始执行,收代理费$1000");
            cf.productCloth();
        }
    }
    
    public class TestClothProduct {
        public static void main(String[] args) {
            NikeClothFactory ncf = new NikeClothFactory();//创建被代理类的对象
            ProxyFactory pf = new ProxyFactory(ncf);//创建代理类的对象
            pf.productCloth();
        }
    }
  • 相关阅读:
    playbook的复用
    playbook 任务标签
    playbook handlers 触发器
    playbook循环语句
    playbook条件语句
    Ansible变量
    每日总结4.13
    每日总结4.12
    每日总结4.9
    每日总结4.8
  • 原文地址:https://www.cnblogs.com/zhyn-BeHard/p/6559395.html
Copyright © 2011-2022 走看看