The difference between adivisor and aspect in spring (self-understanding)

Source: Internet
Author: User

There are several concepts in AOP:

-Square/Facet (Aspect): A focus of modularity, this focus implementation may be additional crosscutting multiple objects. Transaction management is a good example of crosscutting concerns in the Java EE application. The aspect is implemented with spring's advisor or interceptor.
-Connection point/Weaving Point (joinpoint): an explicit point in the execution of a program, such as a call to a method or a particular exception being thrown.
-Notification (Advice): The action performed by the AOP framework at a specific connection point. Various types of notifications include "around", "before", and "throws" notifications.
-Pointcut (Pointcut): Specifies a collection of connection points to which a notification will be raised. The AOP framework must allow developers to specify pointcuts, for example, using regular expressions.

So "<aop:aspect>" actually defines the crosscutting logic, which is what is done on the connection point, and "<aop:advisor>" defines what the connection points apply <aop:aspect>. The benefit of spring is that multiple cross-cutting logic (that is, <aop:aspect> defined) can be used multiple times to provide reusability.

1. Adivisor is a special kind of aspect,advisor that represents spring aspect
2. Difference: Advisor only holds one pointcut and one advice, while aspect can be multiple pointcut and multiple advice

Tingfeng the Understanding :

Above

Our usual program execution can be seen as a horizontal arrow with linear execution characteristics ;

The small blue box can be called the break-in process of the linear execution of the pointcut PointCut;

There is a Pointcut, then you can execute the relevant logic on the Pointcut , Logitech is divided into two kinds , one is adivisor, There is also a Aspect;

Where the Advisor is like the small red circle on the left , can only have a advice, is a point logic ;

The downward arrow on the right can be thought of as Aspect, which can have multiple logical execution and is a polygon logic ;

The difference between adivisor and aspect in spring (self-understanding)

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.