Class HttpComponents5ClientFactory
java.lang.Object
org.springframework.ws.transport.http.HttpComponents5ClientFactory
- All Implemented Interfaces:
org.springframework.beans.factory.FactoryBean<org.apache.hc.client5.http.impl.classic.CloseableHttpClient>
public class HttpComponents5ClientFactory
extends Object
implements org.springframework.beans.factory.FactoryBean<org.apache.hc.client5.http.impl.classic.CloseableHttpClient>
FactoryBean
to set up a CloseableHttpClient
using HttpComponents
HttpClient 5.- Since:
- 4.0.5
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
static interface
static class
HttpClientHttpRequestInterceptor
implementation that removesContent-Length
andTransfer-Encoding
headers from the request. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final org.apache.hc.client5.http.auth.AuthScope
AuthScope
to match any Host.Fields inherited from interface org.springframework.beans.factory.FactoryBean
OBJECT_TYPE_ATTRIBUTE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addClientBuilderCustomizer
(HttpComponents5ClientFactory.HttpClientBuilderCustomizer clientBuilderCustomizer) Add aHttpComponents5ClientFactory.HttpClientBuilderCustomizer
to invoke when creating anCloseableHttpClient
managed by this factory.void
addConnectionManagerBuilderCustomizer
(HttpComponents5ClientFactory.PoolingHttpClientConnectionManagerBuilderCustomizer connectionManagerBuilderCustomizer) Add aHttpComponents5ClientFactory.PoolingHttpClientConnectionManagerBuilderCustomizer
to invoke when creating anCloseableHttpClient
managed by this factory.org.apache.hc.client5.http.impl.classic.CloseableHttpClient
build()
org.apache.hc.client5.http.impl.classic.CloseableHttpClient
Class<?>
boolean
void
setAuthScope
(org.apache.hc.client5.http.auth.AuthScope authScope) Sets the authentication scope to be used.void
setClientBuilderCustomizer
(HttpComponents5ClientFactory.HttpClientBuilderCustomizer clientBuilderCustomizer) Deprecated, for removal: This API element is subject to removal in a future version.void
setConnectionManagerBuilderCustomizer
(HttpComponents5ClientFactory.PoolingHttpClientConnectionManagerBuilderCustomizer connectionManagerBuilderCustomizer) Deprecated, for removal: This API element is subject to removal in a future version.as of 4.1.0 in favor ofaddConnectionManagerBuilderCustomizer(PoolingHttpClientConnectionManagerBuilderCustomizer)
void
setConnectionTimeout
(Duration timeout) Sets the timeout until a connection is established.void
setCredentials
(org.apache.hc.client5.http.auth.Credentials credentials) Sets the credentials to be used.void
setMaxConnectionsPerHost
(Map<String, String> maxConnectionsPerHost) Sets the maximum number of connections per host for the underlying HttpClient.void
setMaxTotalConnections
(int maxTotalConnections) Sets the maximum number of connections allowed for the underlying HttpClient.void
setReadTimeout
(Duration timeout) Set the socket read timeout for the underlying HttpClient.static HttpComponents5ClientFactory
Create a new instance with default settings.
-
Field Details
-
ANY
public static final org.apache.hc.client5.http.auth.AuthScope ANYAuthScope
to match any Host.NOTE:
ANY
was removed fromAuthScope
in HttpComponents 5.0. This value object will easy migration from HttpComponents 4. Consider using aClientInterceptor
to implement http client agnostic preemptive basic auth.- See Also:
-
AuthScope(String, String, int, String, String)
-
-
Constructor Details
-
HttpComponents5ClientFactory
public HttpComponents5ClientFactory()
-
-
Method Details
-
withDefaults
Create a new instance with default settings. This configuresHttpComponents5ClientFactory.RemoveSoapHeadersInterceptor
as the first interceptor- Returns:
- a factory with default settings
-
addClientBuilderCustomizer
public void addClientBuilderCustomizer(HttpComponents5ClientFactory.HttpClientBuilderCustomizer clientBuilderCustomizer) Add aHttpComponents5ClientFactory.HttpClientBuilderCustomizer
to invoke when creating anCloseableHttpClient
managed by this factory.- Parameters:
clientBuilderCustomizer
- the customizer to invoke- Since:
- 4.1.0
-
setClientBuilderCustomizer
@Deprecated(since="4.1.0", forRemoval=true) public void setClientBuilderCustomizer(HttpComponents5ClientFactory.HttpClientBuilderCustomizer clientBuilderCustomizer) Deprecated, for removal: This API element is subject to removal in a future version.as of 4.1.0 in favor ofaddClientBuilderCustomizer(HttpClientBuilderCustomizer)
lAdd aHttpComponents5ClientFactory.HttpClientBuilderCustomizer
to invoke when creating anCloseableHttpClient
managed by this factory.- Parameters:
clientBuilderCustomizer
- the customizer to invoke
-
addConnectionManagerBuilderCustomizer
public void addConnectionManagerBuilderCustomizer(HttpComponents5ClientFactory.PoolingHttpClientConnectionManagerBuilderCustomizer connectionManagerBuilderCustomizer) Add aHttpComponents5ClientFactory.PoolingHttpClientConnectionManagerBuilderCustomizer
to invoke when creating anCloseableHttpClient
managed by this factory.- Parameters:
connectionManagerBuilderCustomizer
- the customizer to invoke
-
setConnectionManagerBuilderCustomizer
@Deprecated(since="4.1.0", forRemoval=true) public void setConnectionManagerBuilderCustomizer(HttpComponents5ClientFactory.PoolingHttpClientConnectionManagerBuilderCustomizer connectionManagerBuilderCustomizer) Deprecated, for removal: This API element is subject to removal in a future version.as of 4.1.0 in favor ofaddConnectionManagerBuilderCustomizer(PoolingHttpClientConnectionManagerBuilderCustomizer)
Add aHttpComponents5ClientFactory.PoolingHttpClientConnectionManagerBuilderCustomizer
to invoke when creating anCloseableHttpClient
managed by this factory.- Parameters:
connectionManagerBuilderCustomizer
- the customizer to invoke
-
setCredentials
public void setCredentials(org.apache.hc.client5.http.auth.Credentials credentials) Sets the credentials to be used. If not set, no authentication is done.- See Also:
-
UsernamePasswordCredentials
NTCredentials
-
setAuthScope
public void setAuthScope(org.apache.hc.client5.http.auth.AuthScope authScope) Sets the authentication scope to be used. Only used when thecredentials
property has been set.By default,
ANY
is used.- See Also:
-
setConnectionTimeout
Sets the timeout until a connection is established. A value of 0 means never timeout.- Parameters:
timeout
- the timeout value
-
setReadTimeout
Set the socket read timeout for the underlying HttpClient. A value of 0 means never timeout.- Parameters:
timeout
- the timeout value
-
setMaxTotalConnections
public void setMaxTotalConnections(int maxTotalConnections) Sets the maximum number of connections allowed for the underlying HttpClient.- Parameters:
maxTotalConnections
- the maximum number of connections allowed- See Also:
-
PoolingHttpClientConnectionManager
-
setMaxConnectionsPerHost
Sets the maximum number of connections per host for the underlying HttpClient. The maximum number of connections per host can be set in a form accepted by thejava.util.Properties
class, like as follows:https://www.example.com=1 http://www.example.com:8080=7 http://www.springframework.org=10
The host can be specified as a URI (with scheme and port).
- Parameters:
maxConnectionsPerHost
- a properties object specifying the maximum number of connection- See Also:
-
PoolingHttpClientConnectionManager
-
build
public org.apache.hc.client5.http.impl.classic.CloseableHttpClient build() -
isSingleton
public boolean isSingleton()- Specified by:
isSingleton
in interfaceorg.springframework.beans.factory.FactoryBean<org.apache.hc.client5.http.impl.classic.CloseableHttpClient>
-
getObject
- Specified by:
getObject
in interfaceorg.springframework.beans.factory.FactoryBean<org.apache.hc.client5.http.impl.classic.CloseableHttpClient>
- Throws:
Exception
-
getObjectType
- Specified by:
getObjectType
in interfaceorg.springframework.beans.factory.FactoryBean<org.apache.hc.client5.http.impl.classic.CloseableHttpClient>
-
addClientBuilderCustomizer(HttpClientBuilderCustomizer)
l