Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] cflow or something like that

robert kuzelj wrote:

hi,

how do i solve the following situation

i have two class
class A{public void executeA(){...}}
class B{public void executeB(){...}}

what i want to do is to get the execution
of B.executeB but only if its called
by A. the problem thou is that executeB
is never directly called by A thou its
somewhere in the callstack.

Does this work for you?

public class Bob {

  static class A{void executeA(){ System.out.println("A"); c(); }}
  static class B{void executeB(){ System.out.println("B");      }}
  static void c() { new B().executeB(); }

  static aspect Aspect {
    pointcut p(): execution(* B.executeB())
               && cflow(execution(* A.executeA()));
    before(): p() { System.out.println(thisJoinPoint); }
  }

  public static void main(String[] args) {
    new A().executeA();
    new B().executeB();
    c();
  }
}

Jeff

i trid all possible poitcut combinations
but luck sofar

here an example
pointcut test():
    call(public void B.executeB())
&&  (       cflowbelow(within(A))
        ||  cflow(within(A))
        ||  within(A)
        ||  cflowbelow(call(* A.(*)))
        ||  cflow(call(* A.(*)))
    )
&&  if(true);

so basically what i want is something like this

pointcut test():
    call(public void B.executeB())
&&  incallstack(call(* A.*(*)));

well the solution is easy enough. i can parse
the callstack in the advise for the pointcut
call(public void B.executeB()) myself. but i was somehow
under the impression i could do that in a more declarative
way.

any suggestions?

ciao robertj
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-users




--
Jeffrey Palm --> http://www.ccs.neu.edu/home/jpalm


Back to the top