GWT RPC with Spring Extension – Download, Install and Use
Update 7/9/2010 – MyEclipse for Spring 8.6 now generates full ready-to-run GWT applications based on MVP and UI Binder in minutes. Just point the scaffolding wizard at your database tables, Java beans, or JPA Entities. You can learn more about it from the Generating Enterprise Class GWT applications for Spring post that I wrote on Genuitec blog. Or, you can keep reading my original post…
This blog post is the last post of a series of blog posts related to extending Skyway Builder to enable some code generation support for GWT. In part one I gave an overview of the Skyway Builder extension in relation to GWT, and in part two I gave an overview of how Skyway Builder will be extended to support GWT development. In part three I describe the actual implementation of the Spring DSL extension, and in this post I will describe how to download, install, and use the extension.
The GWT extension for Skyway Builder is implemented as an Eclipse plugin. As such it needs to be installed as an Eclipse plugin. In the future I may create an update site, but for now you can download the plugin (com.skyway.experimental.integration.gwt_1.0.0.jar) and copy it into the plugin folder for Eclipse. Just as a reminder this plugin is dependent on having Eclipse 3.4.2 plus Skyway Builder 6.3 (Standard Edition). If you don’t have Skyway Builder Standard Edition, you can get a copy from here.
When you restart Eclipe the GWT extension for Skyway Builder is ready to go. For any Spring DSL Services or Components that you have defined in any projects, Skyway Builder will start generating slightly updated or new artifacts (see post two for details).
Here’s an important consideration. This experimental plugin was designed to toggle the generation of GWT artifacts (using the Code Generation tab), and by default the generation is turned on. This means that it will affect all Services. If you have any existing projects that you don’t want to be affected by the GWT extension, you will need to disable the generation of the GWT artifacts by unchecking the GWT entries from the Code Generation tab of the Spring DSL.
A better solution is to add an attribute to the definition of the service that will allow me to specify the Service should be GWT enabled. That’s exactly the approach taken by the DWR and JAX-WS features in Skyway Builder. When you check “Publish DWR” or “Publish Web Service” checkboxes, the service will be generated accordingly. Perhaps I’ll tackle that in a future version of the plugin.
Here’s an example of using the new plugins. I followed the instructions from a previous blog post (GWT and Spring: Setup of development environment and Create GWT project). The only difference is that this time I’m using GWT 2.0 instead of GWT 1.7, and I also added the spring4gwt library to my project. Before I start doing any code generation with Skyway Builder, I want to quickly configure the Spring DSL to generate the correctly generate the new artifacts.
The Code Generation tab of the Spring DSL is used to define the code generation defaults for the project. You will notice there are some new code generation entries that are contributed by the new plugin. The first step is to disable “Service Interface” generation. I recommend sorting the table by Categories in order to see all the Service entries grouped together. The next step is to configure the “Service Interface“, “GWT Service Interface“, and “GWT Service Async” entries with a different package. By default they are set to ${model.package}, which means that the artifact will be generated to a java package corresponding to the model package of the Service. However for GWT we want the interfaces generated into their own package, so we are appending “.interfaces” to the end of the package. I won’t go into all the details why this needs to be done for GWT, but suffice it to say that it’s a GWT best practice to isolate client-side and server-side Java code so that the GWT compiler will only compiling relevant Java code (source path) to javascript.
To see the GWT extension for Skyway Builder in operation, you can create Spring DSL services by hand or you can quickly scaffold a Spring MVC application. For this blog post I scaffolded from a domain object. See step 9 from GWT and Spring (Part 2) – Scaffold Spring back-end for GWT Application for a quick explanation on how to scaffold a Spring MVC application with Skyway Builder.
In my example you can see that the ContactService (in Spring DSL) generated the implementation class, service interface, and asynchronous callback interface (for GWT). As you add new operations to the service, all the artifacts are regenerated to reflect the changes.
As far as events are concerned, you can just create a model package whose corresponding java package will be listed as a source path in GWT application, which will result in it being compiled into javascript.
This concludes my series. My hope is that I provided an easy to understand introduction on how to extend Skyway Builder and an extension that may be usefull to GWT developers using Spring as their backend. If you have any questions or would like me to elaborate on something, please drop me a comment here.
What’s next with this plugin? I’m glad you asked. I would like to expand the support for GWT development in Skyway Builder. I had started experimenting with some GWT UI scaffolding, and I’m making some good progress. However given the new UI Binder feature in GWT 2.0, I will need to re-examine this. If you have any ideas for enhanced GWT suppport, please let me know.
Happy New Year!!!
Tags: ajax, Code Generation, dwr, Extensions, Google, GWT, GWT RPC, java, spring, Spring DSL












February 17th, 2010 at 5:42 pm
Hi Niel,
As you mentioned the UI Binder feature is new having only recently been added to GWT. And, its not currently supported by popular third-party toolkits like smartGWT (http://code.google.com/p/smartgwt/) and Ext GWT (http://www.extjs.com/products/gxt/).
I have only just purchased the Professional Edition of Skyway Builder, so after I have finished the tutorials and worked my way through your articles I may have a few questions.
BTW, the book GWT in Practice by Robert Cooper and Collins has a chapter or two on server integration techniques. It even discuses the pros and cons of the approaches available using GWT-SL (http://gwt-widget.sourceforge.net/).
Cheers
Rob
February 18th, 2010 at 9:07 am
Thanks for pointing out GWT-SL. While I’ve been very happy with spring4gwt, there hasn’t been an update in 8 months. I’m concerned that it may be abandoned. From looking at the documentation for GWT-SL, I think I should be able to pretty much accomplish the same thing.