Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Restricting a pointcut

Fabiano listas wrote:
Hello!

In the example shown below, I'd like to restrict a pointcut to affect
only the superclass, not the subclasses that extend it. Is there a
generic way to do this? Do I need to especify all subclasses that my
pointcut can't affect?

 public aspect TestingPointcut {
   pointcut p1(): call(public * Figure.printPosition());
   before(): p1() {
     System.out.println("TestingPointcut: " + thisJoinPoint);
   }
 }

You need to use within(TypePattern) to restrict your pointcut to a specific type (or group of types). The fact that call pointcut matches overrding methods is a Good Thing in most situations.

R.


Back to the top