Spring AOP的接口耗时统计

Spring AOP的接口耗时统计

/**
 * 通知
 *
 * @author wwl
 *
 */
public class ActionAdvice implements MethodInterceptor {
    private Log log=LogFactory.getLog(ActionAdvice.class);


    @Override
    public Object invoke(MethodInvocation invocation) throws Throwable {
        Long startTime;
        Long endTime;
        startTime=System.currentTimeMillis();
        Object o=invocation.proceed();
        endTime=System.currentTimeMillis();
        log.info("Time["+invocation.getMethod().getDeclaringClass().getSimpleName()+"]["+invocation.getMethod().getName()+"]["+(endTime-startTime)+"]");
        return o;
    }
}

posted @ 2015-09-06 17:34  W&L  阅读(1133)  评论(0编辑  收藏  举报