To add my two cents :
With a call pointcut you are able to handle the source and the target, with
an excecution pointcut you can handle the source only.
It is more academically said below.
Cordialement / Best regards
Jean-Louis Pasturel
_____
De : [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] De la part de Paulo Alexandre
Corigo Zenida
Envoyé : mercredi 4 juin 2008 18:41
À : [email protected]
Objet : Re: [aspectj-users] What's the different between call and execution
What Dean said is absolutely true. Anyway, I just would like to say that,
additionally, a call has more information about the join point, since you
can access the invocation static context, through the variable
thisEnclosingJoinPointStaticPart. E.g.,
public class C {
public void foo() {
bar();
}
public void bar() {
}
}
public aspect A {
// the output will be:
// call(void C.bar())
// execution(void C.foo())
before() :
call(public void C.bar()) {
System.out.println(thisJoinPoint);
System.out.println(thisEnclosingJoinPointStaticPart);
}
// the output will be:
// execution(void C.bar())
// execution(void C.bar())
before() :
execution(public void C.bar()) {
System.out.println(thisJoinPoint);
System.out.println(thisEnclosingJoinPointStaticPart);
}
}
Kind regards,
Paulo Zenida
Dean Wampler escreveu:
For calls, the advice is inserted just before transferring control to the
method. For execution, the advice is inserted just after transferring
control, within the stack frame of the method. (This is my naive way of
viewing it.)
One implication is that you have to use call pointcuts if you want to advise
invocations of code in a 3rd-party jar that you aren't modifying with
advice. For example, suppose you want to log all calls to HashMap.get() for
some reason. Call pointcuts would add advice everywhere in your code that
get() is called. If you tried to write an execution pointcut for the get
method, it would only work if you inserted the advice in the JDK!
An advantage of execution advice, when you can use it, is that you only have
the overhead of advice code in one place, whereas call advice is inserted
everywhere that target method is called.
They AspectJ docs have better explanations of all this ;)
dean
On Jun 4, 2008, at 10:52 AM, Noppanit Charassinvichai wrote:
Can anyone please tell me what is the different between call and execution
in Pointcut? Thank you
_______________________________________________
aspectj-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users
Dean Wampler, Ph.D.
dean at objectmentor.com
http://www.objectmentor.com
See also:
http://www.aspectprogramming.com AOP advocacy site
http://aquarium.rubyforge.org AOP for Ruby
http://www.contract4j.org Design by Contract for Java5
_____
_______________________________________________
aspectj-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users
*********************************
This message and any attachments (the "message") are confidential and intended
solely for the addressees.
Any unauthorised use or dissemination is prohibited.
Messages are susceptible to alteration.
France Telecom Group shall not be liable for the message if altered, changed or
falsified.
If you are not the intended addressee of this message, please cancel it
immediately and inform the sender.
********************************_______________________________________________
aspectj-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users