1700448261
1700448262
clz=_clz;
1700448263
1700448264
}
1700448265
1700448266
@Override
1700448267
1700448268
public void doStuff(){
1700448269
1700448270
InvocationHandler handler=new InvocationHandler(){
1700448271
1700448272
//具体包装行为
1700448273
1700448274
public Object invoke(Object p, Method m, Object[]args)throws
1700448275
1700448276
Throwable{
1700448277
1700448278
Object obj=null;
1700448279
1700448280
//设置包装条件
1700448281
1700448282
if(Modifier.isPublic(m.getModifiers())){
1700448283
1700448284
obj=m.invoke(clz.newInstance(),args);
1700448285
1700448286
}
1700448287
1700448288
animal.doStuff();
1700448289
1700448290
return obj;
1700448291
1700448292
}
1700448293
1700448294
};
1700448295
1700448296
//当前加载器
1700448297
1700448298
ClassLoader cl=getClass().getClassLoader();
1700448299
1700448300
//动态代理,由Handler决定如何包装
1700448301
1700448302
Feature proxy=(Feature)Proxy.newProxyInstance(cl, clz.
1700448303
1700448304
getInterfaces(),handler);
1700448305
1700448306
proxy.load();
1700448307
1700448308
}
1700448309
1700448310
}
[
上一页 ]
[ :1.700448261e+09 ]
[
下一页 ]