package com.eduask.dl;首先定义一个接口interface ClothFactory { void productCloth();}创建被代理类class NikeClothFactory implements ClothFactory{ @Override ...
package com.eduask.dl;
首先定义一个接口
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 nike = new NikeClothFactory();
ProxyFactory proxy = new ProxyFactory(nike);
proxy.productCloth();
}
}
海外公司注册、海外银行开户、跨境平台代入驻、VAT、EPR等知识和在线办理:https://www.xlkjsw.com
原标题:代理类和被代理类的解释及案例
关键词:
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们:
admin#shaoqun.com
(#换成@)。