What does the Spring Framework do?

In the previous example, we removed the tight coupling between BusinessServiceImpl and DataServiceImpl by creating appropriate interfaces and using them. However, we need to write code manually to create instances and wire them together. And that's the problem the Spring Framework solves.

The core of the Spring Framework, called the Spring IoC container, is responsible for identifying the dependencies and instantiating and wiring them together.

Before the Spring IoC container can do its magic, a couple of questions need to be answered:

  1. How does the Spring IoC container know which beans to create? Specifically, how does the Spring IoC container know to create beans for the BusinessServiceImpl and DataServiceImpl classes?
  2. How does the Spring IoC container know how to wire beans together? Specifically, how does the Spring IoC container know to inject the instance of the DataServiceImpl class into an instance of the BusinessServiceImpl class?
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset