Ayelet
Ayelet

Reputation: 1743

Exclude a specific method call (inside another method) from aspectj

I'm trying to exclude a specific method call inside another method from being intercepted:

public Class A {
   public void foo1() {...}

   public void foo2() {
     foo1();
   }

}

I only want to exclude the foo1 calls made from foo2, and not the other calls: someAObject.foo1() & someAobject.foo2() should be included.

Does anyone know how to do this using spring aop? Thanks!

Upvotes: 1

Views: 2510

Answers (2)

aepurniet
aepurniet

Reputation: 1727

I would recommend you stop using spring, barring that, if you can write two pieces of around advice for each call, you can set a ThreadLocal<Boolean> in the first and proceed, and check it in the second, not proceeding if its set. pretty ugly hack.

Upvotes: 0

Dave Syer
Dave Syer

Reputation: 58094

This should work:

execution(* A.*(..)) && !execution(* A.foo2(..))

Upvotes: 0

Related Questions