Package org.nutz.plugins.aop.interceptor

Source Code of org.nutz.plugins.aop.interceptor.ExecutionTimeInterceptor

package org.nutz.plugins.aop.interceptor;

import org.nutz.aop.InterceptorChain;
import org.nutz.aop.MethodInterceptor;
import org.nutz.lang.Stopwatch;
import org.nutz.log.Log;
import org.nutz.log.Logs;

public class ExecutionTimeInterceptor implements MethodInterceptor {

  private static Log LOG = Logs.getLog(ExecutionTimeInterceptor.class);
 
  public void filter(InterceptorChain chain) throws Throwable {
    if (!LOG.isDebugEnabled()) {
      chain.doChain();
      return;
    }
    Stopwatch stopwatch = Stopwatch.begin();
    chain.doChain();
    stopwatch.stop();
    LOG.debugf("ExecutionTime %dms in %s",stopwatch.getDuration(),chain.getCallingMethod());
  }

}
TOP

Related Classes of org.nutz.plugins.aop.interceptor.ExecutionTimeInterceptor

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.