1 17 package org.alfresco.util.perf; 18 19 import org.aopalliance.intercept.MethodInterceptor; 20 import org.aopalliance.intercept.MethodInvocation; 21 22 import com.vladium.utils.timing.ITimer; 23 import com.vladium.utils.timing.TimerFactory; 24 25 30 public class PerformanceMonitorAdvice extends AbstractPerformanceMonitor implements MethodInterceptor 31 { 32 public PerformanceMonitorAdvice(String beanName) 33 { 34 super(beanName); 35 } 36 37 public Object invoke(MethodInvocation invocation) throws Throwable 38 { 39 if (AbstractPerformanceMonitor.isDebugEnabled()) 41 { 42 return invokeWithLogging(invocation); 43 } 44 else 45 { 46 return invocation.proceed(); 48 } 49 } 50 51 private Object invokeWithLogging(MethodInvocation invocation) throws Throwable 52 { 53 ITimer timer = TimerFactory.newTimer (); 55 56 timer.start (); 57 58 Object ret = invocation.proceed(); 61 timer.stop (); 65 66 recordStats(invocation.getMethod().getName(), timer.getDuration ()); 67 return ret; 69 } 70 } 71 | Popular Tags |