2012-01-12 57 views
1

我想時間的在包「com.company.somemodule」代碼的性能(具有類R1,R2,...),以及代碼在子包,多個執行語句,但只有一個是工作

  • com.company.somemodule.subPackageA(已類A1,A2,...)
  • com.company.somemodule.subPackageB

我寫了類似如下的切入點。我可以查看類A1,A2的運行時間,但我無法查看類R1,R2,運行時間等

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

請任何人都可以幫助嗎?提前致謝。

P.S:我已經嘗試下面貼here的建議。

回答

1

我沒有看到你的切入點乍一看任何錯誤,但我認爲你需要的是更容易與「內」切入點表達式和「執行」表達的組合來完成。

嘗試這樣:

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

這是在包com.company.somemodule所有方法方法執行的切入點。

1

要建立在K.C.的答案...

我有一個類似的問題在配置春季PerformanceMonitorInterceptor。這裏是我在幾個包用於監視方法執行的示例工作配置:

<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> 
相關問題