To Roo or not To Roo
By: philippe, 22 June 2009Spring Roo (Milestone2) is the newest Spring brain child. This time however not a (integration) framework, but a real application generation tool.
Using a command line tool (Yes really) you not only tell Roo to generate code for you, but you also use it to modify your generated code.
For example with a simple:
create project -topLevelPackage nl.ordina.compcomp
a project is created.
And with a:
new persistent class jpa -name ~.domain.Competence
a JPA class is generated.
Adding attributes to the JPA class is also done wit a command like:
add field string description
Web interface generation is done by:
new controller automatic ~.web.CompetenceController
In short this is it. A web application with CRUD functionality. The fun part is however the code that is generated. One statement from the Spring Roo website that really intrigued me, is the ability of Roo to once generate your application and the allow you to continue without using Roo. How did the solfe the generation gap and how is it that I can continue developing the application without Roo.
So lets see what Roo has generated:
package nl.ordina.compcomp.domain; import javax.persistence.Entity; import org.springframework.roo.addon.entity.RooEntity; import org.springframework.roo.addon.javabean.RooJavaBean; import org.springframework.roo.addon.tostring.RooToString; @Entity @RooEntity @RooJavaBean @RooToString public class Competence { private String description; }
Thats it. But you say where is the rest then. Or do they have some fancy runtime framework that acts on the beautiful annotations. Well yes and no. Besides the java class a number of AspectJ files are also generated. And these files contain the extra generated code. The generation gap is solved by adding functionality using AOP. The aspect files are generated over and over again. The java class file however is only generated once and can be modified by the programmer.
If you like to continue without Roo, simply tell it to Roo. What will happen is that the Roo annotation are removed from your java files and the Aspects will be merged into your class. At that point the Roo dependency is no longer needed.
Is this the way to go? Who knows must tell. I don’t. The code is still in Milestone phase so it is not written in stone and may contain some bugs or missing functionality. The reasoning behind Roo and some implementation however choices I personally find interesting.
What do you think?

23 June 2009 om 9:22 am
I like the concept of Roo as it enables you to rapidly build Java applications. Like Rod Johnson said in the SpringOne keynote, where Roo was introduced, Java projects are associated with improductive. (See: http://www.infoq.com/presentations/SpringOne-Keynote-Rod-Johnson). You can now either choose Roo of Grails (groovy based), both frameworks are very productive.
I think that Java developers should be addopting these kind of frameworks for their own good. Or customers will start experimenting with alternative technologies, like PHP (ZEND) and Ruby (on Rails).
23 June 2009 om 9:37 am
The question is, which of these frameworks should we adopt? There are already quite a lot of code-generating frameworks. But all of them choose a different strategies.
When should we use what?
For example, we have Mod4J, Spring Roo, Sculptor, AndroMDA, etc…
I think currently it is to new for people to have used multiple frameworks and have opinions about them. Most people are probably still experimenting with their first MDA/generating framework/tool. But in the near future hopefully people will have had time to compare them and create good comparing blogs/write-ups. I’m looking forward to those…
Are you going to look into more frameworks/tools Philippe? I heard you mentioning it once