Source code of Spring Roo Cookbook

73 views
Skip to first unread message

Ashish Sarin

unread,
Jun 9, 2011, 2:04:19 PM6/9/11
to Spring Roo Cookbook
Hi everyone,

The source code of Spring Roo Cookbook is now available for download
from the following location: http://code.google.com/p/spring-roo-cookbook/downloads/list.

The source code is currently not available from Packt website, but
soon it'll be made available.

If you find any problem or issue with the source code, then please
post it in this forum.

thanks
ashish

Alex McLintock

unread,
Jun 10, 2011, 6:24:27 AM6/10/11
to spring-ro...@googlegroups.com
I've run most of the scripts on roo 1.1.4 with no real problems, thanks. 



Suggestions only :-)

1) 
Would it be possible to put a new line on the end of the roo files? If I pipe one of your roo files into roo.sh then the final command (usually "perform eclipse") doesn't get executed. Of course this isn't a problem if you use the roo command "script filename", or manually cut and paste the commands. 

2) 
Maybe all the "flight-app" apps should have different names so that they can be loaded into the same Eclipse workspace? Some are different, and some the same. 

3) Was there a deliberate decision to use MySQL rather than something like hypersonic - some in memory Java database? It makes the examples easier to run. 

Requests:
I'd like to see a bit more on using two databases, especially non RDBMs or NoSQL databases. 
In particular I'd like to see an example with DATANUCLEUS_2 (not 1) because I want to access Hadoop hBase, and so far only DATANUCLEUS_2 seems to do it.  I've seen reports that hBase is accessible through JPA, but also that DATANUCLEUS_2 accesses it via JDO. That might not be suitable for a beginners cookbook though :-)

Another thing I'd like to see is different ways of putting in a service layer. I'm going to go through the service/controller examples now because I am still not happy I understand where the business logic is *supposed* to go in a SpringRoo generated app. Not everything is a CRUD type system. 

Alex McLintock

unread,
Jun 10, 2011, 7:17:22 AM6/10/11
to spring-ro...@googlegroups.com
I'm trying the chapter 6 recipe "Sending emails using JavaMail API"

After step 10 or 11 we have the FlightController.create method copied from the FlightController_blah.aj and put into a new create method in the FlightController.java

Now my eclipse (and mvn) is complaining because that means the create method exists twice in the same class. My understanding is that roo is supposed to "automatically" remove the method from the .aj 
is that correct? 
It isn't happening for me. What should I have seen? Any tips for forcing it to refresh?

Alex

Alex McLintock

unread,
Jun 10, 2011, 8:04:49 AM6/10/11
to spring-ro...@googlegroups.com
OK, 

Found the problem. It is a small but confusing mistake in the RAW file 

What happened was I cut and pasted from the RAW pdf but it included some smart quotes instead of plain quotes...

sendMessage(<username>@gmail.com, A new instance of Flight entity
with id + flight.getFlightId() + has been created.);




Once I replaced the smart quotes (the sloping 66 and 99) with dumb quotes I successfully got:


Updated SRC_MAIN_JAVA/sample/roo/flightapp/web/FlightController_Roo_Controller.aj
Updated SRC_MAIN_JAVA/sample/roo/flightapp/web/ApplicationConversionServiceFactoryBean_Roo_ConversionService.aj




Alex

Ashish Sarin

unread,
Jun 10, 2011, 3:23:22 PM6/10/11
to spring-ro...@googlegroups.com
Hi Alex,

I'll add a newline in the example scripts, I think its a valid point if someone wants to copy-paste commands from the roo script to roo shell. Regarding point 2, I've been thinking about it for a while but wasn't sure how to name the projects. I'll take a shot at naming projects so that its easy to identify chapter and the recipe it corresponds to. Point 3, I intentionally used MySQL because in a typical enterprise application project, in-memory database will not be used to store persistent data. Also, MySQL is lightweight and a popular database that is used in many projects. 

I'll discuss with Packt if we can include neo4j Spring roo add-on example (for the NoSQL example). A roo add-on already exists for Neo4j (http://s3browse.springsource.com/browse/maven.springframework.org/snapshot/org/springframework/data/spring-data-neo4j-roo/) which can be used for creating the recipe.

I think including DATANUCLEUS_2 with Haddop hBase recipe might be difficult, because it'll be a very very specific recipe. Spring Roo Cookbook focuses on demonstrating what roo does, how it does and to explain the significance of artifacts and configurations generated by each of the roo commands. You can use roo in  many ways. For instance, you may generate the JPA layer and create your own web layer or you may just want to create a mavenized project quickly and develop rest of the things yourself or you may use Dojo components in your web layer generated by roo, and so on. The possibilities are endless and I think covering all the possibilities will make the book too long and will defeat the basic purpose of the book. I can definitely fill-in more details on the role of services in roo-based applications, as this is something important for roo users. 

As you have read most of the chapters, do you feel that the flow of recipes is appropriate and important concepts explained at length?

thanks for posting your suggestions. please keep them coming, as I still have time before the book goes into production.
- ashish 

Alex McLintock

unread,
Jun 10, 2011, 6:02:41 PM6/10/11
to spring-ro...@googlegroups.com


On 10 June 2011 20:23, Ashish Sarin <ashes...@gmail.com> wrote:
Hi Alex,
... 
As you have read most of the chapters, do you feel that the flow of recipes is appropriate and important concepts explained at length?

It seems ok. I'd recommend it as a first Spring Roo book. To be honest I was originally hoping for more advanced recipes - but seeing how long the book is already I think it is value for money. :-)


I don't feel myself to be a total beginner with Roo so I approached the book by dipping in at random. I didn't start with chapter one and work through in order. Who reads a technical book from start to finish? However I did run the largest roo script for each chapter and made sure I could get as far as "perform eclipse" without errors. 

I then took an interesting roo script near the end of the book (the one about JMS) and followed that recipe to start with. I managed to get it to email me successfully. Hooray. First time for me with SpringRoo.

And then I went looking for other things to do: I followed the recipe for changing the menu.jspx to say "CREATE", "VIEW", "FIND". HOWEVER rather than start by using the new roo script I just looked to see what the differences were - and added the different commands to my single app. 

(Only yesterday was I wondering what the z="9h987h7n8h8h" meant - and your book explained it nicely)

The biggest problem I had was copying the smart quotes from the PDF file. It confused me for a bit because I didn't notice the problem when it was in the java classes. Sometimes in the book quotes are plain, sometimes smart.

Later on I hit a small snag with CascadeType being imported from hibernate instead of from javax.persistence
That was a bit frustrating. I don't understand why roo imported the hibernate one - I guess I'll find out when I use it.
That may have been something I did which was different from your recipe. Anyway - you may want to double check your recipe for OneToMany relationships which tells you to set CascadeType.


Idea: 

Is there a REST recipe? There seems to be a short mention of it - but not really a full recipe. 

I would like to see something else - which may not be possible with Roo. I'd like to see what you do if you want to access data available on another REST server - so your website is effectively a REST client. Does that make sense? 



Ashish Sarin

unread,
Jun 11, 2011, 1:41:46 AM6/11/11
to spring-ro...@googlegroups.com
Thanks Alex for your feedback. Yes, I'd like to include a REST recipe in which web clients invoke Spring Web MVC controller's methods which accept and return JSON.

You can suggest some of the advanced recipes that you'd like to see in the book and I'll include them in the Second Edition of Spring Roo Cookbook :)  

- ashish
Reply all
Reply to author
Forward
0 new messages