Refer to the book "Spring in Action" 1. Aopbefore you wak the walk that you had to learn to walk the Walk.1) advice---the job of a aspect (what and when)/before/aft Er/after-returning/after Throwing/around:beforen and After2) join points---a point in the execution of the application WH Ere an aspect can is plugged in.3) pointcuts---where the advice should be WOVEN4) aspects---advice & joincuts5) Introduc tion---Add new methods or attributes to existing classes.6) weaving---the process of applyng aspects to target object to CR Eate a new proxied object./compile time/class load time/runtime2. How spring supports AOP 1) Classic spring proxy-based AOP2) pure-pojo aspects3) @AspectJ annotation driven aspects.4) injected Aspe CTJ aspects. 3.creating aspect in spring1) selecting join points with pointcuts.eg:execution (* concert. Performance.perform ())
and Bean (' Woodstock ') 2) Creating annotated aspects
@Aspect Public classAudience {@Pointcut ("Execution (* * concert. Performance.perform (..)) ") Public voidperformance () {} @Before ("Performance ()") Public voidSilencecellphones () {System.out.println ("Silencing cell Phones");} @Before ("Performance ()") Public voidtakeseats () {System.out.println ("Taking seats");} @AfterReturning ("Performance ()") Public voidapplause () {System.out.println ("Clap clap Clap!!!");} @AfterThrowing ("Performance ()") Public voidDemandrefund () {System.out.println ("Demanding a refund");}}
Configuration:
@Configuration @enableaspectjautoproxy@componentscan Public class concertconfig {@Bean public audience audience () {returnnew audience ();}}
3) handling Params in advice
4) Annotation Introductions
Dynamic language like Ruby and groovy can add new methods to an object or class.
Spring Learning--4