类 HttpComponentsAsyncClientHttpRequestFactory
- java.lang.Object
- org.springframework.http.client.HttpComponentsClientHttpRequestFactory
- org.springframework.http.client.HttpComponentsAsyncClientHttpRequestFactory
public class HttpComponentsAsyncClientHttpRequestFactory extends HttpComponentsClientHttpRequestFactory implements AsyncClientHttpRequestFactory, InitializingBean
Asynchronous extension of theHttpComponentsClientHttpRequestFactory. Uses Apache HttpComponents HttpAsyncClient 4.0 to create requests.- 从以下版本开始:
- 4.0
- 作者:
- Arjen Poutsma, Stephane Nicoll
- 另请参阅:
HttpAsyncClient
构造器概要
构造器 构造器 说明 HttpComponentsAsyncClientHttpRequestFactory()Create a new instance of theHttpComponentsAsyncClientHttpRequestFactorywith a defaultHttpAsyncClientandHttpClient.HttpComponentsAsyncClientHttpRequestFactory(HttpClient httpClient, org.apache.http.nio.client.HttpAsyncClient asyncClient)Create a new instance of theHttpComponentsAsyncClientHttpRequestFactorywith the givenHttpClientandHttpAsyncClientinstances.HttpComponentsAsyncClientHttpRequestFactory(CloseableHttpClient httpClient, org.apache.http.impl.nio.client.CloseableHttpAsyncClient asyncClient)Create a new instance of theHttpComponentsAsyncClientHttpRequestFactorywith the givenCloseableHttpClientandCloseableHttpAsyncClientinstances.HttpComponentsAsyncClientHttpRequestFactory(org.apache.http.impl.nio.client.CloseableHttpAsyncClient asyncClient)Create a new instance of theHttpComponentsAsyncClientHttpRequestFactorywith the givenCloseableHttpAsyncClientinstance and a defaultHttpClient.HttpComponentsAsyncClientHttpRequestFactory(org.apache.http.nio.client.HttpAsyncClient asyncClient)Create a new instance of theHttpComponentsAsyncClientHttpRequestFactorywith the givenHttpAsyncClientinstance and a defaultHttpClient.
方法概要
所有方法 实例方法 具体方法 已过时的方法 修饰符和类型 方法 说明 voidafterPropertiesSet()Invoked by the containingBeanFactoryafter it has set all bean properties and satisfiedBeanFactoryAware,ApplicationContextAwareetc.AsyncClientHttpRequestcreateAsyncRequest(URI uri, HttpMethod httpMethod)Create a new asynchronousAsyncClientHttpRequestfor the specified URI and HTTP method.voiddestroy()Shutdown hook that closes the underlyingClientConnectionManager's connection pool, if any.org.apache.http.nio.client.HttpAsyncClientgetAsyncClient()Return theHttpAsyncClientused for synchronous execution.org.apache.http.impl.nio.client.CloseableHttpAsyncClientgetHttpAsyncClient()已过时。as of 4.3.10, in favor ofgetAsyncClient()voidsetAsyncClient(org.apache.http.nio.client.HttpAsyncClient asyncClient)Set theHttpAsyncClientused for synchronous execution.voidsetHttpAsyncClient(org.apache.http.impl.nio.client.CloseableHttpAsyncClient asyncClient)已过时。as of 4.3.10, in favor ofsetAsyncClient(HttpAsyncClient)从类继承的方法 org.springframework.http.client.HttpComponentsClientHttpRequestFactory
createHttpContext, createHttpUriRequest, createRequest, createRequestConfig, getHttpClient, mergeRequestConfig, postProcessHttpRequest, setBufferRequestBody, setConnectionRequestTimeout, setConnectTimeout, setHttpClient, setReadTimeout
构造器详细资料
HttpComponentsAsyncClientHttpRequestFactory
public HttpComponentsAsyncClientHttpRequestFactory()
Create a new instance of theHttpComponentsAsyncClientHttpRequestFactorywith a defaultHttpAsyncClientandHttpClient.
HttpComponentsAsyncClientHttpRequestFactory
public HttpComponentsAsyncClientHttpRequestFactory(org.apache.http.nio.client.HttpAsyncClient asyncClient)
Create a new instance of theHttpComponentsAsyncClientHttpRequestFactorywith the givenHttpAsyncClientinstance and a defaultHttpClient.- 参数:
asyncClient- the HttpAsyncClient instance to use for this request factory- 从以下版本开始:
- 4.3.10
HttpComponentsAsyncClientHttpRequestFactory
public HttpComponentsAsyncClientHttpRequestFactory(org.apache.http.impl.nio.client.CloseableHttpAsyncClient asyncClient)
Create a new instance of theHttpComponentsAsyncClientHttpRequestFactorywith the givenCloseableHttpAsyncClientinstance and a defaultHttpClient.- 参数:
asyncClient- the CloseableHttpAsyncClient instance to use for this request factory
HttpComponentsAsyncClientHttpRequestFactory
public HttpComponentsAsyncClientHttpRequestFactory(HttpClient httpClient, org.apache.http.nio.client.HttpAsyncClient asyncClient)
Create a new instance of theHttpComponentsAsyncClientHttpRequestFactorywith the givenHttpClientandHttpAsyncClientinstances.- 参数:
httpClient- the HttpClient instance to use for this request factoryasyncClient- the HttpAsyncClient instance to use for this request factory- 从以下版本开始:
- 4.3.10
HttpComponentsAsyncClientHttpRequestFactory
public HttpComponentsAsyncClientHttpRequestFactory(CloseableHttpClient httpClient, org.apache.http.impl.nio.client.CloseableHttpAsyncClient asyncClient)
Create a new instance of theHttpComponentsAsyncClientHttpRequestFactorywith the givenCloseableHttpClientandCloseableHttpAsyncClientinstances.- 参数:
httpClient- the CloseableHttpClient instance to use for this request factoryasyncClient- the CloseableHttpAsyncClient instance to use for this request factory
方法详细资料
setAsyncClient
public void setAsyncClient(org.apache.http.nio.client.HttpAsyncClient asyncClient)
Set theHttpAsyncClientused for synchronous execution.- 从以下版本开始:
- 4.3.10
- 另请参阅:
HttpComponentsClientHttpRequestFactory.setHttpClient(HttpClient)
getAsyncClient
public org.apache.http.nio.client.HttpAsyncClient getAsyncClient()
Return theHttpAsyncClientused for synchronous execution.- 从以下版本开始:
- 4.3.10
- 另请参阅:
HttpComponentsClientHttpRequestFactory.getHttpClient()
setHttpAsyncClient
@Deprecated public void setHttpAsyncClient(org.apache.http.impl.nio.client.CloseableHttpAsyncClient asyncClient)
已过时。as of 4.3.10, in favor ofsetAsyncClient(HttpAsyncClient)Set theCloseableHttpAsyncClientused for asynchronous execution.
getHttpAsyncClient
@Deprecated public org.apache.http.impl.nio.client.CloseableHttpAsyncClient getHttpAsyncClient()
已过时。as of 4.3.10, in favor ofgetAsyncClient()Return theCloseableHttpAsyncClientused for asynchronous execution.
afterPropertiesSet
public void afterPropertiesSet()
从接口复制的说明:InitializingBeanInvoked by the containingBeanFactoryafter it has set all bean properties and satisfiedBeanFactoryAware,ApplicationContextAwareetc.This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.
- 指定者:
afterPropertiesSet在接口中InitializingBean
createAsyncRequest
public AsyncClientHttpRequest createAsyncRequest(URI uri, HttpMethod httpMethod) throws IOException
从接口复制的说明:AsyncClientHttpRequestFactoryCreate a new asynchronousAsyncClientHttpRequestfor the specified URI and HTTP method.The returned request can be written to, and then executed by calling
AsyncClientHttpRequest.executeAsync().- 指定者:
createAsyncRequest在接口中AsyncClientHttpRequestFactory- 参数:
uri- the URI to create a request forhttpMethod- the HTTP method to execute- 返回:
- the created request
- 抛出:
IOException- in case of I/O errors
destroy
public void destroy() throws Exception
Shutdown hook that closes the underlyingClientConnectionManager's connection pool, if any.- 指定者:
destroy在接口中DisposableBean- 覆盖:
destroy在类中HttpComponentsClientHttpRequestFactory- 抛出:
Exception- in case of shutdown errors. Exceptions will get logged but not rethrown to allow other beans to release their resources as well.