In Chapter 1, during the first discussion of Inversion of Control (IoC), you might recall that we mentioned that it had been renamed, by Martin Fowler, the more descriptive Dependency Injection (DI). However, this is not strictly true; in reality, DI is a specialized form of IoC, although you will often find that the two terms are used interchangeably. In this chapter, we take a much more detailed look at IoC and DI, formalizing the relationship between the two concepts and looking in great detail at how Spring fits into the picture.
After defining both and looking at Spring's relationship with them, we will explore the concepts that are essential to Spring's implementation of DI. This chapter only covers the basics of Spring's DI implementation; we discuss more advanced DI features in 11. More specifically this chapter will cover the following topics:
Inversion of Control concepts: In this section, we discuss the various kinds of IoC including Dependency Injection and Dependency Lookup. This section looks at the differences between the various IoC approaches and presents the pros and cons of each.
Inversion of Control in Spring: This section looks at IoC capabilities available in Spring and how these capabilities are implemented. In particular, this section looks at Dependency Injection and the setter-based and constructor-based approaches Spring offers. This section also provides the first full discussion of the BeanFactory interface, which is central to the whole Spring framework.
XML configuration for Spring BeanFactories: The final part of this chapter focuses on using the XML-based configuration approach for the BeanFactory configuration. This section starts out with a discussion of DI configuration and moves on to look at additional services provided by the BeanFactory such as bean inheritance, lifecycle management, and autowiring.