課程
/后端開發
/Java
/模式的秘密---代理模式
作業你們是怎么寫的
2017-11-14
源自:模式的秘密---代理模式 2-3
正在回答
InvocationHandler invocationHandler2=new LogHandler(moveable); Class<?> class2 = moveable.getClass(); Moveable moveable2 =(Moveable)Proxy.newProxyInstance(class2.getClassLoader(), class2.getInterfaces(), invocationHandler2); moveable2.move();
qq_下個瞬間_03247970 提問者
我是這么寫的
Car car = new Car();
Class carClass = car.getClass();
InvocationHandler timeHandler = new TimeHandler(car);
Moveable proxy = (Moveable) Proxy.newProxyInstance(carClass.getClassLoader(),?
carClass.getInterfaces(),timeHandler);
InvocationHandler logHandler = new LogHandler(proxy);
Moveable proxy2 =? (Moveable) Proxy.newProxyInstance(proxy.getClass().getClassLoader(),
proxy.getClass().getInterfaces(), logHandler);
proxy2.move();
不能同時實現對時間的代理和對日志的代理嗎?使得輸出結果和靜態聚合代理一樣的。
舉報
本節課程將帶你領略Java編程語言中代理模式的奧妙
4 回答作業是怎么實現的?
5 回答jdk動態代理實現作業怎么寫
2 回答PPT 怎么做到的
3 回答發一下作業
3 回答ppt 是用什么工具做的???
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2017-11-16
InvocationHandler invocationHandler2=new LogHandler(moveable);
Class<?> class2 = moveable.getClass();
Moveable moveable2 =(Moveable)Proxy.newProxyInstance(class2.getClassLoader(), class2.getInterfaces(), invocationHandler2);
moveable2.move();
2019-01-25
我是這么寫的
Car car = new Car();
Class carClass = car.getClass();
InvocationHandler timeHandler = new TimeHandler(car);
Moveable proxy = (Moveable) Proxy.newProxyInstance(carClass.getClassLoader(),?
carClass.getInterfaces(),timeHandler);
InvocationHandler logHandler = new LogHandler(proxy);
Moveable proxy2 =? (Moveable) Proxy.newProxyInstance(proxy.getClass().getClassLoader(),
proxy.getClass().getInterfaces(), logHandler);
proxy2.move();
2018-08-30
不能同時實現對時間的代理和對日志的代理嗎?使得輸出結果和靜態聚合代理一樣的。