spring framework IOC (2)

The so-called inversion of control, is to invoke the right to transfer the code from the caller to the called party (service provider).

2 Based on IOC (Inversion of Control) is called by

  The control code is changed to the caller from the callee, call transfer right means that code to the called party (also known as service side), without modifying the code of the caller,

  As long as modifying the configuration file to achieve the object of the switch.

  By inversion of control can be achieved by adding modules or remove modules linked by a unified configuration file, add or remove modules, configuration XML configuration file.

 

Call the right code (control) is transferred from the caller to the called party (service provider) design pattern called Inversion of Control (IOC)

 

IOC achieve a framework, we must solve two problems:

  1. The caller (service side), it is necessary to create a good object when the program starts, placed inside a container.

  2. The caller interface or use a reference to the class (without the use of new), you can create objects get

 

We will not have this new, but you can get objects created from a container to be called in reference to the class based on the interface or method called Dependency Injection

 

Therefore, inversion of control (the IOC), plus dependency injection is implemented oriented programming ideas interface.

 

Here to seize a focus on: Spring reason why the program can be achieved pluggable, are not achieve the new new , class or interface to use Keyihuode objects!

 

Guess you like

Origin www.cnblogs.com/weishenme/p/11019081.html