javaaop做⼀个接⼝耗时的计算看代码:
@Aspect
@Component
public class TimeCostAspect {
private static Logger logger = Logger(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 = Args();
long startTime = System.currentTimeMillis();
obj = joinPoint.proceed(args);
java做什么的if (!(obj instanceof BaseVO)) {
return obj;
}
long endTime = System.currentTimeMillis();
BaseVO baseVO = (BaseVO) obj;
baseVO.setCost(endTime - startTime);
return baseVO;
}
}
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论