
Wiring Beans Introduction
In Spring applications objects are not responsible to creating the dependent objects to do their job. It is the responsibility of the Spring
container. The container will create the objects, wire
them together, configure them, and manage their complete lifecycle. Spring's container uses
dependency injection (DI) to manage the components that make up an application.
This includes creating associations between collaborating components. As
such, these objects are cleaner and easier to understand, support reuse, and are
easy to unit-test.
Traditionally,
each object is responsible for obtaining its own
references to the objects it collaborates (Dependencies). So the hard coupled code is created which is very hard to test as we need to create all dependencies in order to test any object. Whereas in Dependency Injection, objects are given their
dependencies at creation time by some external mainly XML file and the container itself will take care of
collaborating objects while creating any object in the application. The key benefit of DI is loose coupling. Dependency injection was commonly referred to as inversion of control (IOC).
The coming sections will discuss how to instantiate Spring containers i.e. BeanFactory and ApplicationContext in the first section. Later, we will discuss how do we configure and wire the bean together and how the spring container will take care of object creation as per the given
dependencies in the spring-beans.xml file.
Java Discussion
- - Difference between BMT an
- - Replace getParameterValue
- - Interviewing Next week -
- - Sudoku solver
- - Setting tab order in swin




