Showing posts with label Roo. Show all posts
Showing posts with label Roo. Show all posts

Tuesday, September 6, 2011

Spring Roo 1.2.0 with GWT and Google App Engine

I was first introduced to Spring Roo at Google IO 2010 and I was amazed with the product, it allowed a developer to prototype an application very quickly, building everything from the server, domain, and GWT client.  It looked awesome.

When I got home I realised that we were shown a fixed demo in that many of the features didn't really work when building on Google App Engine and Google Web Toolkit.  Not a problem as all developers know we are used to living on the cutting alpha-beta edge of software where great new features come with one huge caveat, they occasionally don't work.

That was then and this is now.  Like Sushi which I try every 6 months just to confirm that I still am not a huge fan, it doesn't taste of anything right?, I try the latest version of Spring Roo.

The Upgrade Path
Let me just say that I love SpringSource they provide a lot of excellent tools for the Java developer and the Spring Roo documentation is no exception.  The upgrade path is very easy, unpack the latest Spring Roo to a directory of your choosing, amend your $ROO_HOME variable in .profile (Mac OSx) and then re-establish the symbolic link to the roo command line.  (sudo ln -s $ROO_HOME/bin/roo.sh /usr/bin/roo)

Done and done!

The Bleeding Edge
So I tried Spring Roo 1.1.5 and it was giving me lots of errors with trying a GWT-GAE project.  It seemed as equally unreliable as I had tried with previous versions.  Let me just add if you are using a standard database such as MySQL or any of the other persistence options, I believe Spring Roo works just fine.  The problems I usually run into are related to the peculiarities of Google App Engine and how Roo handles those.

Since most of my current projects are currently in the GAE-GWT sphere and Roo advertises that it is suppose to work in this area, I decided to upgrade to the very latest Spring Roo, so I delved into the nightly builds and installed (1.2.0.BUILD-SNAPSHOT [rev 176e407]).

Go for 1.2.0 Its Much Better
After building a couple of projects with 1.2.0 I can honestly say this is the best version yet by far.  Why?  Well it appears to work this time for GWT-GAE projects.  Most of my personal work is done on Google App Engine.  This might change as I am not really liking the new billing restrictions but we will see how those actually plan out when implemented.

I typically build small projects that utilise some sort of reference between domain objects and then build a GWT project and then test it to see if it actually works.  I will deal with deployment in a different post.  What is great about Roo is that you can amend say the domain objects and the auto UI will get updated automatically.  Simply add the line : private String userName; : to your domain object, boot up Roo and it auto creates the UI amendments needed.  Pretty stunning.  I haven't yet got to work out how you prevent it from doing this should you want to improve the UI, but I am sure that will come soon.

The project I have built it is that for a taxi company to take bookings.  It includes three domain objects Contact, Booking and Journey.    A booking can have one or more contacts, and one ore more journeys.

A Spring Roo GAE GWT project that works
 Here is the contents of my Roo file, hopefully this will help you work with your project.

project com.prestige.booking

persistence setup --provider DATANUCLEUS --database GOOGLE_APP_ENGINE --applicationId PrestigeBooking

enum type --class ~.shared.domain.ContactType
enum constant --name Booking
enum constant --name Billing
enum constant --name Passenger

entity --class ~.shared.domain.Contact  --testAutomatically 
field string --fieldName fullName --notNull
field string --fieldName email
field string --fieldName phoneNumber
field enum --fieldName contactType --type ~.shared.domain.ContactType

entity --class ~.shared.domain.Booking --testAutomatically 
field reference --type ~.shared.domain.Contact passenger

entity --class com.prestige.booking.shared.domain.Journey --testAutomatically 
field date --fieldName journeyDate --type java.util.Date 
field string --fieldName startAddress 
field string --fieldName endAddress
field string --fieldName startTime 
field reference --fieldName booking --type com.prestige.booking.shared.domain.Booking 

loggin setup --level INFO

web gwt setup


Next Steps
If you have used Roo or have done some interesting things with a Roo project please get in contact.  I have yet to explore the AddOns or detailed more information on the workflow in a Roo project that goes from prototyping to real world application.  Get in contact and lets document some Best Practices for this awesome product.

Wednesday, June 2, 2010

GWT and Spring Roo Has Great Potential

After messing with Spring Roo and GWT yesterday I can confirm three things:
  1. The potential of this is amazing.
  2. It isn’t quite ready.
  3. Did I mention that this might be amazing?
Spring Roo is a command shell that, as far as I can tell so far, I have a feeling I might be only scratching the surface, creates much of the boiler plate code that we get bored of creating.  By using an automated solution it allows the development of the code to increase, raises quality and allows you to develop application very quickly.
By entering a series of commands into a roo shell on the command line or in the Spring Source Tool Suite Roo Shell you can create an application configured with different databases and database providers.  Whilst developing the data structures and GUI interfaces required for them.
In order to increate my understanding of Spring Roo I am heading to the command line and following their tutorial to increase my understanding.
Here is an example script:
mkdir hello
cd hello
roo
roo> hint
roo> project --topLevelPackage com.foo
roo> persistence setup --provider HIBERNATE --database HYPERSONIC_IN_MEMORY
roo> entity --class ~.Timer --testAutomatically
roo> field string --fieldName message --notNull
roo> hint controllers
roo> controller all --package ~.web
roo> selenium test --controller ~.web.TimerController
roo> gwt setup
roo> perform tests
roo> quit

It is quite readable and quite amazing!

Tuesday, June 1, 2010

Create a GWT Contact Application in 10 easy steps.

Google GWT and Spring Source have joined forces to make it easier to develop web applications by developing a tool which creates your data models, your web gui interface and all the web-server communication code in a few easy command line statements.  This was demo’d at Google IO 2010 and I aim to replicate the steps required here, including any pitfalls to help you jump start your GWT development.

SpringSource Tool Suite (STS) Is a flavor of Eclipse that includes all the necessary functionality to get this working.  At it’s core is a Roo Project where you create project and define entities using the Roo Shell.  This allows you to quickly get a Database, GWT Front End and connectivity code build without writing a single piece of code.

The source data and graphics for this article is from this web page.  I have outlined my steps taken when completing it and any pitfalls I came across.   http://www.thescreencast.com/2010/05/how-to-gwt-roo.html

The Steps REQUIRED

Step 1 : Setup your system

Download and setup Spring Source Tool Suite using the first screencast on this page:

http://www.thescreencast.com/2010/05/how-to-gwt-roo.html

Step 2 : New Roo Project

image

Enter Project Settings and Click Next

image  

Click Finish, and Yes to Turn Weaving Service On

image

No to Restart Now

image

Step 3 : Goto Roo Shell

Ensure project is selected in Project Hierarchy

image

Setup Persistence

image

Step 4 : Create Employee Entity

image 

Step 5 : Create Employee Entity Fields

Field firstName

image

Field lastName

image

Step 6 : Create GWT – Front End

image

Step 7 : Setup Google Web tool Kit Settings

image

image

Step 8 : Enable Maven Dependency

image

Step 9 : Run Project

image

image

image

Step 10 : Goto Browser

image 

Pitfalls to watch out for

Enable Maven Dependency:  This is one of the last stages of the demo and in the screen case it appears to work instantly.  This is not the case.  You will notice Eclipse in a busy mode for a few minutes as it configures itself.

Additional Info

Video from Google IO demonstrating this feature: