On a lighter note I have one more question. Directly or indirectly I am using AOP for quite some time in my Spring app. But theoretical when it comes to distinguish between various terminologies aspect, advice, pointcut, joinpoint; I get confused.
You can think of
- aspect as a class-like concept.
- advice as an automatically called method
These two are usually understood easily.
Join point and pointcut concept take a bit longer. One way to think:
- Join points are like rows in database--they just exists much the same way methods just exists.
- Pointcuts are like SQL statements--they select join points just as SQL selects rows.
Just to make sure my understanding is clear. Let's take example of logging aspect. I want to log before all methods starting with 'test'. (Hypothetically, not sure whether you can do based on method pattern)
Aspect - It's like calling logging framework, the Process of logging
Advice - I am advising the AOP to call log methods on logging framework, like a method
Joinpoints - are actually beginning of methods, AOP intercepts at this point to do some other stuff. i.e. beginning of methods testA(), testB(), testC(), somethingElseD(), somethingElseE()
Point cuts - Pointcut selects those joinpoints based on your aop settings, i.e. out of all the methods select testA(), testB() and testC() and intercept only those.
A JoinPoint is any Method in your app's code that you wrote whether you were using AOP or not.
An advice is code you want to run when that JoinPoint method is being called, without adding the code directly into your app's method.
An Aspect is the class that holds the advice code.
A Pointcut is telling AOP which Joinpoints you want your advice code to run with/on.
Aspect: an aspect, a feature
Join point: a point that aspects can join.
Advice: an aspect joins at a point and advices somebody at that point, the latter action is called ... "advice".
Pointcut: draw line to cut points, aspect will advice somebody at the cut points
Hope this helps.
SCJA 1.0, SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJP 5.0, SCEA 5, SCBCD 5; OCUP - Fundamental, Intermediate and Advanced; IBM Certified Solution Designer - OOAD, vUML 2; SpringSource Certified Spring Professional