Announcement Announcement Module
No announcement yet.
Unable to cut around method Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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?

  • #2
    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.


    • #3
      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.