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 httpAsyncClient)
Create a new instance of the
HttpComponentsAsyncClientHttpRequestFactory
with the given HttpAsyncClient instance and a default HttpClient . |
HttpComponentsAsyncClientHttpRequestFactory(CloseableHttpClient httpClient,
org.apache.http.impl.nio.client.CloseableHttpAsyncClient httpAsyncClient)
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(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.impl.nio.client.CloseableHttpAsyncClient |
getHttpAsyncClient()
Return the
HttpClient used for
asynchronous execution. |
void |
setHttpAsyncClient(org.apache.http.impl.nio.client.CloseableHttpAsyncClient httpAsyncClient)
Set the
HttpClient used for
asynchronous execution. |
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.impl.nio.client.CloseableHttpAsyncClient httpAsyncClient)
HttpComponentsAsyncClientHttpRequestFactory
with the given HttpAsyncClient
instance and a default HttpClient
.httpAsyncClient
- the HttpAsyncClient instance to use for this request factorypublic HttpComponentsAsyncClientHttpRequestFactory(CloseableHttpClient httpClient, org.apache.http.impl.nio.client.CloseableHttpAsyncClient httpAsyncClient)
HttpComponentsAsyncClientHttpRequestFactory
with the given HttpClient
and HttpAsyncClient
instances.httpClient
- the HttpClient instance to use for this request factoryhttpAsyncClient
- the HttpAsyncClient instance to use for this request factorypublic void setHttpAsyncClient(org.apache.http.impl.nio.client.CloseableHttpAsyncClient httpAsyncClient)
HttpClient
used for
asynchronous execution.public org.apache.http.impl.nio.client.CloseableHttpAsyncClient getHttpAsyncClient()
HttpClient
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(URI uri, HttpMethod httpMethod) throws 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 executeIOException
- in case of I/O errorspublic void destroy() throws Exception
HttpComponentsClientHttpRequestFactory
ClientConnectionManager
's
connection pool, if any.destroy
in interface DisposableBean
destroy
in class HttpComponentsClientHttpRequestFactory
Exception
- in case of shutdown errors.
Exceptions will get logged but not rethrown to allow
other beans to release their resources too.