JBoss.org Community Documentation
This will be explained with an example. Consider the following case:
public class Base{ void test(){} } public class Child{ } public class ChildTest{ void test(){} }
<aop> <prepare expr="execution(* POJO->test())"/> <bind pointcut="execution(* Base->test())"> <interceptor class="BaseInterceptor"/> </bind> <bind pointcut="execution(* Child*->test())"> <interceptor class="ChildInterceptor"/> </bind> </aop>
Base base = new Base(); //1 Child child = new Child(); //2 ChildTest childTest = new ChildTest(); //3 base.test(); //4 child.test(); //5 childTest.test(); //6
With the "old" weaving we needed an exact match on methods for advices to get bound, meaning that:
The discrepancy is between calls 5 and 6, we get different behaviour depending on if we have overridden the method or are just inheriting it, which in turn means we have to have some in-depth knowledge about our hierarchy of classes and who overrides/inherits what in order to have predictable interception.
The new weaving model matches differently, and treats inherited methods the same as overridden methods, so:
Note that for this to work, the parent method
MUST
be woven. In the previous example
Base.test()
has been prepared.