Announcement Announcement Module
No announcement yet.
Pointcuts for MVC Controller overridden methods Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Pointcuts for MVC Controller overridden methods

    I'm trying to profile my MVC Controllers using JAMon.
    The Controllers do implement the Controller interface of course, thus profiling the method calls implemented from this interface works ok.
    Here's how:
       <aop:advisor advice-ref="jamonInterceptor" pointcut="execution(* org.springframework.web.servlet.mvc.Controller.*(..))"/>
    <bean id="jamonInterceptor" class="org.springframework.aop.interceptor.JamonPerformanceMonitorInterceptor">
       <property name="trackAllInvocations" value="true"/>
    But I would also like to profile the method calls that overrides the methods in the different controller classes in Spring (SimpleFormController etc.), like the referenceData() method. These methods aren't defined in any interface, so I tried to force use of the CGLIB proxy (the controllers are locted in the myapp.web package):

    <aop:config proxy-target-class="true">
       <aop:advisor advice-ref="jamonInterceptor" pointcut="execution(* myapp.web.*.*(..))"/>
    but none of the method calls got profiled (I also without proxy-target-class="true", getting the same result).

    Any idea how to solve this?
    Last edited by mortenhaugen; Dec 29th, 2006, 08:02 AM.

  • #2
    This is a know problem when trying to do AOP interception on multiple methods of a class using JDKDynamic proxies or CGLib. The problem is there is a proxy created so you can intercept when methods are called by clients of the class you proxied (client uses the proxy). Unfortunately, when you are in the class and call other public, protected, private methods you are no longer using the proxy (using the real class) so no proxy methods get invoked and no chance for interception. The only way (that I'm aware of) is to use AspectJ to weave in the instrumentation (at build or using a LoadTimeWeaver) to the class directly to guarantee that the interceptor code will be called.


    • #3
      I think caleb is right here you would have to use AspectJ. You might want to have a look at the reference manual regarding AOP proxies.


      • #4
        Yes, I believe he's right.
        And if anyone has some good recources on profiling Spring MVC applications using JAMon, I would appreciate a hint. Thanks in advance.