What is the use GWT generator?

谁说胖子不能爱 提交于 2019-12-29 05:03:05

问题


I have seen that GWT framework is having generator feature. In what case we have to use gwt generator option and why it is needed? Can anyone tell me simply why,what is gwt generator? Done some googling. But not much helpful stuffs...


回答1:


From this tutorial:

Generators allow the GWT coder to generate Java code at compile time and have it then be compiled along with the rest of the project into JavaScript.

This tutorial uses the example of generating a Map of values at compile time based on a properties file.




回答2:


I've done GWT development for 3 years now and I've written one generator :) I've written a couple of linkers for experimental purposes so I think they are more common, though still rare. The classic case is where you want to write

X x = GWT.create(X.class)

and have the particular subclass or implementation of X constructed at compile time based on, perhaps, annotations in the provided X class or interface. GWT uses them for things like the CSSResource.

Search for "GWT Generator Experiments" site:development.lombardi.com on google for some info about what I did.




回答3:


One of the use cases is to mimic reflection on the client side by building a factory class on the fly. I remember answering a question posted by you earlier on how to do this

How to create new instance from class name in gwt?

So i guess you already know the application. What else are you looking for? Can you be precise?




回答4:


I've started using GWT Generators where I needed Java Reflection. I've documented One of the use cases for using GWT generators here:

http://jpereira.eu/2011/01/30/wheres-my-java-reflection/

Hope it helps.




回答5:


If you refer to code generator, yes, there will a tool supporting GWT 2.1 code generation. For more details and a quick start, see http://www.springsource.org/roo/start A general roo intro is here http://blog.springsource.com/2009/05/01/roo-part-1/

Another visual tutorial is at http://www.thescreencast.com/2010/05/how-to-gwt-roo.html




回答6:


Check out this implementation: http://samuelschmid.blogspot.com/2012/05/using-generator-for-generic-class.html

You can create new Instances of classes on client with foo.newInstance("fully.qualified.class.name");



来源:https://stackoverflow.com/questions/3298317/what-is-the-use-gwt-generator

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!