我正在寻找一个切入点来匹配类中的方法执行,这些类将类与特定的注释子类化.优秀的AspectJ备忘单帮我创建了以下切入点:
within(@my.own.annotations.AnnotationToMatch *) && execution(* *(..))
Run Code Online (Sandbox Code Playgroud)
这匹配带有@AnnotationToMatch的类A的所有方法调用,但不匹配扩展A的类B的方法.如何匹配两者?
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)
| 归档时间: |
|
| 查看次数: |
4781 次 |
| 最近记录: |