java - PointCut to match method annotated with certain params to the annotation -


i have pointcut

@pointcut("execution(@com.foo.bar.aspect.annotation.myannotation* * (..))"           + "&& @annotation(annot)") public void anyfoo(myannotation annot) {  } 

myannotation looks this:

@target(elementtype.method) @retention(retentionpolicy.runtime) public @interface myannotation {    boolean isfoo();     string name; } 

let's annotate method annotation isfoo set true

@myannotation(isfoo = true, name = "hello") public void dothis() {    system.out.println("hello, world"); } 

how write pointcut matches method annotated myannotaion , isfoo = true?

i tried doesn't seem work

@pointcut("execution(@com.foo.bar.aspect.annotation.myannotation(isfoo = true, *) * * (..))"           + "&& @annotation(annot)") public void anyfoo(myannotation annot) {  } 

you cannot write pointcut because aspectj not support it. need use like

@pointcut("execution(@com.foo.bar.aspect.annotation.myannotation* * (..))"           + "&& @annotation(annot)") public void anyfoo(myannotation annot) {     if (!annot.isfoo())         return;     // continue here if annotation has right parameter value     // ... } 

Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -