File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Spring and the fly likes Spring roo question for Ashish Sarin Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Spring roo question for Ashish Sarin " Watch "Spring roo question for Ashish Sarin " New topic

Spring roo question for Ashish Sarin

Edwin Nels Johnson

Joined: Mar 13, 2011
Posts: 3
Hi Ashish,

Since Spring Roo generates code for you - are there any mechanisms to protect any customization that you do to that code? If another Spring Roo command is issued to alter an entity class for example, will this wipe out any customization?

Ashish Sarin
Ranch Hand

Joined: Nov 20, 2000
Posts: 432
Spring Roo is a smart tool, it's architecture supports code customization that can be retained.

Let's say you create a web controller using Spring Roo. The code generated by Spring Roo is split into two parts:

1. AspectJ ITD files (these are similar to Java source files but have a slight different syntax). The code in AspectJ ITDs is managed by Spring Roo. So, you must not modify methods, constructors and attributes defined in this file. This file has .aj extension.

2. Java source file. Roo will never overwrite any modifications that you make in methods, constructors and attributes of your Java source file.

Let's say you want to customize a method definied in AspectJ ITD file. You can use Push-in refactoring to move the method definition from AspectJ ITD file to the corresponding Java source file. Now, you can modify the method in the Java source file. This will ensure that your modifications are retained.


Author of
Getting started with Spring Framework
Portlets in Action
Spring Roo 1.1 Cookbook
Portlets blogSpring Roo blog
Edwin Nels Johnson

Joined: Mar 13, 2011
Posts: 3
Thanks Ashish - I'm looking forward to learning more about Spring Roo and trying it out.

I agree. Here's the link:
subject: Spring roo question for Ashish Sarin
It's not a secret anymore!