當前位置: 首頁>>代碼示例>>Java>>正文


Java StopWatch.isRunning方法代碼示例

本文整理匯總了Java中org.springframework.util.StopWatch.isRunning方法的典型用法代碼示例。如果您正苦於以下問題:Java StopWatch.isRunning方法的具體用法?Java StopWatch.isRunning怎麽用?Java StopWatch.isRunning使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.util.StopWatch的用法示例。


在下文中一共展示了StopWatch.isRunning方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: printBackFromErrorStateInfoIfStopWatchIsRunning

import org.springframework.util.StopWatch; //導入方法依賴的package包/類
private static void printBackFromErrorStateInfoIfStopWatchIsRunning(StopWatch stopWatch) {

		if (stopWatch.isRunning()) {
			stopWatch.stop();
			System.err.println("INFO: Recovered after: " + stopWatch.getLastTaskInfo().getTimeSeconds());
		}
	}
 
開發者ID:Just-Fun,項目名稱:spring-data-examples,代碼行數:8,代碼來源:RedisSentinelApplication.java

示例2: invokeUnderTrace

import org.springframework.util.StopWatch; //導入方法依賴的package包/類
/**
 * Writes a log message before the invocation based on the value of {@code enterMessage}.
 * If the invocation succeeds, then a log message is written on exit based on the value
 * {@code exitMessage}. If an exception occurs during invocation, then a message is
 * written based on the value of {@code exceptionMessage}.
 * @see #setEnterMessage
 * @see #setExitMessage
 * @see #setExceptionMessage
 */
@Override
protected Object invokeUnderTrace(MethodInvocation invocation, Log logger) throws Throwable {
	String name = invocation.getMethod().getDeclaringClass().getName() + "." + invocation.getMethod().getName();
	StopWatch stopWatch = new StopWatch(name);
	Object returnValue = null;
	boolean exitThroughException = false;
	try {
		stopWatch.start(name);
		writeToLog(logger,
				replacePlaceholders(this.enterMessage, invocation, null, null, -1));
		returnValue = invocation.proceed();
		return returnValue;
	}
	catch (Throwable ex) {
		if(stopWatch.isRunning()) {
			stopWatch.stop();
		}
		exitThroughException = true;
		writeToLog(logger,
				replacePlaceholders(this.exceptionMessage, invocation, null, ex, stopWatch.getTotalTimeMillis()), ex);
		throw ex;
	}
	finally {
		if (!exitThroughException) {
			if(stopWatch.isRunning()) {
				stopWatch.stop();
			}
			writeToLog(logger,
					replacePlaceholders(this.exitMessage, invocation, returnValue, null, stopWatch.getTotalTimeMillis()));
		}
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:42,代碼來源:CustomizableTraceInterceptor.java

示例3: invokeUnderTrace

import org.springframework.util.StopWatch; //導入方法依賴的package包/類
/**
 * Writes a log message before the invocation based on the value of {@code enterMessage}.
 * If the invocation succeeds, then a log message is written on exit based on the value
 * {@code exitMessage}. If an exception occurs during invocation, then a message is
 * written based on the value of {@code exceptionMessage}.
 * @see #setEnterMessage
 * @see #setExitMessage
 * @see #setExceptionMessage
 */
@Override
protected Object invokeUnderTrace(MethodInvocation invocation, Log logger) throws Throwable {
	String name = invocation.getMethod().getDeclaringClass().getName() + "." + invocation.getMethod().getName();
	StopWatch stopWatch = new StopWatch(name);
	Object returnValue = null;
	boolean exitThroughException = false;
	try {
		stopWatch.start(name);
		writeToLog(logger,
				replacePlaceholders(this.enterMessage, invocation, null, null, -1));
		returnValue = invocation.proceed();
		return returnValue;
	}
	catch (Throwable ex) {
		if (stopWatch.isRunning()) {
			stopWatch.stop();
		}
		exitThroughException = true;
		writeToLog(logger,
				replacePlaceholders(this.exceptionMessage, invocation, null, ex, stopWatch.getTotalTimeMillis()), ex);
		throw ex;
	}
	finally {
		if (!exitThroughException) {
			if (stopWatch.isRunning()) {
				stopWatch.stop();
			}
			writeToLog(logger,
					replacePlaceholders(this.exitMessage, invocation, returnValue, null, stopWatch.getTotalTimeMillis()));
		}
	}
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:42,代碼來源:CustomizableTraceInterceptor.java

示例4: startStopWatchIfNotRunning

import org.springframework.util.StopWatch; //導入方法依賴的package包/類
private static void startStopWatchIfNotRunning(StopWatch stopWatch) {

		if (!stopWatch.isRunning()) {
			stopWatch.start();
		}
	}
 
開發者ID:Just-Fun,項目名稱:spring-data-examples,代碼行數:7,代碼來源:RedisSentinelApplication.java

示例5: stopTiming

import org.springframework.util.StopWatch; //導入方法依賴的package包/類
static long stopTiming(StopWatch stopWatch) {
    if (stopWatch.isRunning()) {
        stopWatch.stop();
    }
    return stopWatch.getTotalTimeMillis();
}
 
開發者ID:ePages-de,項目名稱:spring-boot-readiness,代碼行數:7,代碼來源:Timer.java


注:本文中的org.springframework.util.StopWatch.isRunning方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。