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?