About this Book

About this book
About this book

The Spring framework was created with a very specific goal in mind: to make developing J2EE applications easier. Along the same lines, Spring in Action was written to make learning how to use Spring easier. Our goal is not to give you a blow-by-blow listing of Spring APIs. Instead, we hope to present the Spring framework in a way that is most relevant to a J2EE developer by providing practical code examples from real-world experience.

Since Spring is a modular framework, this book was written in the same way. We recognize that not all developers have the same needs. Some may want to learn the Spring framework from the ground up, while others may want to pick and choose different topics and go at their own pace. That way, the book can act as a tool for learning Spring for the first time as well as a guide and reference for those wanting to dig deeper into specific features.

Roadmap

Spring in Action is divided into three parts, plus two appendices. Each of the three parts focuses on a general area of the Spring Framework: the core, middle-tier, and web layer. While each part builds on the previous section, each is also able to stand on its own, allowing you to dive right into a certain topic without starting from the beginning.

In part 1, you?ll explore the two core features of the Spring framework: inversion of control (IoC) and aspect-oriented programming (AOP). This will give you a good understanding of Spring?s fundamentals that will be utilized throughout the book.

In chapter 1, you?ll be introduced to IoC and AOP and how Spring uses them to make developing Java applications easier. You will also see how Spring compares to other frameworks, such as EJB, Struts, and PicoContainer.

Chapter 2 takes a more detailed look at how to configure your application objects using IoC. You will learn how to write loosely coupled components and wire their dependencies and properties within the Spring container using XML.

Chapter 3 explores how to use Spring?s AOP to decouple cross-cutting concerns, such as security, from the objects that they service. This chapter also sets the stage for chapter 5, where you?ll learn how to provide declarative transaction services with Spring?s AOP.

Part 2 builds on the IoC and AOP features introduced in part 1 and shows you how to apply these concepts to the middle tier of your application.

Chapter 4 covers Spring?s support for data persistence. You?ll be introduced to Spring?s JDBC support, which helps you remove much of the boilerplate code associated with JDBC. You?ll also see how Spring integrates with several popular object-relational mapping frameworks, such as Hibernate, JDO, OJB, and iBATIS SQL Maps.

Chapter 5 complements chapter 4, showing you how to ensure integrity in your database using Spring?s transaction support. You will see how Spring uses AOP to give you the power of declarative transactions without having to use EJBs.

Chapter 6 explores how to expose your application objects as remote services. You?ll also learn how to transparently access remote services as though they were any other in your application. Remoting technologies explored will include RMI, Hessian/Burlap, EJB, web services, and Spring?s own HttpInvoker.

Since most enterprise applications do not exist in a vacuum, chapter 7 shows you how to integrate with other enterprise services. In this chapter, you will learn how Spring makes it easy to integrate with mail services, JMS, and even EJBs.

Part 3 moves out of the middle tier and into the presentation layer used in so many J2EE applications: the Web.

Chapter 8 introduces you to Spring?s own MVC web framework. You will discover how Spring can transparently bind web parameters to your business objects and provide validation and error handling at the same time. You will also see how easy it is to add functionality to your web applications using Spring?s interceptors.

Building on the foundation of Spring MVC, chapter 9 demonstrates how to move beyond JavaServer Pages and use other templating languages such as Velocity and FreeMarker. In addition, you?ll see how to use Spring MVC to dynamically produce binary content, such as PDF and Excel documents.

Chapter 10 shows you how to integrate Spring with other web frameworks. For those of you who have already made an investment in another framework, Spring provides support for several of the popular web frameworks, including Struts, Tapestry, JavaServer Faces, and WebWork.

Finally, in chapter 11 you will learn how to apply security to your web applications using the Acegi Security System to provide authentication. In addition, you will see how to integrate Acegi with your business objects to apply security at the method level as well.

Appendix A will get you started with your own Spring application, showing you how to download the Spring framework and configure your Ant build file.

Appendix B introduces you to several other open source frameworks related to Spring.

Who should read this book

Spring in Action is for all Java developers, but enterprise Java developers will find it particularly useful. While we will guide you gently through code examples that build in complexity throughout each chapter, the true power of Spring lies in its ability to make enterprise applications easier to develop. As a result, enterprise developers will most fully appreciate the examples presented in this book.

Because a vast portion of Spring is devoted to providing enterprise services, many parallels can be drawn between Spring and EJB. Any EJB experience you have will be useful in making comparisons between these two frameworks. Finally, while this book is not exclusively focused on web applications, a good portion of it is dedicated to this topic. In fact, the final four chapters demonstrate how Spring can support the development of your applications? web layer. If you are a web application developer, you will find the last part of this book especially valuable.

Code conventions and downloads

There are many code examples in this book. These examples will always appear in a code font. If there is a particular part of an example we want you to pay extra attention to, it will appear in a bolded code font. Any class name, method name, or XML fragment within the normal text of the book will appear in code font as well.

Many of Spring?s classes have exceptionally long names. Because of this, line-continuation markers (Code-line continuations) may be included when necessary.

Not all code examples in this book will be complete. Often we only show a method or two from a class to focus on a particular topic.

Complete source code for the application found in the book can be downloaded from the publisher?s web site at http://www.manning.com/walls2 or at http://www.springinaction.com.