Matching a Joinpoint Based on Interface Implementation
Something I had a little trouble with while toying with aspects was getting a joinpoint pattern to match methods where the return type implemented some interface. I tried the following:
execution(public AnInterface *(..))
But, that only works if I am returning the explicit interface as the return type… it doesn’t match if the return type happens to implement that interface. However, according to the AspectJ Programming Guide, we’ll need to use the + operator to match a subtype. So, simply put, we just modify the above joinpoint pattern:
execution(public AnInterface+ *(..))
That does the trick…
If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!







