[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
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
aspectj-users@xxxxxxxxxxx
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
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users
|
Attachment:
smime.p7s
Description: S/MIME Cryptographic Signature