中国开发网: 论坛: 程序员情感CBD: 贴子 721451
sealw: 像guice、spring这样的框架,一般是通过反射生成实例,再强制类型转换返回
<T> T inject(Class<T> implementation, InternalContext context) {
try {
ConstructorInjector<T> constructor = getConstructor(implementation);
return implementation.cast(
constructor.construct(context, implementation));
} catch (Exception e) {
throw new RuntimeException(e);
}
}


http://www.koders.com/java/fid1EADF59AF6175D22EA481EE603B0800C21167EAC.aspx

相关信息:


欢迎光临本社区,您还没有登录,不能发贴子。请在 这里登录