IOC and AOP of Spring core technology

Source: Internet
Author: User

IOC:

The IoC, the control reversal, is the relationship between the container control program and not the traditional implementation, which is implemented by the program code directly with new. Control is transferred from the application code to the external container, so called control inversion. IOC is also called Di, dependency injection, so-called dependency injection, that is, the dependencies between components are determined by the container at run time, that is, the container dynamically inject some kind of dependency into the component (System boot, USB device loading, the win OS running in the computer relies on USB device for data access, Then write to the win file access component)


In a business class, if you want to use ClassA, do you want to new a ClassA object? This is equal to the Business Class initiative to create an object. After quoting spring, what do you do with it? It's the business class. When a ClassA object is needed, the spring IOC container is created to create the ClassA object, which is then injected into the business class where it is needed. This shows the meaning of control inversion. That is, creating this ClassA object is actively created by the business class and changed to passively accept the injection of the spring IOC container.

Aop:

AOP, aspect-oriented programming, the core competency is a technology that can dynamically and uniformly add functions to a program without modifying the code by pre-compiling and running-time dynamic agent.

Aspect-oriented, multi-use in logging, transaction management, security authentication and so on. (Interceptors are an implementation of AOP ideas)
It's like acting in a sense. For example, you want to record the log while executing the business class. You can insert a portion of the logging code after executing the code for the Business class. But there are a lot of business classes, and if every business class calls this log code, it's a hassle, and the code that writes the log is coupled to the code of the Business class. So then you can use AOP, the code to write the log out, call it a section, the dynamic cut into the specified method of the specified position, this position is called the pointcut.
This kind of thought is the aspect-oriented thought, it is actually a complement to the object-oriented thought.

IOC and AOP of Spring core technology

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.