I am using AspectJ with annotation and trying to find how to disable all AspectJ's advices to stop advicing method from user's input (e.g. Boolean tracked = false).
Here is my code for main class.
package testMaven;
public class MainApp {
public static void main(String[] args) {
testing test = new testing();
test.aa(1000);
test.setDd(3);
}
}
Here is the Aspect annotated class.
package testMaven;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.annotation.Before;
@Aspect
public class aspecter {
public aspecter(){
}
boolean tracked = false;
@Before("execution(* testMaven.testing.aa(..)) && if(tracked)")
public void testBefore(){
System.out.println("yooi");
}
@Before("execution(* testMaven.testing.setDd(..)) && if(tracked) ")
public void testBefore2(){
System.out.println("yooi2");
}
}
if(tracked) will give an error of "Syntax error on token "execution(* testMaven.testing.aa(..)) && if(tracked) ", "in annotation style, if(...) pointcuts cannot contain code. Use if() and put the code in the annotated method" expected".
Is there anyway that I could specify the if() method based on my specification?
Thanks