When spring AOP declares the tangent class, how do you declare the pointcut?

Source: Internet
Author: User

8.2.3 declaring a Pointcut

Recall that pointcuts determine join points of interest, and thus enable us-to-control when advice executes. Spring AOP only supports method execution joins points for Spring beans, so can think of a pointcut as Matchin G The execution of methods on Spring beans.

A pointcut declaration has both parts:a signature comprising a name and any parameters, and a pointcut expression that Det Ermines exactly which method executions we is interested in.

Pointcut declaration There are two parts oh, one is that the signature method contains the method name and parameters. The other is the pointcut expression, which is used to affirm which methods are executed.

In the @AspectJ Annotation-style of AOP, a pointcut signature are provided by a regular method definition, and the Pointcut Expression is indicated using the @Pointcut annotation (the method serving as the Pointcut signature must has a return type).

Pointcut signature must be no return worth.

Here's an example:

An example would help do this distinction between a pointcut signature and a pointcut expression clear. The following example defines a pointcut named ‘anyOldTransfer‘ that would match the execution of any method named ‘transfer‘ :

@Pointcut ("Execution (* transfer (..))") The pointcut expressionprivate void Anyoldtransfer () {}//the pointcut signature

The pointcut expression, that forms, the value of the @Pointcut annotation is a regular AspectJ 5 pointcut expression. For a full discussion of AspectJ ' s pointcut language, see the AspectJ Programming Guide (and for extensions, the AspectJ 5 Developers Notebook) or one of the books on AspectJ such as "Eclipse AspectJ" by Colyer et. Al. or "AspectJ in Action" by Ramnivas Laddad.


When spring AOP declares the tangent class, how do you declare the pointcut?

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.