views:

31

answers:

3

I would like to measure the number of times a method is called on a service provisioned by Spring.

In EJB land this information is usually provided by the container.

Now since spring is conceived when "Anything you can do, I can do better" was playing on the radio, I expect there to be a nice and elegant component hidden somewhere which I can weave into my application using a sprinkling of XML.

Does anybody know of such a component?

+2  A: 

Yes, I'd look at the Spring interceptors and AOP for a "do better" solution. Maybe org.springframework.aop.interceptor.PerformanceMonitorInterceptor will do what you want out of the box.

If none of the out of the box Interceptors meet your need, it's an easy matter to extend the interface, write your own to your exact requirements, and weave it in using Spring configuration.

duffymo
Thanks, it is almost what I need but I rather need aggregate information. I'll store this one because I'll need this one for later.
Peter Tillemans
+2  A: 

Have a look at JAMon API.

JAMon gathers aggregate performance statistics such as hits, execution times (total, average, minimum, maximum, standard deviation), as well as concurrency information such as simultaneous application requests. It is easy to use and provides multiple ways to view the reports.

Edit: Also as suggested by @duffymo , there are already available interceptors out of the box with spring for jamon integrarion. This link may provide a direction.

Gopi
There's a JamonPerformanceMonitor in Spring out of the box.
duffymo
Awesome! that I didnt know. I just used it with my non-spring application once.
Gopi
I saw it and this is the route we're taking. Thanks guys!
Peter Tillemans
A: 

You might also like to write your own method-level timing and logging. Here is an example I wrote that shows how to do it with Spring AOP.

James Earl Douglas