Oct 24th, 2007, 05:18 AM
Unable to cut around method
I have an implementation of AbstractCommandController and I am attempting to cut around its handle(...) method. For some reason this never works. Using the exact same setup, if I cut around the implementation's handleRequest(..) method it works fine. I have attempted things like making the handle(..) method public instead of protected. I have also attempted creating an interface for the implementation that defines the handle(..) method but still the cut doesn't seem to work. Any ideas?
Oct 24th, 2007, 11:18 AM
Because Spring AOP is interceptor-based, you unfortunately cannot advise methods like AbstractCommandController.handle, because they not called through a proxied interface or class, but are rather invoked internally by the framework (e.g., self-invocation). Within the Spring MVC controller hierarchy, you can only advise the Controller.handleRequest method with Spring AOP.
A further discussion of how Spring AOP proxies work (and their limitations) can be found here:
If you need more flexibility in your AOP solution, you might consider using AspectJ.
Oct 25th, 2007, 10:39 AM
Thank you for your response. Unfortunately I am not able to use AspectJ because of project constraints. However, I have found a semi-hack solution to this (semi-hack in that it actually allows me to do some other powerful things too). I now inject a handler class into the controller to which the controller delegates the handling. This not only allows me to advise on the handler's handle method but also allows me to swap between different handler's easily.