Our previous approach was to use
@AfterReturning (value= "Execution (* com.guigu.shen.anotion.userdaoimpl.* (..))", returning= "ReturnVal") Public void afterreturning (joinpoint joinpoint,object returnval) {System.out.println ("This is Afterreturning method"); System.out.println (returnval); }
Such a way. In this way, the tangency point and the notice are closely linked, and we change the other way. Use @pointcut annotations to define pointcuts. Untie the two.
The cases are as follows:
The second step defines a notification, using the tangent point
What is written here is the definition of the method that is modified with @pointcut annotations.
@After ("MyPoint ()")publicvoid after () { System.out.print ("final notification, freeing resources" );}
First step: Define a pointcut @pointcut ("Execution (* com.guigu.shen.anotion.userdaoimpl.* (..))" )
Must be private void no parameter privatevoid mypoint () { }
The effect is exactly the same as before.
Extension: Is there any more I want to intercept a pointcut? I already have a tangent point above, so can a advice have multiple pointcuts. The answer is: Of course you can.
In the development of such a requirement, that is, to cut the DAO layer, but also to cut the server over there.
19SPRING_AOP Programming (AspectJ) _ using @pointcut annotations to define Pointcuts