Skyway Builder GWT Extension – Detailed Implementation
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 continuation of a series of blog posts related to extending Skyway Builder to enable some code generation support for GWT, including the automated access of Spring @Services for GWT RPC. 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 this post I will describe the implementation of the Spring DSL extension in more detail.
If you don’t so much care how the GWT extension for Skyway Builder is implemented and just want to start using the extension, then you will probably just want to skip to part 4 where I will describe how to download, install, and use the extension.
Since the general steps for extending in Skyway Builder are already described on Modifying Artifact Generation in the Skyway Wiki, in the post I’m going to focus specifically on how these steps were applied to create the GWT extension.
Following the setup instructions, first of all I created a Jet Transformation project called com.skyway.experimental.integration.gwt. I accepted all the defaults in the wizard. Next I added required dependencies.
I’m going to use JET to implement my code generation templates. JET templates resemble JSP in many ways, making it very easy to follow the implementation of the templates. JET supports the concept of tags and tag libraries (just like JSP). The JET tag library is very rich in generation functionality, but you can also use custom or 3rd party tag libraries (just like JSP). Skyway Builder contributes a set of JET tag libraries for simplifying many of the recurring generation requirements of Spring applications. A full reference of the Skyway JET tag library can be found here. In regards to the GWT extension, the Skyway JET tag library need to be added as extension.
The next step is to add the artifact definitions for the new artifacts that are going to be generated and register the template overrides for the pre-existing artifact definitions.
This diagram shows the extension entries required to accomplish the functions described in post 2, which includes:
- adding a new Service artifact definition for the GWT callback interface
- adding a new Service artifact definition for the service interface (the decision to create new artifact definition instead of overriding existing template will be described in part 4)
- overriding the JET template for generating the web deployment descriptor (web.xml)
- overriding the JET template for generating the Spring context file for the service layer
- adding a new Component artifact definition for generated GWT events
I won’t review each JET template, but the the project contains five new templates.
Here’s a summary of each template:
- generated-service-context.jet – This template is a copy of the base template and includes additional logic to direct Spring to do a component scan of all annotated Spring components. By default the component scan is done from the web context file, but GWT front-ends talk will directly to the service layer (and bypass the web layer). Therefore the component scan needs to be done from service layer, otherwise the dependencies of the Service layer won’t be resolved by Spring.
- gwtEvent.jet – This new template generates a GWT event Java class from a Spring DSL component. The component name is used as the event name, and the component variables are use for generating the event payload.
- gwtServiceAsync.jet - This template is a new template that generates the GWT callback interface, which is a requirement for using GWT RPC.
- gwtServiceInterface.jet - This template is a copy of the base template and includes additional logic to emit an @RemoteServiceRelativePath annotation for each service operation.
- web.xml.jet – This template is a copy of the base template and includes additional logic to register the spring4gwt servlet and servlet mappings.
That’s it for the plugin. The next step is to export the plugin (Export –> Deployable plug-ins and fragments). The resulting plugin (jar file) can be installed into an Eclipse instance with Skyway Builder 6.3. I’ll cover that in more detail in the next post (part four).
Tags: ajax, Code Generation, dwr, Extensions, Google, GWT, GWT RPC, java, spring, Spring DSL












February 17th, 2010 at 2:28 am
Hi Niel,
Is part 4 (“I’ll cover that in more detail in the next post (part four).”) still in the works?
Cheers
Rob
February 17th, 2010 at 10:24 am
Part 4 can be found here.
http://www.skywayperspectives.org/blog/?p=1473
February 17th, 2010 at 5:15 pm
Thanks Niel.