Setting up Roo
The first thing that you need to do to get started with using Spring Roo is to set up the Roo tool on your laptop or desktop.
In this recipe, we will look at how you can install Spring Roo and verify that it's ready to use.
Tip
What do I need to learn to effectively use Spring Roo?
If you are an experienced Java enterprise developer, then you hardly need to learn anything new to use Spring Roo. If you know how AspectJ ITDs (Inter-type Declarations) work, then it will be helpful to understand what Spring Roo does behind the scenes. As you go through the various recipes in this book, you will find enough details on how Spring Roo makes use of AspectJ ITDs.
Getting ready
As you are going to install Spring Roo, you first need to download Spring Roo ZIP archive from the official home page of Spring Roo(http://www.springsource.org/roo/start). Also, ensure that you have the following software installed on your machine:
Java SE 6 or later (http://java.sun.com/javase/downloads/index.jsp).
Apache Maven 3.x or later (http://maven.apache.org/download.html). Examples in this book make use of Apache Maven 3.0.2
How to do it...
To install Spring Roo, all you need to do is to follow the given steps:
Unzip the downloaded Spring Roo ZIP archive into a directory. Once you have unzipped Spring Roo ZIP file, you will see the directory structure (excluding the
cache
directory) as shown in the following screenshot:Set the
JAVA_HOME
environment variable to point to the Java SE installation directory.Set the
ROO_HOME
environment variable to point to the Roo installation directory.If you are using Windows, add the
ROO_HOME/bin
directory to thePATH
environment variable. If you are using Linux or Mac OS X, then create a symbolic link to theROO_HOME/bin/roo.sh
shell script.Roo installation isn't complete unless you verify it. So, create a
ch01-recipe
sub-directory in theC:\roo-cookbbook
directory, open command prompt, and go to thech01-recipe
directory. Now, execute theroo.bat
batch file, as shown in the following commands:Tip
Downloading the example code
You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.
C:\>cd roo-cookbbook C:\roo-cookbbook>cd ch01-recipe C:\roo-cookbbook\ch01-recipe>roo ____ ____ ____ / __ \/ __ \/ __ \ / /_/ / / / / / / / / _, _/ /_/ / /_/ / /_/ |_|\____/\____/ 1.1.1.RELEASE [rev 156ccd6] Welcome to Spring Roo. For assistance press TAB or type "hint" then hit ENTER. .. roo>
If you see the output as shown, it means you have successfully installed Spring Roo. You will notice that when you execute
roo.bat
orroo.sh
, the command prompt changes toroo>
. You are now ready to play with Spring Roo.
How it works...
Spring Roo is built on top of Apache Felix (http://felix.apache.org/site/index.html) OSGi container, which promotes modularity and dynamic assembly of applications. The bundle
directory contains OSGi bundles that form part of Spring Roo release. These bundles provide core services required by Roo and add-ons that support code generation. When you first start Spring Roo by executing Roo batch file or shell script, then these bundles are installed and copied into the cache
directory of your Spring Roo installation.
There's more...
Spring Roo comes with certain core services and base add-ons that are part of Spring Roo distribution. Core services like the Roo shell, file system monitor, bootstrap, and so on, provide the necessary infrastructure for the add-ons to perform their intended responsibility. Add-ons are at the heart of Spring Roo and they provide the code generation functionality. For instance, the e-mail add-on adds e-mail support and the JPA (Java Persistence API) add-on helps with setting up a JPA provider, creating JPA entities, their relationships, and so on.
As Roo add-ons are OSGi compliant, you can additionally create a custom add-on or download a third-party add-on and install it as part of your Spring Roo installation to extend Roo's functionality.