当前位置: 首页>>代码示例>>Java>>正文


Java ResponseHandler类代码示例

本文整理汇总了Java中ch.boye.httpclientandroidlib.client.ResponseHandler的典型用法代码示例。如果您正苦于以下问题:Java ResponseHandler类的具体用法?Java ResponseHandler怎么用?Java ResponseHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ResponseHandler类属于ch.boye.httpclientandroidlib.client包,在下文中一共展示了ResponseHandler类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import ch.boye.httpclientandroidlib.client.ResponseHandler; //导入依赖的package包/类
/**
 * Schedule a request for execution.
 *
 * @param <T>
 *
 * @param request
 *            request to execute
 * @param context
 *            optional context; use null if not needed.
 * @param responseHandler
 *            handler that will process the response.
 * @param callback
 *            callback handler that will be called when the request is scheduled,
 *            started, completed, failed, or cancelled.
 * @return HttpAsyncClientFutureTask for the scheduled request.
 * @throws InterruptedException
 */
public <T> HttpRequestFutureTask<T> execute(
        final HttpUriRequest request,
        final HttpContext context,
        final ResponseHandler<T> responseHandler,
        final FutureCallback<T> callback) {
    if(closed.get()) {
        throw new IllegalStateException("Close has been called on this httpclient instance.");
    }
    metrics.getScheduledConnections().incrementAndGet();
    final HttpRequestTaskCallable<T> callable = new HttpRequestTaskCallable<T>(
        httpclient, request, context, responseHandler, callback, metrics);
    final HttpRequestFutureTask<T> httpRequestFutureTask = new HttpRequestFutureTask<T>(
        request, callable);
    executorService.execute(httpRequestFutureTask);

    return httpRequestFutureTask;
}
 
开发者ID:mozilla-mobile,项目名称:FirefoxData-android,代码行数:35,代码来源:FutureRequestExecutionService.java

示例2: HttpRequestTaskCallable

import ch.boye.httpclientandroidlib.client.ResponseHandler; //导入依赖的package包/类
HttpRequestTaskCallable(
        final HttpClient httpClient,
        final HttpUriRequest request,
        final HttpContext context,
        final ResponseHandler<V> responseHandler,
        final FutureCallback<V> callback,
        final FutureRequestExecutionMetrics metrics) {
    this.httpclient = httpClient;
    this.responseHandler = responseHandler;
    this.request = request;
    this.context = context;
    this.callback = callback;
    this.metrics = metrics;
}
 
开发者ID:mozilla-mobile,项目名称:FirefoxData-android,代码行数:15,代码来源:HttpRequestTaskCallable.java

示例3: execute

import ch.boye.httpclientandroidlib.client.ResponseHandler; //导入依赖的package包/类
public <T> T execute(final HttpHost target, final HttpRequest request,
        final ResponseHandler<? extends T> responseHandler, final HttpContext context)
        throws IOException, ClientProtocolException {
    final HttpResponse response = execute(target, request, context);
    try {
        return responseHandler.handleResponse(response);
    } finally {
        final HttpEntity entity = response.getEntity();
        if (entity != null) {
            EntityUtils.consume(entity);
        }
    }
}
 
开发者ID:mozilla-mobile,项目名称:FirefoxData-android,代码行数:14,代码来源:DecompressingHttpClient.java

示例4: execute

import ch.boye.httpclientandroidlib.client.ResponseHandler; //导入依赖的package包/类
/**
 * Validate the response using the response handler. Aborts the request if
 * there is an exception.
 * 
 * @param <T>
 *            Return type
 * @param request
 *            Request to execute
 * @param responseHandler
 *            Determines the return type.
 * @return parsed response
 */
protected <T> T execute(HttpRequestBase request,
		ResponseHandler<T> responseHandler) throws IOException {
	try {
		//System.out.println("starn: requestSent="+request.toString());
		// Clear circular redirect cache
		// this.context.removeAttribute(DefaultRedirectStrategy.REDIRECT_LOCATIONS);
		// Execute with response handler
		return this.client.execute(request, responseHandler, this.context);
	} catch (IOException e) {
		request.abort();
		throw e;
	}
}
 
开发者ID:starn,项目名称:encdroidMC,代码行数:26,代码来源:SardineImpl.java

示例5: execute

import ch.boye.httpclientandroidlib.client.ResponseHandler; //导入依赖的package包/类
public <T> T execute(final HttpHost target, final HttpRequest request,
        final ResponseHandler<? extends T> responseHandler) throws IOException {
    return execute(target, request, responseHandler, null);
}
 
开发者ID:mozilla-mobile,项目名称:FirefoxData-android,代码行数:5,代码来源:AutoRetryHttpClient.java

示例6: execute

import ch.boye.httpclientandroidlib.client.ResponseHandler; //导入依赖的package包/类
/**
 * Executes a request using the default context and processes the
 * response using the given response handler. The content entity associated
 * with the response is fully consumed and the underlying connection is
 * released back to the connection manager automatically in all cases
 * relieving individual {@link ResponseHandler}s from having to manage
 * resource deallocation internally.
 *
 * @param request   the request to execute
 * @param responseHandler the response handler
 * @param context   the context to use for the execution, or
 *                  <code>null</code> to use the default context
 *
 * @return  the response object as generated by the response handler.
 * @throws IOException in case of a problem or the connection was aborted
 * @throws ClientProtocolException in case of an http protocol error
 */
public <T> T execute(final HttpUriRequest request,
        final ResponseHandler<? extends T> responseHandler, final HttpContext context)
        throws IOException, ClientProtocolException {
    final HttpHost target = determineTarget(request);
    return execute(target, request, responseHandler, context);
}
 
开发者ID:mozilla-mobile,项目名称:FirefoxData-android,代码行数:24,代码来源:CloseableHttpClient.java


注:本文中的ch.boye.httpclientandroidlib.client.ResponseHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。