亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

正在回答

2 回答

EMMMMMMMMMMMM,這就是一種

0 回復 有任何疑惑可以回復我~

第一種方法

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();

第二種方法

Car car = new Car();

InvocationHandler h = new TimeHandler(car);

Class<?> cls = car.getClass();

/**

* loader? 類加載器

* interfaces? 實現接口

* h InvocationHandler

*/

Moveable m = (Moveable)Proxy.newProxyInstance(cls.getClassLoader(),

cls.getInterfaces(), h);

InvocationHandler h2=new LogHandler(m);

Class<?> clh=m.getClass();

Moveable m2=(Moveable)Proxy.newProxyInstance(clh.getClassLoader(),?

clh.getInterfaces(), h2);

m2.move();

其實都差不多。。。

1 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

功能疊加

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號