I've scanned the Spring 2.5.1 and AspectJ docs on this, but I can't find the best solution. It may well be staring me in the face ...
The question is - when using Spring AOP with CGLIB2 proxies, can I declare a pointcut to match all methods called only on a particular concrete class, including methods that are actually declared in that classes' super-types?
Example - I have two concrete classes com.mypackage.MySubClass extends com.mypackage.MyBaseClass, and MyBaseClass declares a method methodInBaseClass(). I want a pointcut on execution of any method in MySubClass, including methodInBaseClass(). I do _not_ want the pointcut to match execution of methodInBaseClass() in MyBaseClass or subclasses other than MySubType.
If I declare:
... I don't seem to generate advice on execution of methodInBaseClass() in MySubClass. Switching to matching MyBaseClass will provide advice on MySubClass#methodInBaseClass(), but also generates unwanted matches in the base class and other subtypes.Code:<aop:pointcut id="anySubClassMethod" expression="execution(* com.mypackage.MySubClass.*(..))" />
I'm guessing that I could achieve this by using @AspectJ notation and combining expressions (any thoughts on the best expression?), but if possible, I'd like to stick with Spring XML AOP configuration.
I realise that this might be a stretch, and that proxying is normally by interfaces, but - is this possible?