package com.tt;
//静态代理模式
//接口
interface ClothProduct{
void productCloth();
}
//被代理类
class NikeClothFactory implements ClothProduct{
@Override
public void productCloth() {
System.out.println("Nike生产线,1234565789");
}
}
//代理类
class ProxyFactory implements ClothProduct{
ClothProduct cf;
public ProxyFactory(ClothProduct cf){
this.cf=cf;
}
@Override
public void productCloth() {
System.out.println("代理类开始执行,收取代理费10000");
cf.productCloth();
}
}
public class TestClothProduct {
public static void main(String[] args) {
NikeClothFactory nike=new NikeClothFactory();
ProxyFactory proxy=new ProxyFactory(nike);
proxy.productCloth();
}
}
静态代理(反射的应用)
最新推荐文章于 2020-09-10 20:58:37 发布