我有一个类和一个注释
@Retention(RetentionPolicy.RUNTIME)
public @interface AnnotateMethod
{
public abstract boolean value();
}
class AAA{
@AnnotateMethod(value=true)
void method()
{
}
@AnnotateMethod(value=false)
void method1()
{
}
void method2()
{
}
}
我想编写一个aspectj切入点,它将捕获具有值= true的AnnotateMethod注释的所有方法。我该怎么办?
答案 0 :(得分:0)
这应该是你要找的东西:
@Pointcut("execution(* *(..)) && @annotation(anMethod) && if()")
public static boolean annotatedMethod(final AnnotateMethod anMethod) {
return anMethod.value();
}
定义所有具有注释的方法执行的切入点,并在执行建议之前检查所述注释是否具有值== true。
不能保证立即运行,因为我在这里处理内存,但它应该是好的。 ;)