Google Web Toolkit Autobeans

时间:2015-08-11 06:09:21

标签: java gwt reflection autobean

由于好奇心,我检查了如何生成autobeans。我发现它使用sun.misc.ProxyGenerator类来生成autobean proxies,并使用reflections。但我不明白,它如何在客户端工作。那些使用reflections的方法是否编译为javascript?这是否意味着我可以在客户端自己使用反射?

1 个答案:

答案 0 :(得分:1)

代理实例仅用于服务器上,在真实的JVM中,反射有效。你是对的,GWT代码不能使用一般反射。

要在客户端上生成它们,请使用GWT Generator。当GWT编译器仍在运行时,这会完成所有反射,在真正的JVM中也是如此,并创建实现autobean接口和工厂的新类。

com.google.web.bindery.autobean.gwt.rebind.AutoBeanGenerator课程主要负责这项工作,com.google.web.bindery.autobean.gwt.rebind.model包的内容(以及com.google.web.bindery.autobean.shared)在这项工作中有所帮助。