@AfterReturning(value = "execution(WeaveMe.new(..))", returning = "obj")
public void aop(WeaveMe obj) { // Warning: advice defined in poc.ToInject has not been applied.
obj.setA(100);
}
}
class WeaveMe {
private int a;
public int getA() {
return a;
}
public void setA(int a) {
this.a = a;
}
}
public class App {
public static void main(String[] args) {
WeaveMe weave = new WeaveMe();
System.out.println(weave.getA());
// Error: I am expecting 100 but am getting 0.
}
}
The advice does not seem to be working but I get a compiler error in the IDE (AJDT 2.0.0 on Eclipse).
What I prefer from the weaving is to see the bytecode of WeaveMe
constructor changed. ( and not that of App , where it is getting called
) since I need to use this in a larger context of Spring injection.
Can somebody help with the same, as to if the advice is correct. Thanks.