package com.debuggg.java.exer2;
public class StaticProxyTest {
public static void main(String[] args) {
ClothFactory clothFactory = new ClothFactoryImpl();
ProxyClothFactory proxyClothFactory = new ProxyClothFactory(clothFactory);
proxyClothFactory.produceCloth();
}
}
interface ClothFactory{
void produceCloth();
}
/**
* 作者 ZYL
* 功能描述 : 代理类
* 特点:编译期间,代理类和被代理类都被确定了
* 日期 2020-03-01 11:26
* 参数 null
* 返回值
*/
class ProxyClothFactory implements ClothFactory{
ClothFactory clothFactory;
public ProxyClothFactory(ClothFactory clothFactory) {
this.clothFactory = clothFactory;
}
@Override
public void produceCloth() {
System.out.println("代理工厂准备工作");
clothFactory.produceCloth();
System.out.println("代理工厂做一些后续的收尾工作");
}
}
class ClothFactoryImpl implements ClothFactory{
@Override
public void produceCloth() {
System.out.println("Nike工厂生产一批工作服");
}
}
更多内容请访问:IT源点
注意:本文归作者所有,未经作者允许,不得转载