Spring Roo Article 2

You may remember my article some time ago written about Spring Roo. Well I've been playing with it some more and am thinking that the pros outweigh the cons.

Spring is of course a popular framework (or skeleton) for doing Java based applications. It includes a mechanism for connecting beans together through config files rather than hard coding them in the .java files. On top of this there are other standardised systems for Web Model/View/Controller, Security, Web Services, Web Flow, and other common java problems.

Now th is is fine if you are a Spring expert, or at least have a Spring expert to hand who can set up your project for you. I was hoping that Spring Roo would fill this gap.

The documentation disagrees with me. It clearly states that you need good understanding of Spring before using Roo, but I think that you can learn both at the same time.

The way I see Roo being used is as a tool which sets up your initial project for you based upon a few simple criteria.

JPA Persistence
Ideally you want to specify your database schema in the roo language and this works fine for new databases. When you have an existing Database you can use the Database Introspection capability but the reverse engineering you get isn't perfect yet. The problem I find is that your pre-existing database isn't necessarily the same structure as Spring Roo would like for its JPA. If your database is already working with a Java JPA layer then I would hope you would still be able to use the same libraries as before.

You aren't forced to use hibernate, but it seems to make it easy if you do.

Web:
With just a few commands Spring Roo sets up a Tiles jsp based web front end. In theory it can use other templating systems but you'll have to investigate that yourself. What it does is to give you CRUD (Create, Read, Update, Delete) operations on each entity (aka "table"). I am a bit disappointed this is all it does. I may be greedy but I'd like it if it did fancier things like "shopping cart". Maybe an add-on is in development, or maybe I just need to write it myself :-)

REST:
It seems trivial to add a REST interface to manipulate those entities in a JSON or XML style with the same old CRUD operations. This is very pleasing to me as it means alot less work!

Libraries and Maven:
It builds the maven pom.xml file for you. If you've spent hours trying to figure out which is the current version of some library and which is the correct group id then this is the business! I believe there is an ivy creator planned as an alternative to maven but I haven't tried it.
The advantage here is that maven will fetch all the libraries you need and set up the project for you.

Eclipse:
Happily there is a simple "perform eclipse" command which turns the roo project into an Eclipse project.

The Downside:
Well, I am sure that many people don't see this as a downside, but Spring Roo makes heavy use of Spring AOP - and in particular AspectJ. I agree that the code is quite clean, but it is also (in my opinion) difficult to follow. Maybe those with more Spring AOP experience think otherwise. My colleague finds the AspectJ Eclipse plugins just don't work adequately on her development machine. This might be a bad sticking point. Although you can remove the AspectJ'ness of a Spring Roo project this is a one way operation. You can't use Spring Roo to change the project at all afterwards.

More esoteric:
There are a number of more esoteric options which you might want to consider. There is a Java Messaging System option which can use ActiveMQ for example. There is support for the Google GWT - though I expect you need to be experienced in GWT to make much use of this. Since I've mentioned Google there is support for the Google App Engine GAE though I am uncertain the extent of the other cloud computing integration.

Further Reading:
https://www.packtpub.com/spring-roo-1-1-cookbook/book (I'll try to review this soon)
http://www.springsource.org/roo/why
http://www.youtube.com/watch?v=TNE7NBLseRA - Spring Roo and REST
http://gordondickens.com/wordpress/2010/08/09/adding-jms-in-spring-roo/ Spring Roo and JMS (Apache ActiveMQ)
http://www.rimple.com/tech/2010/9/19/spring-roo-and-web-flow-the-experga... Spring Roo and WebFlow