Spring aspect-oriented programming (i) AOP terminology

Source: Internet
Author: User

1, Connection point (Joinpoint):

A connection point is a specific point at which a slice can be inserted during program execution. The point can be when the method is called, when an exception is thrown, or even when the field is modified,

For spring, only method connection points are supported.

2. Tangent point (Pointcut):

A class has many methods, all of which are connection points, but not every method has to be inserted into a slice, so it is necessary to filter by certain conditions, which

The method to insert a slice after filtering is called a tangent, so the tangent point consists of a single live multiple connection points, which is a subset of the connection point collection.

3. Notice (Advice):

The work to be done by a slice is called a notification, and it is understood as "when" and "what" to do when it defines a pre-tangent (before) or a tangent (after).

Spring has 5 types of notifications:

①before: Pre-notification, executed before the tangent method.

②after: A post notification, which is notified after the tangent method returns, regardless of whether the method was executed successfully.

③after-returning: Notify after return, call notification after the Tangency method executes successfully.

④after-throwing: Notifies after a throw is thrown, and a notification is invoked after the Pointcut method throws an exception.

⑤arount: Surround notification, which invokes the notification both before the method call and after the method call. And can decide whether this method executes, when to execute.

4. Facets ( Aspect):

The combination of a notification and a tangent point is a tangent.

5. Introduction (Introduction):

The introduction is to add new methods and properties to a class so that they have new behaviors and properties without changing existing classes.

6. Weave in ( Weaving ):

Weaving is the process by which facets are applied to the target object, and multiple points can be woven into the target object's running cycle.

① compile time: weaving when the tangent target class is compiled. ASPECTJ is the compile-time weaving.

② class loading period: The tangent target class is loaded into the JVM that is weaving.

③ Runtime: Slices are woven at some point in the run, and Spring AOP is woven in this way, and the AOP container creates a proxy object dynamically for the target object.

Spring aspect-oriented programming (i) AOP terminology

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.