Introduction

The Spring framework is growing. It has always been about choice. Java EE focused on a few technologies, largely to the detriment of alternative, better solutions. When the Spring framework debuted, few would have agreed that Java EE represented the best-in-breed architectures of the day. Spring debuted to great fanfare, because it sought to simplify Java EE. Each release since marks the introduction of new features designed to both simplify and enable solutions.

With version 2.0 and later, the Spring framework started targeting multiple platforms. The framework provided services on top of existing platforms, as always, but was decoupled from the underlying platform wherever possible. Java EE is a still a major reference point, but it's not the only target. OSGi (a promising technology for modular architectures) has been a big part of the SpringSource strategy here. Additionally, the Spring framework runs on Google App Engine. With the introduction of annotation-centric frameworks and XML schemas, SpringSource has built frameworks that effectively model the domain of a specific problem, in effect creating domain-specific languages (DSLs). Frameworks built on top of the Spring framework have emerged supporting application integration, batch processing, Flex and Flash integration, GWT, OSGi, and much more.

When it came time to update the seminal Spring Recipes, we quickly discovered that it's been a long time since there was, effectively, only one core Spring framework. The SpringSource portfolio, such as it is, describes several frameworks, each of which is dramatically more capable than the alternatives with which it competes in other products. This book will serve you well on your journey through the various frameworks. If you don't need these technologies, you don't need to use them or add them to your project. If you do, it's nice to know they're available for you.

Who This Book Is For

This book is for Java developers who want to simplify their architecture and solve problems outside the scope of the Java EE platform. If you are already developing using Spring in your projects, the more advanced chapters present discussions of newer technologies that you might not know about already. If you are new to the framework, this book will get you started in no time.

This book assumes that you have some familiarity with Java and an IDE of some sort. While it is possible, and indeed useful, to use Java exclusively with client applications, Java's largest community lives in the enterprise space and that, too, is where you'll see most of these technologies deliver the most benefit. Thus, some familiarity with basic enterprise programming concepts like the Servlet API is assumed.

How This Book Is Structured

Chapter 1, "Introduction to Spring," gives a general overview of the Spring framework: how to set it up, what it is, and how it's used.

Chapter 2, "Advanced Spring IoC Container," reviews concepts that, while not as widely used as those discussed in Chapter 1, are still key to fully exploiting the container.

Chapter 3, "Spring AOP and AspectJ Support," discusses Spring's support for aspect-oriented programming using AspectJ. This technology underlies many of the other services provided by the Spring framework.

Chapter 4, "Scripting in Spring," discusses using scripting languages like Groovy, BeanShell, and JRuby with the Spring framework.

Chapter 5, "Spring Security," provides an overview of the Spring Security project, formerly Acegi, to help you better secure your application.

Chapter 6, "Integrating Spring with Other Web Frameworks," introduces the core web-tier support that Spring provides. This provides a base for all technologies that Spring provides in the web tier.

Chapter 7, "Spring Web Flow," provides an introduction of Spring Web Flow, which lets you build UI-flows on the web tier.

Chapter 8, "Spring @MVC," covers web-based application development using the Spring Web MVC framework.

Chapter 9, "Spring REST," provides an introduction to Spring's support for RESTful web services.

Chapter 10, "Spring and Flex," discusses using Spring BlazeDS to integrate your rich Internet application (RIA) with Spring beans. Additionally, this chapter gives an introduction to Spring ActionScript, to let users writing Flash applications in ActionScript enjoy the same container services and conveniences as Java Spring developers do.

Chapter 11, "Grails," discusses the Grails framework, with which can increase your productivity by using best-of-breed pieces and gluing them together with Groovy code.

Chapter 12, "Spring Roo," covers Spring Roo, the pivotal new framework from SpringSource designed to provide a force-multiplying framework for Java developers.

Chapter 13, "Spring Testing," discusses unit testing with the Spring framework.

Chapter 14, "Spring Portlet MVC Framework," covers using the Spring MVC Portlet framework to build applications and leverage the strengths of the Portlet container.

Chapter 15, "Data Access," discusses using Spring to talk to data stores using APIs like JDBC, Hibernate, and JPA.

Chapter 16, "Transaction Management in Spring," introduces the concepts behind Spring's robust transaction management facilities.

Chapter 17, "EJB, Spring Remoting, and Web Services," introduces you to the various facilities for RPC, including the Spring Web Services project.

Chapter 18, "Spring in the Enterprise," discusses many utilities provided by the Spring platform like JMX support, scheduling, and e-mail support.

Chapter 19, "Messaging," discusses using Spring with message-oriented middleware through JMS and the simplifying Spring abstractions.

Chapter 20, "Spring Integration," discusses using the Spring Integration framework to integration disparate services and data.

Chapter 21, "Spring Batch," introduces the Spring Batch framework, which provides a way to model solutions traditionally considered the domain of mainframes.

Chapter 22, "Distributed Spring," talks about various ways of taking scaling Spring using distributed state and grid processing.

Chapter 23, "Spring and jBPM," introduces you to business process management concepts and how to integrate one popular framework, JBoss' jBPM, with the Spring framework.

Chapter 24, "OSGi and Spring," walks you through the robust support for OSGi provided by the Spring framework.

Conventions

Sometimes, when we want you to pay particular attention to a part within a code example, we will make the font bold. Please note that the bold doesn't necessarily reflect a code change from the previous version.

In cases when a code line is too long to fit the page's width, we will break it with a code continuation character. Please note that when you try to type the code, you have to concatenate the line by yourself without any spaces.

Prerequisites

Because the Java programming language is platform independent, you are free to choose any supported operating system. However, some of the examples in this book use platform-specific paths. Translate them as necessary to your operating system's format before typing the examples.

To make the most of this book, install JDK version 1.5 or higher. You should have a Java IDE installed to make development easier. For this book, the sample code is Maven based. If you're running Eclipse and Install the m2Ecliplse plug-in, you can open the same code in Eclipse and the CLASSPATH and dependencies will be filled in the by the Maven metadata.

If you're using Eclipse, you might prefer SpringSource's SpringSource Tool Suite (STS), as it comes preloaded with the plug-ins you'll need to be productive with the Spring framework in Eclipse. If you use NetBeans or IntelliJ IDEA, there are no special configuration requirements: they already support Maven out of the box.

This book uses Maven because the Spring framework, starting with version 3.0.3, no longer ships with all the dependencies needed to use the framework. The recommended approach is to simply use a tool like Maven (or Ant and Ivy) to handle dependency management. If you are unfamiliar with Maven, you might skip ahead briefly to Chapter 12 ("Spring Roo"), where we work through setting up the Spring Roo environment, including Apache Maven.

Downloading the code

The source code for this book is available from the Apress web site (www.apress.com) in the Source Code / Download section. The source code is organized by chapters, each of which includes one or more independent examples.

Contacting the Authors

We always welcome your questions and feedback regarding the contents of this book. You can contact Josh Long at (or via his web site, www.joshlong.com). You can reach Gary Mak by e-mail at (or via his web site, www.metarchit.com). You can reach Daniel Rubio via his web site at www.webforefront.com.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset