带有注释的类的子类的@AspectJ切入点

Han*_*örr 5 java aop aspectj

我正在寻找一个切入点来匹配类中的方法执行,这些类将类与特定的注释子类化.优秀的AspectJ备忘单帮我创建了以下切入点:

within(@my.own.annotations.AnnotationToMatch *) && execution(* *(..))
Run Code Online (Sandbox Code Playgroud)

这匹配带有@AnnotationToMatch的类A的所有方法调用,但不匹配扩展A的类B的方法.如何匹配两者?

ale*_*hro 3

public aspect AnnotatedParentPointcutAspect {   

//introducing empty marker interface
declare parents : (@MyAnnotation *) implements TrackedParentMarker;

public pointcut p1() : execution(* TrackedParentMarker+.*(..));

before(): p1(){
    System.out.println("Crosscutted method: "
            +thisJoinPointStaticPart.getSignature().getDeclaringTypeName()
            +"." 
            +thisJoinPointStaticPart.getSignature().getName());
}
}
Run Code Online (Sandbox Code Playgroud)