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


Java AsyncEvent.getAsyncContext方法代碼示例

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


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

示例1: onTimeout

import javax.servlet.AsyncEvent; //導入方法依賴的package包/類
/**
 * Async operation timeout (AsyncListener interface)
 *
 * @param   event               Async event
 */
@Override
public void onTimeout(AsyncEvent event) {
    AsyncContext context = event.getAsyncContext();
    lock.lock();
    try {
        pendingWaits.remove(context);
        JSONObject response = new JSONObject();
        response.put("events", new JSONArray());
        response.put("requestProcessingTime", System.currentTimeMillis()-timestamp);
        try (Writer writer = context.getResponse().getWriter()) {
            response.writeJSONString(writer);
        } catch (IOException exc) {
            Logger.logDebugMessage(String.format("Unable to return API response to %s: %s",
                                                 address, exc.toString()));
        }
        context.complete();
        timestamp = System.currentTimeMillis();
    } finally {
        lock.unlock();
    }
}
 
開發者ID:BitcoinFullnode,項目名稱:ROKOS-OK-Bitcoin-Fullnode,代碼行數:27,代碼來源:EventListener.java

示例2: customizeEvent

import javax.servlet.AsyncEvent; //導入方法依賴的package包/類
private AsyncEvent customizeEvent(AsyncEvent event) {
    if (servletRequest != null && servletResponse != null) {
        return new AsyncEvent(event.getAsyncContext(), servletRequest, servletResponse,
                event.getThrowable());
    } else {
        return event;
    }
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:9,代碼來源:AsyncListenerWrapper.java

示例3: onComplete

import javax.servlet.AsyncEvent; //導入方法依賴的package包/類
@Override
public void onComplete(AsyncEvent event) throws IOException {
	final AsyncContextState state = (AsyncContextState) event.getAsyncContext();
	final HttpServletRequest request = (HttpServletRequest) state.getRequest();
	final HttpServletResponse response = (HttpServletResponse) state.getResponse();
	updateResponses(request, response, startTime);
}
 
開發者ID:mevdschee,項目名稱:tqdev-metrics,代碼行數:8,代碼來源:InstrumentedHandler.java

示例4: customizeEvent

import javax.servlet.AsyncEvent; //導入方法依賴的package包/類
private AsyncEvent customizeEvent(AsyncEvent event) {
	if (servletRequest != null && servletResponse != null) {
		return new AsyncEvent(event.getAsyncContext(), servletRequest, servletResponse, event.getThrowable());
	} else {
		return event;
	}
}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:8,代碼來源:AsyncListenerWrapper.java

示例5: onStartAsync

import javax.servlet.AsyncEvent; //導入方法依賴的package包/類
@Override
public void onStartAsync(AsyncEvent event) throws IOException {
    // Another async event was started (e.g. via asyncContext.dispatch(...), which means this listener was
    //      removed and won't be called on completion unless we re-register (as per the javadocs for this
    //      method from the interface).
    AsyncContext eventAsyncContext = event.getAsyncContext();
    if (eventAsyncContext != null) {
        eventAsyncContext.addListener(this);
    }
}
 
開發者ID:Nike-Inc,項目名稱:wingtips,代碼行數:11,代碼來源:WingtipsRequestSpanCompletionAsyncListener.java

示例6: onError

import javax.servlet.AsyncEvent; //導入方法依賴的package包/類
/**
 * Async error detected (AsyncListener interface)
 *
 * @param   event               Async event
 */
@Override
public void onError(AsyncEvent event) {
    AsyncContext context = event.getAsyncContext();
    lock.lock();
    try {
        pendingWaits.remove(context);
        context.complete();
        timestamp = System.currentTimeMillis();
        Logger.logDebugMessage("Error detected during event wait for "+address, event.getThrowable());
    } finally {
        lock.unlock();
    }
}
 
開發者ID:BitcoinFullnode,項目名稱:ROKOS-OK-Bitcoin-Fullnode,代碼行數:19,代碼來源:EventListener.java

示例7: finalizeAsyncContext

import javax.servlet.AsyncEvent; //導入方法依賴的package包/類
private void finalizeAsyncContext(AsyncEvent event, Reason reason) throws IOException {
    AsyncContext asyncContext = event.getAsyncContext();
    bean.asyncContextDestroyed(asyncContext, reason);
    HANDLER.finalizeAsyncBean(bean, (HttpServletRequest) asyncContext.getRequest());
}
 
開發者ID:jefalbino,項目名稱:jsmart-web,代碼行數:6,代碼來源:ServletControl.java


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