Open Tao Spring3 (6.7)-AOP 6.7 Notification order

Source: Internet
Author: User

If we have multiple notifications that we want to execute at the same connection point, how is the order of execution determined? Spring AOP uses ASPECTJ precedence rules to determine the order in which notifications are executed. There are two cases in which the order of execution in the same slice is notified, and the order in which the notifications are executed in different slices.

First let's look at the

1) The Order of notification execution in the same slice:6-6.

Figure 6-6 Notification execution order in the same slice

If you define two identical type notifications in the same facet (as if they were pre-notifications or surround notifications (before proceed)) and execute at the same connection point, their order of execution is unknown, and if you do need to specify the order of execution, you need to refactor the notification to two facets and then define the order in which the slices are executed.

2) Order of notification execution in different facets: when the same type of notification defined on different facets needs to be performed at the same connection point, the order of execution of the two notifications will be unknown if the execution order of the slices is not specified.

If they need to be executed sequentially, you can control the order in which notifications are executed by specifying the priority of the facets.

In spring, you can specify a tangent priority by implementing the Org.springframework.core.Ordered interface on the facet implementation class or by using the order annotation. In multiple facets, the Ordered.getvalue () method returns the lower value of the value (or annotation value) with a higher priority, as shown in 6-7.

In this we do not recommend the implementation of the ordered interface method, so no introduction

Open Tao Spring3 (6.7)-AOP 6.7 Notification order

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.