David_W (70) [Avatar] Offline
#1
Personally, I find dynamic proxies really annoying. Assuming that all of the classes whose behaviour is to be modified are instantiated by some framework (eg, Spring) - and this is a big assumption - people always seem to forget that the proxy only intercepts calls from OUTSIDE the class. So, using Spring, I set up a pointcut that should intercept calls to method abc for class Foo. And class Bar calls abc - yay, my advice is called. But call method abc from class def of the same instance of Foo, and no advice is called, since it won't go through the proxy.
ramnivas (171) [Avatar] Offline
#2
Re: why does everyone think dynamic proxies are enough?
I think the use of dynamic proxy is a pragmatic choice when combined with a framework, where the creation of the objects of your interest is centralized (in other words, a DI framework). Even then, as you note, you need to be aware of the self-call issue. I, therefore, explain this limitation through a diagram in chapter 9.

-Ramnivas