Spring AOP in-depth analysis

Source: Internet
Author: User

Introduction to AOP

AOP is one of the two main features of spring and the IOC. Mainly provides the aspect-oriented programming idea, distinguishes the object-oriented programming.

AOP principle (Dynamic proxy + reflection)

There may be many other method calls in a method body, and we can call each method invocation a connection point. For the target connection point we configured in the expression, we call the pointcut. The execution of each entry point, we can be seen as a one-time stack and into the stack operation. While the program is running, spring dynamically generates a proxy class for the target class in the form of reflection, and the slices are implanted into the proxy object. This allows the proxy class to handle some additional notification events before and after the target method executes.

AOP targets

The ultimate goal of AOP is to achieve complete decoupling of code. Complete modularity makes it easier to develop and manage large projects

  

Agent

Static proxy: Target interface, target class, proxy class. For large and complex projects, it is a huge project to write too many target proxy classes.

Dynamic Agent:

JDK Dynamic Proxy: Dynamically generated proxy classes, and the target class implements the same interface. (for proxy classes that implement multiple interfaces, there are some drawbacks)

Cglib Dynamic Proxy: Dynamically generated proxy class that inherits the target class.

Reflection

The process of forming an instance object by acquiring a class object in another way.

Spring AOP in-depth analysis

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.