Today continue to learn Spring in action 3rd and run the example in the book, to the 4th Chapter AOP, is to join a audience class as a slice, the performer of the Perform () method seat pointcut to cut into.
Related code:
<Aop:aspectref= "Audience"> <Aop:pointcutID= "Performance"expression= "Execution (* com.springinaction.springidol.Performer.perform (..))" /> <Aop:beforePointcut-ref= "Performance"Method= "Takeseats"/> <Aop:beforePointcut-ref= "Performance"Method= "Turnoffcellphone"/> <aop:after-returningPointcut-ref= "Performance"Method= "Applaud"/> <aop:after-throwingPointcut-ref= "Performance"Method= "Demandrefund"/> </Aop:aspect>
PackageCom.springinaction.springidol; Public classAudience { Public voidtakeseats () {System.out.println ("The audience is taking their seats."); } Public voidTurnoffcellphone () {System.out.println ("The audience is turning off their cellphones."); } Public voidapplaud () {System.out.println ("Clap clap clap clap."); } Public voidDemandrefund () {System.out.println ("Boo! We Want out Money back! "); }}
This will report the following 2 errors when testing:
Java.lang.noclassdeffounderror:org/aopalliance/aop/advice
Java.lang.noclassdeffounderror:org/aspectj/weaver/bcexception
We need to import the Spring-framework-3.2.11.release-dist.zip based on the previously imported Com.springsource.org.aopalliance-1.0.0.jar, Aspectj-1.6.13.jar two packs. They can all be downloaded on their own official website.
In particular, the direct import of Aspectj-1.6.13.jar is not possible, it needs to be decompressed, and then extracted out of Aspectjrt.jar, Aspectjtools.jar, Aspectjweaver.jar, Org.aspectj.matcher.jar into the Eclipse project, as shown in.
Spring Development First Step (ii)