O'Reilly logo

Professional Java™ Development with the Spring Framework by Colin Sampaleanu, Thomas Risberg, Alef Arendsen, Juergen Hoeller, Rod Johnson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 2. The Bean Factory and Application Context

At the heart of Spring is its lightweight Inversion of Control (IoC) container functionality. One or more instances of a container are used to configure and wire together application and framework objects, and manage their lifecycles. The key principles of IoC ensure that the great majority of these objects do not have to have dependencies on the container itself, and can generally deal with related objects purely in terms of (Java) interfaces or abstract superclasses, without having to worry about how those other objects are implemented, or how to locate them. The IoC container is the basis for many of the features that will be introduced in the chapters that follow.

In this chapter, you will learn about the configuration and usage of Spring's bean factories and application contexts, as the embodiment of Spring's IoC container functionality. You will learn about the BeanFactory and ApplicationContext interfaces, along with related interfaces and classes, used when the container needs to be created or accessed in a programmatic fashion. This chapter will focus on the BeanFactory and ApplicationContext variants configured in a declarative fashion via XML. These generally have the most built-in functionality in terms of configuration and usage, and are the ones used by Spring users in the vast majority of cases. Note however that Spring decouples container configuration and usage. The next chapter will show how you may also access ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required