Package org.apache.http.nio.protocol
Class HttpAsyncRequester
java.lang.Object
org.apache.http.nio.protocol.HttpAsyncRequester
HttpAsyncRequester is a utility class that can be used
in conjunction with HttpAsyncRequestExecutor to initiate execution
of asynchronous HTTP requests.- Since:
- 4.2
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionHttpAsyncRequester(HttpProcessor httpprocessor) Creates new instance of HttpAsyncRequester.HttpAsyncRequester(HttpProcessor httpprocessor, ConnectionReuseStrategy connReuseStrategy) Creates new instance of HttpAsyncRequester.HttpAsyncRequester(HttpProcessor httpprocessor, ConnectionReuseStrategy connReuseStrategy, ExceptionLogger exceptionLogger) Creates new instance ofHttpAsyncRequester.HttpAsyncRequester(HttpProcessor httpprocessor, ConnectionReuseStrategy reuseStrategy, HttpParams params) Deprecated. -
Method Summary
Modifier and TypeMethodDescription<T,E extends PoolEntry<HttpHost, NHttpClientConnection>>
Future<T> execute(HttpAsyncRequestProducer requestProducer, HttpAsyncResponseConsumer<T> responseConsumer, E poolEntry, ConnPool<HttpHost, E> connPool, HttpContext context, FutureCallback<T> callback) Initiates asynchronous HTTP request execution.<T> Future<T> execute(HttpAsyncRequestProducer requestProducer, HttpAsyncResponseConsumer<T> responseConsumer, NHttpClientConnection conn) Initiates asynchronous HTTP request execution.<T> Future<T> execute(HttpAsyncRequestProducer requestProducer, HttpAsyncResponseConsumer<T> responseConsumer, NHttpClientConnection conn, HttpContext context) Initiates asynchronous HTTP request execution.<T> Future<T> execute(HttpAsyncRequestProducer requestProducer, HttpAsyncResponseConsumer<T> responseConsumer, NHttpClientConnection conn, HttpContext context, FutureCallback<T> callback) Initiates asynchronous HTTP request execution.<T,E extends PoolEntry<HttpHost, NHttpClientConnection>>
Future<T> execute(HttpAsyncRequestProducer requestProducer, HttpAsyncResponseConsumer<T> responseConsumer, ConnPool<HttpHost, E> connPool) Initiates asynchronous HTTP request execution.<T,E extends PoolEntry<HttpHost, NHttpClientConnection>>
Future<T> execute(HttpAsyncRequestProducer requestProducer, HttpAsyncResponseConsumer<T> responseConsumer, ConnPool<HttpHost, E> connPool, HttpContext context) Initiates asynchronous HTTP request execution.<T,E extends PoolEntry<HttpHost, NHttpClientConnection>>
Future<T> execute(HttpAsyncRequestProducer requestProducer, HttpAsyncResponseConsumer<T> responseConsumer, ConnPool<HttpHost, E> connPool, HttpContext context, FutureCallback<T> callback) Initiates asynchronous HTTP request execution.<T,E extends PoolEntry<HttpHost, NHttpClientConnection>>
Future<List<T>> executePipelined(List<HttpAsyncRequestProducer> requestProducers, List<HttpAsyncResponseConsumer<T>> responseConsumers, E poolEntry, ConnPool<HttpHost, E> connPool, HttpContext context, FutureCallback<List<T>> callback) Initiates asynchronous pipelined HTTP request execution.<T,E extends PoolEntry<HttpHost, NHttpClientConnection>>
Future<List<T>> executePipelined(HttpHost target, List<? extends HttpAsyncRequestProducer> requestProducers, List<? extends HttpAsyncResponseConsumer<T>> responseConsumers, ConnPool<HttpHost, E> connPool, HttpContext context, FutureCallback<List<T>> callback) Initiates asynchronous pipelined HTTP request execution.
-
Constructor Details
-
HttpAsyncRequester
@Deprecated public HttpAsyncRequester(HttpProcessor httpprocessor, ConnectionReuseStrategy reuseStrategy, HttpParams params) Deprecated. -
HttpAsyncRequester
public HttpAsyncRequester(HttpProcessor httpprocessor, ConnectionReuseStrategy connReuseStrategy, ExceptionLogger exceptionLogger) Creates new instance ofHttpAsyncRequester.- Parameters:
httpprocessor- HTTP protocol processor.connReuseStrategy- Connection re-use strategy. IfnullDefaultConnectionReuseStrategy.INSTANCEwill be used.exceptionLogger- Exception logger. IfnullExceptionLogger.NO_OPwill be used. Please note that the exception logger will be only used to log I/O exception thrown while closingCloseableobjects (such asHttpConnection).- Since:
- 4.4
-
HttpAsyncRequester
Creates new instance of HttpAsyncRequester.- Since:
- 4.3
-
HttpAsyncRequester
Creates new instance of HttpAsyncRequester.- Since:
- 4.3
-
-
Method Details
-
execute
public <T> Future<T> execute(HttpAsyncRequestProducer requestProducer, HttpAsyncResponseConsumer<T> responseConsumer, NHttpClientConnection conn, HttpContext context, FutureCallback<T> callback) Initiates asynchronous HTTP request execution.- Type Parameters:
T- the result type of request execution.- Parameters:
requestProducer- request producer.responseConsumer- response consumer.conn- underlying HTTP connection.context- HTTP contextcallback- future callback.- Returns:
- future representing pending completion of the operation.
-
execute
public <T> Future<T> execute(HttpAsyncRequestProducer requestProducer, HttpAsyncResponseConsumer<T> responseConsumer, NHttpClientConnection conn, HttpContext context) Initiates asynchronous HTTP request execution.- Type Parameters:
T- the result type of request execution.- Parameters:
requestProducer- request producer.responseConsumer- response consumer.conn- underlying HTTP connection.context- HTTP context- Returns:
- future representing pending completion of the operation.
-
execute
public <T> Future<T> execute(HttpAsyncRequestProducer requestProducer, HttpAsyncResponseConsumer<T> responseConsumer, NHttpClientConnection conn) Initiates asynchronous HTTP request execution.- Type Parameters:
T- the result type of request execution.- Parameters:
requestProducer- request producer.responseConsumer- response consumer.conn- underlying HTTP connection.- Returns:
- future representing pending completion of the operation.
-
execute
public <T,E extends PoolEntry<HttpHost, Future<T> executeNHttpClientConnection>> (HttpAsyncRequestProducer requestProducer, HttpAsyncResponseConsumer<T> responseConsumer, ConnPool<HttpHost, E> connPool, HttpContext context, FutureCallback<T> callback) Initiates asynchronous HTTP request execution.- Type Parameters:
T- the result type of request execution.E- the connection pool entry type.- Parameters:
requestProducer- request producer.responseConsumer- response consumer.connPool- pool of persistent reusable connections.context- HTTP contextcallback- future callback.- Returns:
- future representing pending completion of the operation.
-
executePipelined
public <T,E extends PoolEntry<HttpHost, Future<List<T>> executePipelinedNHttpClientConnection>> (HttpHost target, List<? extends HttpAsyncRequestProducer> requestProducers, List<? extends HttpAsyncResponseConsumer<T>> responseConsumers, ConnPool<HttpHost, E> connPool, HttpContext context, FutureCallback<List<T>> callback) Initiates asynchronous pipelined HTTP request execution.- Type Parameters:
T- the result type of request execution.E- the connection pool entry type.- Parameters:
target- target host.requestProducers- list of request producers.responseConsumers- list of response consumers.connPool- pool of persistent reusable connections.context- HTTP contextcallback- future callback.- Returns:
- future representing pending completion of the operation.
- Since:
- 4.4
-
execute
public <T,E extends PoolEntry<HttpHost, Future<T> executeNHttpClientConnection>> (HttpAsyncRequestProducer requestProducer, HttpAsyncResponseConsumer<T> responseConsumer, E poolEntry, ConnPool<HttpHost, E> connPool, HttpContext context, FutureCallback<T> callback) Initiates asynchronous HTTP request execution. This method automatically releases the given pool entry once request execution is completed (successfully or unsuccessfully).- Type Parameters:
T- the result type of request execution.E- the connection pool entry type.- Parameters:
requestProducer- request producer.responseConsumer- response consumer.poolEntry- leased pool entry. It will be automatically released back to the pool when execution is completed.connPool- pool of persistent reusable connections.context- HTTP contextcallback- future callback.- Returns:
- future representing pending completion of the operation.
- Since:
- 4.3
-
executePipelined
public <T,E extends PoolEntry<HttpHost, Future<List<T>> executePipelinedNHttpClientConnection>> (List<HttpAsyncRequestProducer> requestProducers, List<HttpAsyncResponseConsumer<T>> responseConsumers, E poolEntry, ConnPool<HttpHost, E> connPool, HttpContext context, FutureCallback<List<T>> callback) Initiates asynchronous pipelined HTTP request execution. This method automatically releases the given pool entry once request execution is completed (successfully or unsuccessfully).- Type Parameters:
T- the result type of request execution.E- the connection pool entry type.- Parameters:
requestProducers- list of request producers.responseConsumers- list of response consumers.poolEntry- leased pool entry. It will be automatically released back to the pool when execution is completed.connPool- pool of persistent reusable connections.context- HTTP contextcallback- future callback.- Returns:
- future representing pending completion of the operation.
- Since:
- 4.4
-
execute
public <T,E extends PoolEntry<HttpHost, Future<T> executeNHttpClientConnection>> (HttpAsyncRequestProducer requestProducer, HttpAsyncResponseConsumer<T> responseConsumer, ConnPool<HttpHost, E> connPool, HttpContext context) Initiates asynchronous HTTP request execution.- Type Parameters:
T- the result type of request execution.E- the connection pool entry type.- Parameters:
requestProducer- request producer.responseConsumer- response consumer.connPool- pool of persistent reusable connections.context- HTTP context- Returns:
- future representing pending completion of the operation.
-
execute
public <T,E extends PoolEntry<HttpHost, Future<T> executeNHttpClientConnection>> (HttpAsyncRequestProducer requestProducer, HttpAsyncResponseConsumer<T> responseConsumer, ConnPool<HttpHost, E> connPool) Initiates asynchronous HTTP request execution.- Type Parameters:
T- the result type of request execution.E- the connection pool entry type.- Parameters:
requestProducer- request producer.responseConsumer- response consumer.connPool- pool of persistent reusable connections.- Returns:
- future representing pending completion of the operation.
-
HttpAsyncRequester(HttpProcessor, ConnectionReuseStrategy)