开发者

Define pointcut to capture an interface but not parent or sub interfaces

开发者 https://www.devze.com 2022-12-31 11:06 出处:网络
I was wondering how to define a pointcut in aspecJ that captures any method of an interface but not the methods of any parent or sub-interface.

I was wondering how to define a pointcut in aspecJ that captures any method of an interface but not the methods of any parent or sub-interface.

public interface A {
  void methodA();
}

public interface B extends A {
  void methodB();
}

public interface C extends B {
  void methodC();
}

I would like a poincut that only catches methodB() and not methodA() or met开发者_C百科hodC(). Is there any way i can do this in a general way without listing all the sub and super interfaces in the pointcut?


To find direct inheritance is not possible with Java or AspectJ.


Have you tried B.methodB(..) or B+.methodB(..) or even B+.*(..) AspectJ method patterns?

0

精彩评论

暂无评论...
验证码 换一张
取 消