Controlled inversion (ioc,inversion of Control), is a concept, an idea. Refers to the object that is traditionally manipulated directly by the program code to the container, through the container to achieve the assembly and management of the object. Control inversion is the transfer of control over objects, which is reversed from the program code itself to the outer container.
IOC is a concept, a kind of thought, the way of realization is various. There are two types of implementations that are currently popular: Dependency Injection and Dependency lookup. The application of dependency injection is more extensive.
- Dependency Lookup (Dependency lookup,dl): The container provides callback interfaces and context to the component, and the program code needs to provide a specific way to find it. It is more typical to rely on the lookup of the Jndi service interface (Java naming and Directory Interface).
- Dependency Injection (Dependency injection,di): The program code does not do the location query, these tasks are done by the container itself.
Dependency Injection DI refers to the process of running a program, if you need to invoke another object assistance, you do not need to create the callee in code, but rather rely on the external container, created by the external container and passed to the program.
Spring's dependency injection has virtually no requirement for callers and callers to fully support the management of dependency between POJO.
Dependency Injection is by far the best decoupling method . Dependency Injection lets Spring's beans be organized together in a configuration file, rather than being coupled in a hard-coded fashion.
[Js-spring] Spring vs. IOC (control inversion, inversion of controls)