1 package es.whatabout.service.db.aop; 2 3 import org.apache.commons.logging.Log; 4 import org.apache.commons.logging.LogFactory; 5 import org.aspectj.lang.ProceedingJoinPoint; 6 import org.aspectj.lang.annotation.Around; 7 import org.aspectj.lang.annotation.Aspect; 8 import org.springframework.stereotype.Component; 9 import org.springframework.util.StopWatch; 10 11 @Aspect 12 @Component 13 public class Performance { 14 15 private final Log log = LogFactory.getLog(Performance.class); 16 17 /** 18 * http://tomasjurman.blogspot.com.es/2010/01/spring-aop-with-annotation.html 19 * 20 * @param joinPoint 21 * @return object 22 * @throws Throwable 23 */ 24 25 @Around("execution(* es.whatabout.dao.*.* (..))") 26 public Object logAround(ProceedingJoinPoint joinPoint) throws Throwable { 27 28 StopWatch clock = new StopWatch("performance_dao"); 29 30 try { 31 32 clock.start(); 33 34 log.debug("Comenzando metodo: " + joinPoint.getSignature().getName()); 35 36 return joinPoint.proceed(); 37 38 } finally { 39 40 clock.stop(); 41 42 log.debug("Consumo: " + clock.prettyPrint()); 43 } 44 45 } 46 }