All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.springframework.aop.interceptor.JamonPerformanceMonitorInterceptorCustom Maven / Gradle / Ivy

package org.springframework.aop.interceptor;

import org.apache.commons.logging.Log;

/**
 * 프로세스 실행 시간을 체크하여 로그 (기본 값: 1000 (1초), 단위: milliseconds)
 */
public class JamonPerformanceMonitorInterceptorCustom extends JamonPerformanceMonitorInterceptor {
  private static final long serialVersionUID = -5293915614472598728L;
  private boolean trackException;
  private double boundary = 1000.0D;

  @Override
  protected Object invokeUnderTrace(org.aopalliance.intercept.MethodInvocation invocation, org.apache.commons.logging.Log logger) throws Throwable {
    String name = createInvocationTraceName(invocation);
    com.jamonapi.MonKey key = new com.jamonapi.MonKeyImp(name, name, "ms.");

    com.jamonapi.Monitor monitor = com.jamonapi.MonitorFactory.start(key);
    try {
      return invocation.proceed();
    }
    catch (Throwable t) {
      if (this.trackException) {
        trackException(key, t);
      }
      throw t;
    }
    finally {
      monitor.stop();
      if (monitor.getLastValue() > this.boundary && isLogEnabled(logger)) {
        logger.warn("JAMon performance statistics for method [" + name + "]:");
        logger.warn(monitor);
      }
    }
  }

  @Override
  protected boolean isLogEnabled(Log logger) {
    return logger.isWarnEnabled();
  }

  /**
   * @param trackException to set
   */
  public void setTrackException(boolean trackException) {
    this.trackException = trackException;
  }

  /**
   * @param boundary to set (in milliseconds)
   */
  public void setBoundary(double boundary) {
    this.boundary = boundary;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy