I'm trying to define a pointcut around a method annotated with a custom annotation. The annotation has one parameter that I would like to include a check in the pointcut definition.
This is the annotation:
public @interface MyAnno {
String[] types;
}
An example of how the annotation could be applied:
public class MyClass {
@MyAnno(types={"type1", "type2"})
public void doSomething() {
// ...
}
@MyAnno(types={"type3"})
public void doSomethingElse() {
// ...
}
}
Now I would like to have two pointcut definitions which select those two methods, based on the contents of the annotation.
Creating a pointcut on the annotation itself is relatively easy:
@Pointcut("@annotation(myAnno)")
public void pointcutAnno(MyAnno myAnno) {
}
@Pointcut("execution(* *(..)) && pointcutAnno(myAnno)")
public void pointcut(MyAnno myAnno) {
}
This will match every occurrence of the of @MyAnno. But how can I define two pointcuts, one matching @MyAnno with types containing "type1" and the other matching @MyAnno with types containing "type3"