C H A P T E R 2
25
Spring Framework Fundamentals
The Spring Framework evolved from the code written for Expert One-on-One J2EE Design and
Development by Rod Johnson (Wrox, 2002). The framework combines best practices for Java Enterprise
Edition (JEE) development from the industry and integration with the best-of-breed third-party
frameworks. It also provides easy extension points to write your own integration if you need one that
doesn’t yet exist. The framework was designed with developer productivity in mind, and it makes it
easier to work with the existing, sometimes cumbersome Java and JEE APIs.
Before we start our journey into Spring MVC and Spring Web Flow, we will provide a quick refresher
course on Spring Core (formerly known as the Spring Framework). Spring is now a longtime de-facto
standard for Java enterprise software development. It introduced many of us to concepts such as
dependency injection, aspect-oriented programming (AOP), and programming with plain-old-Java-
objects (POJOs).
In this chapter, we will cover dependency injection and AOP. Specifically, we will cover how the
Spring Framework helps us implement dependency injection and how to use programming to our
advantage. To be able to do the things mentioned here, we will explore the Inversion of Control (IoC)
container; the application context.
We will only touch on the necessary basics of the Spring Framework here. If you want more in-depth
information about it, we suggest the excellent Spring Reference guide (www.springsource.org) or books
such as Pro Spring 3 (Apress, 2012) or Spring Recipes, 2
nd
Edition (Apress, 2011).
Let’s begin by taking a quick look at the Spring Framework and the modules that comprise it.
Tip You can find the sample code for this chapter in the chapter2-samples project. Different parts of the
sample contain a class with a main method, which you can run to execute the code.
The Spring Framework
In the introduction, we mentioned that the Spring Framework evolved from code written for the book
Expert One-on-One J2EE Design and Development by Rod Johnson. This book was written to explain
some of the complexities in JEE and how to overcome them. And while many of the complexities and
problems in JEE have been solved in the newer JEE specifications (especially since JEE 6), the Spring
Framework remains very popular.
It remains popular due to its simple (not simplistic!) approach to building applications. It also offers
a consistent programming model for different kinds of technologies, be they for data access or
评论1
最新资源