Understanding of AOP, AOP

Source: Internet
Author: User

Understanding of AOP, AOP

AOP: Aspect-Oriented Programming. You can see a good understanding and a good example of AOP when watching the video.

 

Optimal example: Permission control.

In permission control, the original method (not the original method I will not) is to determine the permissions of a person in each place where permissions need to be controlled through if, then, grant or not grant a certain permission. For example:

In this process, once authorization is required for every button, page, or other element, such a judgment is required. The process of this judgment is obviously code duplication. Therefore, it is necessary to separate the if judgment. We only need to focus on the do xxx part.

The process of separating if judgment is an embodiment of AOP.

Java extracts AOP Using the proxy method. Simply put, it is to set a proxy object to intercept all business methods, and then determine whether the user has the access permission. if the user has the permission, the service method can be executed, otherwise, the execution of business methods is not allowed.

That is, assign all business implementation methods of the target object to the proxy object. In this way, you only need to perform operations on the proxy object, rather than redundant code on the target object.

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.