AspectJ confusion with pointcut

How can I express a point that finds methods only when called from another method, but not directly?

For instance:

Foo() calls Bar() calls object.Method() 

and

 NotFoo() calls Bar() calls object.Method() 

I want pointcut to work inside Foo ()

I tried the "internal code", but this only works directly.

Thanks Eric

+4
source share
1 answer

Why do you need two connection points:

  • call method or constructor in the Bar class and within the Foo class or ultimately Foo () with a withincode pointer. The tip of this junction can, for example, set a flag that is true when called from Foo () and falso otherwise. This variable can be stored in a HashMap with the stream as a key to avoid concurrency issues.
  • withincode The constructor of Bar () or within the class Bar and call object.Method (). The tip of this junction point should also check if the flag is set to true. Finally, set the Foo flag to false again.
+4
source

All Articles