1

I am trying to time the performance of code in package "com.company.somemodule" (has class R1, R2,..), as well as code in the subpackages,

  • com.company.somemodule.subPackageA (has classes A1, A2,..)
  • com.company.somemodule.subPackageB

I wrote the pointcut similar to the following. I am able to view the running time for classes A1, A2, but I am unable to view the running time for classes R1, R2, etc.

<bean id="timingAdvice"
      class="org.springframework.aop.interceptor.PerformanceMonitorInterceptor" />
<aop:config>
    <aop:advisor
    pointcut="execution(* com.company.somemodule..*.*(..)) OR 
              execution(* com.company.somemodule.*.*(..))"
    advice-ref="timingAdvice" />
</aop:config>

Please could anyone help? Thanks in advance.

P.S.: I have already tried following the suggestions posted here.

Community
  • 1
  • 1
user799188
  • 13,965
  • 5
  • 35
  • 37

2 Answers2

1

To build on K.C.'s answer...

I had a similar problem configuring the Spring PerformanceMonitorInterceptor. Here is an example working configuration that I used for monitoring method execution in several packages:

<bean id="performanceMonitor"
  class="org.springframework.aop.interceptor.PerformanceMonitorInterceptor" />

<aop:config>
  <aop:pointcut id="allCoreMethods" expression="
      (
           within( org.somepackage.dao..* ) 
        or within( org.somepackage.controller..* )
        or within( org.somepackage.service..* )
        or within( org.somepackage.webservices..* )
      ) 
      AND execution(* *(..))"
  />
  <aop:advisor pointcut-ref="allCoreMethods" advice-ref="performanceMonitor" order="2"/>
</aop:config>
2Aguy
  • 3,955
  • 5
  • 22
  • 28
1

I don't see any error in your pointcut at first glance, but I think what you need is easier done with a combination of the "within" pointcut expression and the "execution" expression.

Try something like this:

pointcut="within(com.company.somemodule..*) AND 
              execution(* *(..))"

This is a pointcut for method execution for all methods in the package com.company.somemodule.

K.C.
  • 2,084
  • 2
  • 25
  • 38