About this Book

The Spring Framework was created with a very specific goal in mind—to make developing Java EE applications easier. Along the same lines, Spring in Action, Third Edition was written to make learning how to use Spring easier. My goal is not to give you a blow-by-blow listing of Spring APIs. Instead, I hope to present the Spring Framework in a way that is most relevant to a Java EE developer by providing practical code examples from real-world experiences. Since Spring is a modular framework, this book was written in the same way. I 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.

Who should read this book

Spring in Action, Third Edition, is for all Java developers, but enterprise Java developers will find it particularly useful. While I will guide you along 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. Therefore, 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. Therefore, any experience you have will be useful in making comparisons between these two frameworks. A portion of this book is dedicated to this topic. In fact, the final five chapters demonstrate how Spring can support enterprise integration of web applications. If you are an enterprise application developer, you will find the last part of this book especially valuable.

Roadmap

Spring in Action, Third Edition, is divided into three parts. The first part introduces you to the essentials of the Spring Framework. Part 2 goes beyond that by delving into the common elements of a Spring application. The final part shows how Spring can be used to integrate with other applications and services.

In part 1, you’ll explore dependency injection (DI) and aspect-oriented programming (AOP), two essential features of the Spring Framework. 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 DI and AOP and how they lend themselves to developing loosely coupled Java applications.

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

Once you have the basics of Spring XML configuration down, chapter 3 will present annotation-oriented alternatives to XML configuration.

Chapter 4 explores how to use Spring’s AOP to decouple cross-cutting concerns from the objects that they service. This chapter also sets the stage for later chapters, where you’ll use Spring AOP to provide declarative services such as transactions, security, and caching.

Part 2 builds on the DI and AOP features introduced in part 1, and shows you how to apply these concepts to build the common elements of an application.

Chapter 5 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 persistence frameworks such as Hibernate and the Java Persistence API (JPA).

Chapter 6 complements chapter 5, showing you how to ensure integrity in your database using Spring’s transaction support. You’ll see how Spring uses AOP to give simple application objects the power of declarative transactions.

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

Chapter 8 explores Spring Web Flow, an extension to Spring MVC that enables development of conversational web applications. In this chapter you’ll learn how to build web applications that guide the user through a specific flow.

In chapter 9 you’ll learn how to apply security to your application using Spring Security. You’ll see how Spring Security secures applications both at the web request level using servlet filters and at the method level using Spring AOP.

After building an application with what you’ve learned from part 2, you may want to integrate it with other applications or services. In part 3 you’ll learn how to do that.

Chapter 10 explores how to expose your application objects as remote services. You’ll also learn how to seamlessly access remote services as though they were any other object in your application. Remoting technologies explored will include RMI, Hessian/Burlap, SOAP-based web services, and Spring’s own HttpInvoker.

Chapter 11 revisits Spring MVC, showing how to use it to expose your application data as RESTful resources. In addition, you’ll learn how to develop REST clients with Spring’s RestTemplate.

Chapter 12 looks at using Spring to send and receive asynchronous messages with JMS. In addition to basic JMS operations with Spring, you’ll also learn how to use the open source Lingo project to expose and consume asynchronous remote services over JMS.

Chapter 13 will show you how to use Spring to schedule jobs, send emails, access JNDI-configured resources, and manage your application objects with JMX.

Wrapping up our exploration of Spring, chapter 14 will show you how to use Spring to schedule jobs, send emails, and access JNDI-configured resources.

Code conventions

There are many code examples throughout this book. These examples will always appear in a fixed-width code font. If there is a part of an example I 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 and packages have exceptionally long (but expressive) names. Because of this, line-continuation markers (å) may be included when necessary.

Not all code examples in this book will be complete. Often I only show a method or two from a class to focus on a particular topic. Complete source code for the applications found throughout the book can be downloaded from the publisher’s website at www.manning.com/SpringinActionThirdEdition.

About the author

Craig Walls is a software developer with more than 13 years of experience and is the coauthor of XDoclet in Action (Manning, 2003) and two earlier editions of Spring in Action (Manning, 2005 and 2007). He’s a zealous promoter of the Spring Framework, speaking frequently at local user groups and conferences and writing about Spring on his blog. When he’s not slinging code, Craig spends as much time as he can with his wife, two daughters, six birds, four dogs, two cats, and an ever-fluctuating number of tropical fish. Craig lives in Plano, Texas.

Author Online

Purchase of Spring in Action, Third Edition includes free access to a private web forum run by Manning Publications where you can make comments about the book, ask technical questions, and receive help from the author and from other users. To access the forum and subscribe to it, point your web browser to www.manning.com/SpringinActionThirdEdition. This page provides information on how to get on the forum once you are registered, what kind of help is available, and the rules of conduct on the forum.

Manning’s commitment to our readers is to provide a venue where a meaningful dialogue between individual readers and between readers and the author can take place. It is not a commitment to any specific amount of participation on the part of the author, whose contribution to the book’s forum remains voluntary (and unpaid). We suggest you try asking the author some challenging questions, lest his interest stray!

The Author Online forum and the archives of previous discussions will be accessible from the publisher’s website as long as the book is in print.

About the title

By combining introductions, overviews, and how-to examples, the In Action books are designed to help learning and remembering. According to research in cognitive science, the things people remember are things they discover during self-motivated exploration.

Although no one at Manning is a cognitive scientist, we are convinced that for learning to become permanent it must pass through stages of exploration, play, and, interestingly, retelling of what is being learned. People understand and remember new things, which is to say they master them, only after actively exploring them. Humans learn in action. An essential part of an In Action guide is that it is example-driven. It encourages the reader to try things out, to play with new code, and explore new ideas.

There is another, more mundane, reason for the title of this book: our readers are busy. They use books to do a job or to solve a problem. They need books that allow them to jump in and jump out easily and learn just what they want just when they want it. They need books that aid them in action. The books in this series are designed for such readers.

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

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