Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Code Regneration in Spring Roo

 
Ranch Hand
Posts: 193
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One of the reasons that I am a bit reluctant to use Spring Roo is the fact that it depends on code generation, non-Java code generation at that. Do you address this in your book? What can you tell me to assure me that this is not a liability in adopting Spring Roo.

Thanks,
Joshua Smith
 
author
Posts: 469
20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Joshua,

The following is a FlightService_Roo_ToString.aj AspectJ ITD file:



The above code says that FlightService_Roo_ToString.aj file adds a method named toString to FlightService Java class. You can move this toString method into the corresponding FlightService.java source file with just a few clicks in your IDE.

If you look at the above AspectJ ITD file, you can see that it is Java code with slightly different syntax for introducing members to the corresponding Java class. I don't see this can be considered as an impediment in adoption of Spring Roo.

regards
ashish
 
Joshua Smith
Ranch Hand
Posts: 193
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Ashish.

If I move that code into the .java file, does that mean that I can delete the .aj file and not use it any longer?

Why does Roo generate the code in a .aj file instead of generating .java files or modifying existing Java files?

Thanks,
Josh
 
Ashish Sarin
author
Posts: 469
20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Joshua,

Let's say you have an AspectJ ITD file which contains a single method toString. When you move this method from AspectJ ITD file to the corresponding Java source file, Roo will automatically delete the ITD file because it is no longer required. You don't need to manually delete the .aj files.

Imagine you have a code generation tool that keeps all the information in Java source files. Now, everytime you do something using such a code generator, it'd result in overwriting the Java source file. It also means that you may lose all the customization that you made. In Spring Roo, the code that is managed by Spring Roo is kept in AspectJ ITD files, which you must not modify. This results in clear separation of what code is owned by developer (the code in .java files) and what is owned by Spring Roo (the code in .aj files).

I have added a blog entry that can give you some idea about what typically forms part of .aj files.

regards
ashish
 
My previous laptop never exploded like that. Read this tiny ad while I sweep up the shards.
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic