Spring Roo in Action
eBook - ePub

Spring Roo in Action

Ken Rimple, Srini Penchikala

Share book
  1. 408 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Spring Roo in Action

Ken Rimple, Srini Penchikala

Book details
Book preview
Table of contents
Citations

About This Book

Summary Spring Roo in Action is a unique book that teaches you how to code Java in Roo, with a particular focus on Spring-based applications. Through hands-on examples, you'll learn how Roo creates well-formed application structures and supports best practices and tools. Plus, you'll get a quick-and-dirty guide to setting up Roo effectively in your environment.
About the Technology
Roo is a lightweight Java console shell that simplifies compile-time tasks. It improves productivity by enforcing correct coding practices and patterns and integrates with mainstream Java technologies, including ActiveMQ, GWT, JPA, and OSGi. And, when you finish coding, it gets out of the way so there's no runtime impact.
About the Book
Spring Roo in Action teaches you to code Java more efficiently using Roo. With the help of many examples, it shows you how to build application components from the database layer to the user interface. The book takes a test-first approach and points out how Roo can help automate many of the mundane details of coding Java apps. Along the way, you'll address important topics like security, messaging, and cloud computing.This book is for Java developers who want to get more productive by using Roo. Purchase of the print book comes with an offer of a free PDF, ePub, and Kindle eBook from Manning. Also available is all code from the book.
What's Inside

  • Learn Roo from the ground up
  • Integrate with existing projects
  • Create custom add-ons
  • Use Roo with Spring


========================================?==============

Table of Contents

PART 1 STARTING SPRING APPS RAPIDLY WITH ROO

  • What is Spring Roo?
  • Getting started with Roo
  • PART 2 DATABASES AND ENTITIES
  • Database persistence with entities
  • Relationships, JPA, and advanced persistence
  • PART 3 WEB DEVELOPMENT
  • Rapid web applications with Roo
  • Advanced web applications
  • RIA and other web frameworks
  • Configuring security
  • PART 4 INTEGRATION
  • Testing your application
  • Enterprise services—email and messaging
  • Roo add-ons
  • Advanced add-ons and deployment
  • PART 5 ROO IN THE CLOUD
  • Cloud computing
  • Workflow applications using Spring Integration

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Spring Roo in Action an online PDF/ePUB?
Yes, you can access Spring Roo in Action by Ken Rimple, Srini Penchikala in PDF and/or ePUB format, as well as other popular books in Ciencia de la computación & Programación en Java. We have over one million books available in our catalogue for you to explore.

Information

Publisher
Manning
Year
2012
ISBN
9781638351580

Part 1. Starting Spring apps rapidly with Roo

Spring Roo is an excellent framework for the rapid development of Spring-based Java applications. With a simple command-line shell, it can create and manage Spring applications, adding and configuring components in all of the application architecture layers from SQL to URL, so to say.
We start exploring Roo with chapter 1, “What is Spring Roo?” explaining how Roo works and how it helps with creating the various configuration files required for a typical Spring application. You’ll also learn how to install and launch the Roo shell. We’ll look at a simple application by running one of the sample scripts provided in the Roo installation package.
Chapter 2, “Getting started with Roo,” will show you how to create applications from scratch with the Roo shell. You’ll also learn the details of Roo project layout and architecture. We discuss one of the new concepts Roo introduces, called AspectJ ITDs that plays an important role in the overall Roo architecture. As developers, you need tools to take advantage of new technologies and frameworks. Roo comes with integration in the form of the SpringSource Tool Suite (STS) IDE tool, which is also discussed in this chapter. We wrap up the chapter with a discussion on refactoring Roo code and leaving Roo behind if, for some reason, you want to remove Roo from your project.

Chapter 1. What is Spring Roo?

This chapter covers
  • The challenges of Enterprise Java
  • The Spring Framework
  • Roo simplifies it all
  • A sample Roo project
You’re about to be introduced to a powerful new tool that makes your life as a Java application developer less stressful and more productive. That tool is Spring Roo. With a simple command-line shell, Roo can create and manage Spring-based applications, adding and configuring features such as the Java Persistence API (JPA), the Java Message Service (JMS), email, and Spring Security. Roo generates Spring MVC web applications. These allow you to manage and edit your database data, configure tests using frameworks such as JUnit and Selenium, and choose from a variety of ORM APIs and databases. At the same time, Roo reduces the amount of code written by you and rolls out efficient, customizable generated code.
In this chapter, we discuss the challenges of working with Enterprise Java applications, create a sample application with the Roo shell, and take a quick tour of Roo’s features. We then review the Roo sample script file and discuss the architectural models available to you when crafting your application.
By the end of this chapter, you’ll see how Roo helps you get rid of much of the tedium Java EE application development demands. You’ll see that you can gain much of the productivity available in dynamic-language, convention-over-configuration platforms such as Ruby on Rails and Grails. This all comes without sacrificing the benefits of Java compile-time type safety, compiled code, and debuggability.
Let’s begin our journey by discussing one of the major reasons why Java-based development projects sputter: the complexity of configuring an application architecture.

1.1. Configuration is a burden

Putting together a Java-based application can be a difficult task these days. Where do you start? There are many things to consider: build scripts, dependency management, architectural patterns, framework selections, database mapping strategies, and much more.
In traditional Enterprise Java development efforts, architects pull together a hodgepodge of open source technologies and standards-driven platforms such as JDBC, the Servlet and JavaServer Pages (JSP) APIs, and Enterprise JavaBeans (EJB) using a build tool such as Ant or Maven. If they’re more advanced, they’ll use an application framework such as Struts and EJB, Seam, or Spring. Many starting templates, IDE shortcuts, and architectural and/or design patterns can be used to make development more efficient, but most of the work involves a lot of coding, physical build configuration, and design work.
Contrast this with your friends programming in dynamic language platforms, such as Ruby on Rails or Grails, who take about 15 minutes to get a basic application shell up and running. That shell usually includes a web application, database data and validation, and some basic business and navigation logic. Unlike a lot of Java application prototypes, theirs is usually the beginning of the final project, whereas Java developers have to try and throw away a fair number of APIs and platforms manually until they get to a point where they’re comfortable assigning a team to the project. The bottom line is that it just takes a long time to write a Java-based application.

1.1.1. Spring reduces the pain

The Spring Framework, a development platform that uses interface-driven development, dependency injection, aspect-oriented programming, and a number of helper APIs and services, significantly reduces the complexity of your Enterprise Java code. If you haven’t heard of Spring by now, we strongly suggest you put this book down and read up on the framework before you dig deeply into Roo. Craig Walls’ excellent Spring in Action is a great companion to this book.
Spring operates on the principle of making your development less about busy work and more about writing business logic. Spring application developers define interface-driven beans that are then implemented as Plain Old Java Objects (POJOs) and mounted in a Spring container using XML, annotations, or Java-based configuration directives.
Here’s an example business interface:
package org.rooinaction.coursemanager.services; ... public interface CourseManager { void addCourse(Course c); List<Course> getAllCourses(); }
Spring developers then create an implementation class:
package org.rooinaction.coursemanager.services; ... public class CourseManagerDefaultImpl { public void addCourse(Course c) { // some logic here } public List<Course> getAllCourses() { // retrieve logic here } }
One way you can use this bean is to autowire it as shown next:
package org.rooinaction.coursemanager.web; ... public class CourseInputComponent { @Autowired private CourseManager courseManager; public void createACourse(String name) { Course c = new Course(); c.setName(name); courseManager.addCourse(c); } }
We’re leaving out the configuration here, but the basic idea is a simple one: let Spring find and mount your component, deal with it at the interface level, and just write a POJO both to expose and use your component.
You can use any Java API you can think of inside a Spring application, but you’re still required to add dependent JAR files and configuration to simplify the programming tasks later.

1.1.2. Shifting from code to configuration

Even Spring can’t save you from all of the tedium involved in building an application. There are many decisions that you need to make, as shown in figure 1.1.
Figure 1....

Table of contents