Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
多玩游戏 ©2005-2010. 多玩通行证系统 udb.duowan.com

:
#)MethodRunMessageInterceptor.java date:2011-6-13
 
 package io.leopard.topnb;
 
 
方法耗时监控.

Author(s):
阿海
public class TopnbInterceptor implements MethodInterceptor {
	private final PerformanceService performanceService = TopnbBeanFactory.getPerformanceService();
	private static boolean isCreated = false;
	public TopnbInterceptor() {
		if () {
			throw new IllegalArgumentException("方法耗时监控系统已经启动.");
		}
		TopnbBeanFactory.setEnableMonitor(true);
	}
	public Object invoke(MethodInvocation invocationthrows Throwable {
		Method method = invocation.getMethod();
		long startTime = System.nanoTime();
		Object result = invocation.proceed();
		long endTime = System.nanoTime();
		long time = (endTime - startTime) / 1000L; // time 单位:微妙
		Object target = invocation.getThis();
		String className = PerformanceUtil.getLongClassName(target);
		String methodName = PerformanceUtil.getLongMethodName(classNamemethod.getName());
		.add(methodNametime);
		return result;
	}
New to GrepCode? Check out our FAQ X