Home » spring » Inversion of Control/Dependency Injection

Inversion of Control/Dependency Injection

The basic principle is that beans define their dependencies (i.e. the other objects they work with) only through constructor arguments, arguments to a factory method, or properties which are set on the object instance after it has been constructed or returned from a factory method

Dependency Injection are of two types

1 Constructor based dependency injection.
2 Setter based dependency injection

setter-based dependency injection is realized by calling setters on your beans after invoking a no-argument constructor or no-argument static factory method to instantiate your bean. Beans defined in the BeanFactory that use setter-based dependency injection are true JavaBeans

constructor-based dependency injection is realized by invoking a constructor with a number of arguments,each representing a collaborator or property. Additionally, calling a static factory method with specific arguments, to construct the bean.

Managed by MochaHost - Fast & Easy WordPress Hosting