我想知道是否有办法从主函数中获取变量并在方面使用它。我知道建议会在之前和之后执行,before()
但他们怎么能得到和/或?after()
methodeOne
VAR1
VAR2
public class AOPdemo {
public static void main(String[] args) {
AOPdemo aop = new AOPdemo();
aop.methodeOne(5);//Call of the function wrapped in the aspect
int VAR1;
//VAR1 variable im trying to send to the aspect
}
public void methodeOne(int VAR2){
//VAR2 another variable i'm trying to send to the aspect
System.out.println("method one");
}
}
public aspect myAspect {
pointcut function():
call(void AOPdemo.methode*(..));
after(): function(){
int VAR1;//Trying to get this variables
int VAR2;
System.out.println("aspect after...");
}
before(): function(){
System.out.println("...aspect before");
}
}