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.
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.
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:
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
cachedirectory) as shown in the following screenshot:
JAVA_HOMEenvironment variable to point to the Java SE installation directory.
ROO_HOMEenvironment variable to point to the Roo installation directory.
If you are using Windows, add the
ROO_HOME/bindirectory to the
PATHenvironment variable. If you are using Linux or Mac OS X, then create a symbolic link to the
Roo installation isn't complete unless you verify it. So, create a
ch01-recipesub-directory in the
C:\roo-cookbbookdirectory, open command prompt, and go to the
ch01-recipedirectory. Now, execute the
roo.batbatch file, as shown in the following commands:
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.sh, the command prompt changes to
roo>. You are now ready to play with Spring Roo.
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.
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.