Hi,
Let's say my code looks like this:
Now I want to use AOP to inject the myInterface.method1.Code:public interface myInterface{ void method1(); } public class myClass implements myInterface{...}
Above code never works. But if I change "@Before" to "@Around", and modify the signature, it works fine.Code:@Aspect public class myAspect{ @Pointcut("execution(* myInterface.method1(..)) && target(t)") private void myPointcut(myInterface t){} @Before("myPointcut(t)") public void myBefore(myInterface t){...} }
The reason I need the "target" is that I want to modify the target object before the method invoking. I am new to AOP. I am not even sure if it is a valid use case.


Reply With Quote
