我有这个切入点
@Pointcut("execution(@com.foo.bar.aspect.annotation.MyAnnotation* * (..))"
+ "&& @annotation(annot)")
public void anyFoo(MyAnnotation annot)
{
}
MyAnnotation
看起来像这样:
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface MyAnnotation
{
boolean isFoo();
String name;
}
假设我用这个注释注释了一个方法,其中 isFoo 设置为 true
@MyAnnotation(isFoo = true, name = "hello")
public void doThis()
{
System.out.println("Hello, World");
}
如何编写我的切入点以使其仅匹配用MyAnnotaion
AND注释的方法isFoo = true
?
我试过这个,但它似乎不起作用
@Pointcut("execution(@com.foo.bar.aspect.annotation.MyAnnotation(isFoo = true, *) * * (..))"
+ "&& @annotation(annot)")
public void anyFoo(MyAnnotation annot)
{
}