当前位置: 首页>>代码示例>>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;未经允许,请勿转载。