看代码:
@Aspect
@Component
public class TimeCostAspect {
private static Logger logger = LoggerFactory.getLogger(TimeCostAspect.class);
private static final String POINT = "execution (* com.ming..*.controller..*.*(..))"; @Pointcut(POINT)
public void performance() {
} @Around("performance()")
public Object watchPerformance(ProceedingJoinPoint joinPoint) throws Throwable {
Object obj = null;
Object[] args = joinPoint.getArgs();
long startTime = System.currentTimeMillis();
obj = joinPoint.proceed(args);
if (!(obj instanceof BaseVO)) {
return obj;
}
long endTime = System.currentTimeMillis();
BaseVO baseVO = (BaseVO) obj;
baseVO.setCost(endTime - startTime);
return baseVO;
}
}