As I already tweeted earlier today I was trying out Spring Roo 1.0.0.RC1 as it was released today.
After playing a couple of hours with Roo I must say really like Roo using AspectJ inter-type declarations (ITDs). For example Roo will automaitcally generate id and version fields and getters and setters for your persistent fields in your domain class. Roo generates these at development time in separate AspectJ .aj files. As a developer you won't touch them as Roo will manage and update them automatically as you add fields etc. to domain classes. The great thing is the generated code will not interfere with your custom code and you don't have to be scared you custom or overwritten methods are overwritten by Roo again. During compilation all .aj files belonging to the Java class are compiled into just 1 .class file.
What I really liked is that when you are developing in SpringSource Tool Suite (based on Eclipse) code completion works also for methods contained in the AspectJ .aj files. So also debugging your code is a real breech as you can step through the methods generated by Roo easily.
Roo also contains scaffolding. However as a long term Grails user I got scared when I saw the controller code generated by Roo. See the example below:
Roo generated controller code:
@org.springframework.web.bind.annotation.RequestMapping(value = "/nation", method = org.springframework.web.bind.annotation.RequestMethod.GET)
public java.lang.String NationController.list(org.springframework.ui.ModelMap modelMap) {
modelMap.addAttribute("nations", com.footdex.domain.Nation.findAllNations());
return "nation/list";
}
Grails generated controller code:
def list = {
params.max = Math.min(params.max ? params.max.toInteger() : 10, 100)
[nationList: Nation.list(params), nationTotal: Nation.count()]
}
OK, the Roo generated code could look better if we remove all the package information before the classes:
@RequestMapping(value = "/nation", method = RequestMethod.GET)
public String list(ModelMap modelMap) {
modelMap.addAttribute("nations", Nation.findAllNations());
return "nation/list";
}
But then we should also just create the same functionality in the Grails controller (without paging):
def list = {
[nationList: Nation.list()]
}
So which one do you prefer?
I really think Spring Roo will have a great future. The use of ITDs for generated code and it's support in SpringSource Tool Suite will really aid adoption. Also in case Grails is not allowed within your company, Roo could really help you to get more productive.
As I expressed already in my example I really like Grails/Groovy effectiveness and readiness of code. Also the deep level of code by convention empowered by Grails is unbeatable.
With Grails and Roo, SpringSource has 2 remarkable frameworks in it's portfolio. Let them be as innovative as always and we as developers are the winners!