[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] Trying to find pointcut for direction recursive methods
|
Hi steenreem,
AspectJ unfortunately does not support a mechanism similar to named
references in regular expressions, so you have no way to express
directly something like this :
withincode(group(* *(..))) && call(group))
and have it replace "group" with the current method signature as it
scans the code.
So, as you properly guessed, you have to use the "if" pointcut, which is
a performance nightmare but for a school test can work.
You should use thisEnclosingJoinPointStaticPart in the second part of
your if (and thisJoinPointStaticPart in the first one, just to make it
faster).
thisEnclosingJoinPointStaticPart contains the "lexically enclosing"
joinpoint, so in this case :
public String doSomething() {
return this.doSomethingElse();
}
if you match the call(* *.doSomethingElse()) the enclosing join point
will be execution(..... doSomething()). You can implement your logic in
your "if" using it.
Hope this helps,
Simone
steenreem wrote:
Hello.
I'm working on an assignment for school and I'm supposed to find all methods
that are direct recursive.
I haven't gotten very far yet. The pointcut I tried was:
pointcut directionRecursion(): !adviceexecution()
&& withincode(* *(..))
&& call(* *(..));
Now I need to specify that the method in 'withincode' is the same as in
'call'
So I thought of using " && if(thisJoinPoint.getSignature().getName() == ...
) "
But I can't get any further.
After I finally get the pointcut right. I rather wouldn't write advice for
this pointcut. Instead I just want to loop over all the pointcuts and for
example print the method names of the recursive methods.
Could someone explain to me how to do this?
Thanks a bundle!
--
Simone Gianni CEO Semeru s.r.l. Apache Committer
http://www.simonegianni.it/