Results 1 to 7 of 7

Thread: PerformanceMonitorInterceptor Example

  1. #1
    Join Date
    Oct 2006
    Posts
    1

    Default PerformanceMonitorInterceptor Example

    A lack of examples exist for the implementation of the Interceptors for Performance and JaMon with wildcards, therefore newbies, like me, struggle.

    Looking for a simple example of how to activate the PerformanceMonitorInterceptor for all classes in a package or class name wildcard. The config I have looks like this. No errors, no logging. What would the logging look like?

    <bean id="performanceMonitor" class="org.springframework.aop.interceptor.Perform anceMonitorInterceptor">
    <property name="useDynamicLogger"><value>true</value></property>
    </bean>

    <!-- Create the proxy bean that returns AOP'd varieties of our controller -->
    <bean name="proxyBean" class="org.springframework.aop.framework.autoproxy .BeanNameAutoProxyCreator">
    <property name="beanNames" value="prefix*"/>
    <property name="interceptorNames">
    <list>
    <value>performanceMonitor</value>
    </list>
    </property>
    </bean>

    Thanks.

  2. #2

    Default Similar situation

    I too have this frustration. I notice that the original post here was in 2006.

    If I freshly ask, could someone please give a little clue if this config should work?

    Code:
    <bean id="performanceMonitor" class="org.springframework.aop.interceptor.PerformanceMonitorInterceptor">
      <property name="useDynamicLogger" value="true"/>
    </bean>
    <aop:config>
      <aop:pointcut id="allMethods" expression="execution(* com.package.*.*(..))"/>
      <aop:advisor pointcut-ref="allMethods" advice-ref="performanceMonitor"/>
    </aop:config>
    Thanks in advance,

    Stewart

  3. #3

    Default

    I finally got something working - yeah!

    This is the blog that finally made things clear to me:
    (h tt p :// w w w.unicon.net/node/765) Update to Profiling Your Code with Spring

    Many thanks to "holdorph"

    PS: What's with not letting me enter that url as a url until 15 posts?

  4. #4
    Join Date
    Nov 2007
    Posts
    420

    Default

    you should be able to work with what you have as well, just change the pointcut to

    Code:
    <aop:pointcut id="allMethods" expression="execution(* com.package..*.*(..))"/>

  5. #5

    Default

    Thank you bdangubic.

    Perhaps what is really needed is a concise pointcut expression language reference.

    I've looked for one, but only found overly complex AspectJ references.
    Does anyone know of anything available which has distilled out the definitive expressions needed for Spring AOP ?

    Stewart

  6. #6
    Join Date
    Nov 2007
    Posts
    16

    Default Jamon

    All,

    I have the following which works ....

    <aop:advisor pointcut="execution(* com.package..*.*(..))" advice-ref="performanceMonitor"/>

    <bean id="performanceMonitor" class="org.springframework.aop.interceptor.JamonPe rformanceMonitorInterceptor">
    <property name="trackAllInvocations" value="true"/>
    </bean>


    Then in your log4j file you need ...

    log4j.logger.org.springframework.aop.interceptor.J amonPerformanceMonitorInterceptor=TRACE

    On the subject of Jamon ... is there a way to get timings for nested calls ie the timings that get logged seem to be for the initial method called on an interface ie if I have a method called processTransaction which when implemented calls several methods I only get a timing for the processTransaction whereas I would like to get a breakdown of the various calls it makes. Any suggestions ?

    Thanks

  7. #7
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    Spring uses a proxy based approach so only externally called methods are intercepted. As soon as you are in the object and call methods on itself those don't pass through the proxy.

    The only way to achieve that is to switch to loadtime or compile time weaving.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •