BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Spring Aiming to Bring Grails-like Productivity to GWT Application Development With Roo

Spring Aiming to Bring Grails-like Productivity to GWT Application Development With Roo

Leia em Português

This item in japanese

Bookmarks

In May, VMware and Google announced a collaboration between the engineers of VMware's Spring Roo framework and Google's GWT Java-to-JavaScript compiler. The collaboration aims to deliver the productivity gains of Spring Roo to the Java-based GWT rich Internet application framework.

Spring Roo, led by SpringSource's Ben Alex, is a light-weight rapid application development stack that attempts to bring the rapid feedback and productivity features enjoyed by developers using other full-stack solutions (e.g. Ruby on Rails and Groovy on Grails) to the Java developer community. It provides a shell that generates and manages the life-cycle of classes using a simple command language to describe project setup, entities, controllers, and much more. It provides a set of source-code-retention-level annotations that enable developers to "opt-in" to various Spring Roo services for the classes they annotate.

Spring Roo also lets developers generate a domain layer using the shell, but keep in mind the approach departs from the traditional Java Enterprise method of employing DAOs in favor of the much discussed preference toward the Entity Manager pattern. From the Spring Roo reference:

Most traditional Java enterprise applications will have a DAO layer, services layer, domain layer and controller layer. In a typical Roo application you'll only use an entity layer (which is similar to a domain layer) and a web layer. ... a services layer might be added if your application requires it, although a DAO layer is extremely rarely added

An application may be taken all the way through the creation of a Spring-MVC-, or GWT-MVP-based CRUD scaffolding application.

Google Web Toolkit (GWT) is a Java-to-JavaScript compiler that lets developers program using Java IDEs and idioms in their code. The final "compiled" application is indeed JavaScript, and can be used to build cross-browser, interactive web applications. GWT includes the Chrome extension Speed Tracer, a tool that enables client side application profiling and debugging. Speed Tracer includes server-side profiling, although the support is limited to Google App Engine (GAE), and SpringSource tc Server Developer Edition. As the GWT project site states:

With this integration, you'll be able to view metrics for database calls, memcache hits, resources fetches, as well as other server-side service calls.

The new collaboration with Google allows the developer to extend the application with GWT, and enables deployment to GAE with DataNucleus persistence support. Spring Roo - in the background - automates the project lifecycle; from wiring together GWT MVP views to setting up the GWT compiler, configuring domain persistence, dependencies with Maven, and more.

Spring Roo provides a command to generate JUnit integration test cases of the domain layer. A set of test cases - built on the Spring integration testing infrastructure - are produced to verify that common JPA operations such as CRUD, all work. Additionally, Spring Roo relies on the Selenium tool to create automated tests for each of the project's web controllers. To enable web-tier testing, Maven starts a Tomcat server instance. Spring Roo then deploys the final test web-application for developer verification.

To support round-tripping code generation in the background, Spring Roo relies on AspectJ Inter-type declarations (ITDs). An ITD is an aspect described in a Java-like syntax that is woven into the Java classes at compile time. Spring Roo manages the ITDs, reacting to changes in the Java classes that they belong to. For example: given a class annotated with @RooToString, Spring Roo might generate, or update, a toString() method in an aspect that enumerates all the variables in the class. This method gets compiled into the final .class file, in effect freeing the developer from having to manually write that code.

Setting up an IDE such as Eclipse, or IntelliJ to acknowledge code generated with ROO will require the plugin which provides the AspectJ Development Toolkit (ADJT). This will enable support for code-completion using AspectJ aspect artifacts within the development environment. SpringSource provides a free (as in beer) Eclipse-based distribution called SpringSource Tool Suite (STS) that includes a full host of plugins ideal for Spring Roo development (like the m2eclipse plugin). The IDE is a useful, if unnecessary, luxury, however as all commands are still executed at the ROO shell.

An example application was put together by Christian Dupuis with instructions on his blog at SpringSource. His post goes through all of the steps to configure STS, generate a project using ROO, and deploy a basic GWT app to GAE. Whilst still in the early stages of development the STS with GWT integration shows a lot of promise.

Rate this Article

Adoption
Style

BT