PDA

View Full Version : Using AOP to get timing data


ElPapa
Oct 21st, 2004, 04:26 PM
Hi,

I need to get timing data to deterimine the length of time a method call takes. I thought that perhaps AOP would be a good approach. Then I could have some sort of class store a "start time" in a MethodBeforeAdvice and then work with that class in the AfterReturningAdvice. However, I'm not sure of the approach for storing this state. I was thinking about having a class that uses ThreadLocal, but so far my attempts don't appear to be working. Perhaps I'm misusing ThreadLocal?

mraible
Oct 21st, 2004, 05:21 PM
You could use one of Spring's existing interceptors for this:

http://www.springframework.org/docs/api/org/springframework/aop/interceptor/PerformanceMonitorInterceptor.html

ElPapa
Oct 21st, 2004, 10:30 PM
I'll have to take a closer look at that. Thanks.

ElPapa
Oct 22nd, 2004, 03:49 PM
mraible,

Thanks.. that took my approach in a whole other direction that was far more effective. I appreciate you pointing that out.