IOC (Inversion of Control) or Dependency Injection

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

JAVA Means DURGA SOFT

DURGA SOFTWARE SOLUTIONS ,202 HUDA Maitrivanam, Ameerpet , Hyd. Ph: 040-64512786 Page 1
JAVA Means DURGA SOFT

IOC (Inversion of Control) or Dependency Injection:

Problem: Dependency Look Up i.e. If the resource of the application spending some time to
search and gather its dependent values required in the business logic from the other resource
of the application then it is called as Dependency Look Up. In Dependency Look Up resource
pulls its dependent values from other resources of the application.

Ex: The way we get the JDBC data resource object from JNDI registry comes under Dependency
Look Up.

In dependency look up resource cannot used dependent values directly in the business
logic. The resource must spend time to search and gather dependent values before utilizing
them in business logic.

Solution: Use Dependency Injection i.e. if underlying server software or container software or
frame work software or JRE or special resource of the application dynamically assigns its
dependent to resources then it is called as Dependency Injection.

In Dependency Injection resource can directly use the injected values in business logic
without spending time to search and gather them.

DURGA SOFTWARE SOLUTIONS ,202 HUDA Maitrivanam, Ameerpet , Hyd. Ph: 040-64512786 Page 2
JAVA Means DURGA SOFT

Ex:

a) JRE/JVM performs Dependency Injection while instantiating classes using parameterized


constructor.
b) The way ActionServlet writes form data to Form Bean class object comes under
Dependency Injection.
c) Spring container can perform Dependency Injection on Spring beans.
d) Life cycle methods, Event handling methods cannot perform Dependency Injection
because they never give choice to the programmer to pass the explicit data.

Note: Dependency Injection might be a design pattern, whereas Inversion of Control is


implemented using Dependency Injection. Dependency injection is the main method to
implement Inversion of Control.

DURGA SOFTWARE SOLUTIONS ,202 HUDA Maitrivanam, Ameerpet , Hyd. Ph: 040-64512786 Page 3
JAVA Means DURGA SOFT

DURGA SOFTWARE SOLUTIONS ,202 HUDA Maitrivanam, Ameerpet , Hyd. Ph: 040-64512786 Page 4

You might also like