Flylib.com

Books Software

 
 
 

What s Covered in This Chapter


What's Covered in This Chapter

The focus of this chapter is to get a high-level understanding of the Spring Framework and some related concepts (for example, dependency injection). We will look at the Spring Web MVC Framework in the next chapter, and we'll look at other features such as job scheduling and emailing in later chapters. In this chapter, we will

  • Get a clear understanding of what the Spring Framework is, its fundamental concepts, how it is organized, and the many benefits of using this framework

  • Learn about the basic Spring concepts such as dependency injection, beans and bean factory, application context, property editors, and more

  • Understand how the Spring Framework is packaged, from development and deployment perspectives



What Is Spring?

When people ask me what Spring does, I have to stop and think about how to answer it in one sentence , which is not easy to do as you will see shortly. So, let me first start by quoting an excerpt directly out of the Spring Framework Reference Documentation (springframework.org) because it describes the framework well:

"...Spring provides a light-weight solution for building enterprise-ready applications, while still supporting the possibility of using declarative transaction management, remote access to your logic using RMI or web services, mailing facilities and various options in persisting your data to a database. Spring provides an MVC framework, transparent ways of integrating AOP into your software and a well-structured exception hierarchy including automatic mapping from proprietary exception hierarchies.

Spring could potentially be a one-stop shop for all your enterprise applications, however, Spring is modular, allowing you to use parts of it, without having to bring in the rest..."

Let's explore the "modular" aspect of Spring a bit further. Figure 6.1 (also taken directly out of the Spring Framework Reference Documentation) is probably the best way to get an immediate understanding of the various things Spring can do, and it shows precisely why it is difficult to describe the entire Spring Framework in a short sentence.

Figure 6.1. Overview of the Spring Framework (taken directly from the Spring Framework Reference Documentation found on springframework.org).


In this book, I use Spring Framework 2.0 RC1.



Spring Packaging for Development

The Spring modules , shown in Figure 6.1, are essentially conceptual groups of functionality provided by the extensive list of Spring's Java packages and underlying classes.

Figure 6.2 shows the various top-level Spring packages. (Note:The shaded packages are ones we will use for our sample application, again demonstrating that Spring does not take an all-or-nothing approach.)

Figure 6.2. Spring's top-level Java packages under org.springframework.


Overwhelmed by the Size of the Spring Framework?

The Spring Framework contains something along the lines of 130+ Java packages and 1,200+ Java classes. However, do not be overwhelmed by this number; here is why.

First, you may want to use only Spring's IoC features, so you could essentially ignore most of the APIs. Second, although there are lots of classes and there's lots of Javadoc, many of these classes are for internal use by the framework itself. Third, Spring enables you to select the modules you want to use and ignore the rest. For example, we will use only a handful of these for our sample application, Time Expressionthis is proof that Spring's design is highly modular.