public class HttpComponentsAsyncClientHttpRequestFactory extends HttpComponentsClientHttpRequestFactory implements AsyncClientHttpRequestFactory, InitializingBean
HttpComponentsClientHttpRequestFactory
. Uses
Apache HttpComponents
HttpAsyncClient 4.0 to create requests.HttpAsyncClient
Constructor and Description |
---|
HttpComponentsAsyncClientHttpRequestFactory()
Create a new instance of the
HttpComponentsAsyncClientHttpRequestFactory
with a default HttpAsyncClient and HttpClient . |
HttpComponentsAsyncClientHttpRequestFactory(org.apache.http.impl.nio.client.CloseableHttpAsyncClient asyncClient)
Create a new instance of the
HttpComponentsAsyncClientHttpRequestFactory
with the given CloseableHttpAsyncClient instance and a default HttpClient . |
HttpComponentsAsyncClientHttpRequestFactory(CloseableHttpClient httpClient,
org.apache.http.impl.nio.client.CloseableHttpAsyncClient asyncClient)
Create a new instance of the
HttpComponentsAsyncClientHttpRequestFactory
with the given CloseableHttpClient and CloseableHttpAsyncClient instances. |
HttpComponentsAsyncClientHttpRequestFactory(org.apache.http.nio.client.HttpAsyncClient asyncClient)
Create a new instance of the
HttpComponentsAsyncClientHttpRequestFactory
with the given HttpAsyncClient instance and a default HttpClient . |
HttpComponentsAsyncClientHttpRequestFactory(HttpClient httpClient,
org.apache.http.nio.client.HttpAsyncClient asyncClient)
Create a new instance of the
HttpComponentsAsyncClientHttpRequestFactory
with the given HttpClient and HttpAsyncClient instances. |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet()
Invoked by a BeanFactory after it has set all bean properties supplied
(and satisfied BeanFactoryAware and ApplicationContextAware).
|
AsyncClientHttpRequest |
createAsyncRequest(java.net.URI uri,
HttpMethod httpMethod)
Create a new asynchronous
AsyncClientHttpRequest for the specified URI
and HTTP method. |
void |
destroy()
Shutdown hook that closes the underlying
ClientConnectionManager 's
connection pool, if any. |
org.apache.http.nio.client.HttpAsyncClient |
getAsyncClient()
Return the
HttpAsyncClient used for
synchronous execution. |
org.apache.http.impl.nio.client.CloseableHttpAsyncClient |
getHttpAsyncClient()
Deprecated.
as of 4.3.10, in favor of
getAsyncClient() |
void |
setAsyncClient(org.apache.http.nio.client.HttpAsyncClient asyncClient)
Set the
HttpAsyncClient used for
synchronous execution. |
void |
setHttpAsyncClient(org.apache.http.impl.nio.client.CloseableHttpAsyncClient asyncClient)
Deprecated.
as of 4.3.10, in favor of
setAsyncClient(HttpAsyncClient) |
createHttpContext, createHttpUriRequest, createRequest, createRequestConfig, getHttpClient, mergeRequestConfig, postProcessHttpRequest, setBufferRequestBody, setConnectionRequestTimeout, setConnectTimeout, setHttpClient, setReadTimeout
public HttpComponentsAsyncClientHttpRequestFactory()
HttpComponentsAsyncClientHttpRequestFactory
with a default HttpAsyncClient
and HttpClient
.public HttpComponentsAsyncClientHttpRequestFactory(org.apache.http.nio.client.HttpAsyncClient asyncClient)
HttpComponentsAsyncClientHttpRequestFactory
with the given HttpAsyncClient
instance and a default HttpClient
.asyncClient
- the HttpAsyncClient instance to use for this request factorypublic HttpComponentsAsyncClientHttpRequestFactory(org.apache.http.impl.nio.client.CloseableHttpAsyncClient asyncClient)
HttpComponentsAsyncClientHttpRequestFactory
with the given CloseableHttpAsyncClient
instance and a default HttpClient
.asyncClient
- the CloseableHttpAsyncClient instance to use for this request factorypublic HttpComponentsAsyncClientHttpRequestFactory(HttpClient httpClient, org.apache.http.nio.client.HttpAsyncClient asyncClient)
HttpComponentsAsyncClientHttpRequestFactory
with the given HttpClient
and HttpAsyncClient
instances.httpClient
- the HttpClient instance to use for this request factoryasyncClient
- the HttpAsyncClient instance to use for this request factorypublic HttpComponentsAsyncClientHttpRequestFactory(CloseableHttpClient httpClient, org.apache.http.impl.nio.client.CloseableHttpAsyncClient asyncClient)
HttpComponentsAsyncClientHttpRequestFactory
with the given CloseableHttpClient
and CloseableHttpAsyncClient
instances.httpClient
- the CloseableHttpClient instance to use for this request factoryasyncClient
- the CloseableHttpAsyncClient instance to use for this request factorypublic void setAsyncClient(org.apache.http.nio.client.HttpAsyncClient asyncClient)
HttpAsyncClient
used for
synchronous execution.HttpComponentsClientHttpRequestFactory.setHttpClient(HttpClient)
public org.apache.http.nio.client.HttpAsyncClient getAsyncClient()
HttpAsyncClient
used for
synchronous execution.HttpComponentsClientHttpRequestFactory.getHttpClient()
@Deprecated public void setHttpAsyncClient(org.apache.http.impl.nio.client.CloseableHttpAsyncClient asyncClient)
setAsyncClient(HttpAsyncClient)
CloseableHttpAsyncClient
used for
asynchronous execution.@Deprecated public org.apache.http.impl.nio.client.CloseableHttpAsyncClient getHttpAsyncClient()
getAsyncClient()
CloseableHttpAsyncClient
used for
asynchronous execution.public void afterPropertiesSet()
InitializingBean
This method allows the bean instance to perform initialization only possible when all bean properties have been set and to throw an exception in the event of misconfiguration.
afterPropertiesSet
in interface InitializingBean
public AsyncClientHttpRequest createAsyncRequest(java.net.URI uri, HttpMethod httpMethod) throws java.io.IOException
AsyncClientHttpRequestFactory
AsyncClientHttpRequest
for the specified URI
and HTTP method.
The returned request can be written to, and then executed by calling
AsyncClientHttpRequest.executeAsync()
.
createAsyncRequest
in interface AsyncClientHttpRequestFactory
uri
- the URI to create a request forhttpMethod
- the HTTP method to executejava.io.IOException
- in case of I/O errorspublic void destroy() throws java.lang.Exception
HttpComponentsClientHttpRequestFactory
ClientConnectionManager
's
connection pool, if any.destroy
in interface DisposableBean
destroy
in class HttpComponentsClientHttpRequestFactory
java.lang.Exception
- in case of shutdown errors.
Exceptions will get logged but not rethrown to allow
other beans to release their resources too.