What is spring control inversion (IOC )?

Source: Internet
Author: User

What is control reversal? The famous saying in Hollywood is: You stay and don't change. I will look for you later. What does it mean?

 

Just like an emperor and Eunuch: One day the emperor wants to lucky a beautiful girl, so he told the eunuch that I want to be lucky tonight, and the Emperor will not tell the eunuch that he will go back to the palace at the time of the evening, he will only tell the eunuch which beauty he wants. Everything else will be arranged by the eunuch. At night, the emperor will go back to the palace.Naturally, there will be beautiful women in the Emperor's dragon bed, this is the control reversal, And the beauty to the Emperor's Inner Palace is injection, eunuch is the injection controller class beanfactory in the framework, responsible for finding beautiful women and sending them to the Dragon bed. The whole harem can be seen as a spring framework. Beautiful women are the JavaBean under the control of spring.

However, the traditional model is that a hungry man goes to the lady to issue a ticket, find the foreman, and help introduce a cloud, so the foreman starts to introduce Zhang Luo to him and give him a suitable one, return the lady to the foreman and come back next time. In this process, the foreman queries the context. One function of the foreman is to find the lady they want, which is the Lookup () method, the Miss directory in the foreman is JNDI // Java Naming and Directory Interface, Miss is EJB, hunger and thirst is the client, and qinglou is the EJB container.
Have you seen the difference? It is very troublesome for a hungry man to look for a young lady. Not only do he have to look for it, but he still has to give it back after use, and the Emperor turned it over, so he does not have to worry about anything and handed it over to the eunuch for handling, the control is transferred to the Eunuch's hands, rather than the emperor. If necessary, the eunuch can inject the control. Haha, this is the beauty of spring, spring also provides support for multiple mainstream frameworks and can be integrated with other open-source frameworks.

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.