Top Description Fields Constructors Methods
org.springframework.http.client

public Class JettyClientHttpRequestFactory

extends Object
implements ClientHttpRequestFactory, InitializingBean, DisposableBean
Class Inheritance
All Implemented Interfaces
org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean, org.springframework.http.client.ClientHttpRequestFactory
Imports
java.io.IOException, java.net.URI, java.time.Duration, org.eclipse.jetty.client.HttpClient, .Request, org.springframework.beans.factory.DisposableBean, .InitializingBean, org.springframework.http.HttpMethod, org.springframework.util.Assert

ClientHttpRequestFactory implementation based on Jetty's HttpClient.
Author
Arjen Poutsma
Since
6.1
See Also
Jetty HttpClient

Field Summary

Modifier and TypeField and Description
private final boolean
private final HttpClient
private long

Constructor Summary

AccessConstructor and Description
public
JettyClientHttpRequestFactory()

Default constructor that creates a new instance of HttpClient.

public
JettyClientHttpRequestFactory(HttpClient
the
httpClient
)

Constructor that takes a customized HttpClient instance.

private
JettyClientHttpRequestFactory(HttpClient httpClient, boolean defaultClient)

Method Summary

Modifier and TypeMethod and Description
public void
afterPropertiesSet()

Implements org.springframework.beans.factory.InitializingBean.afterPropertiesSet.

Invoked by the containing BeanFactory after it has set all bean properties and satisfied BeanFactoryAware, ApplicationContextAware etc.

This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.

public ClientHttpRequest
createRequest(URI
the URI to create a request for
uri
,
HttpMethod
the HTTP method to execute
httpMethod
)

Implements org.springframework.http.client.ClientHttpRequestFactory.createRequest.

Create a new ClientHttpRequest for the specified URI and HTTP method.
public void
destroy()

Implements org.springframework.beans.factory.DisposableBean.destroy.

Invoked by the containing BeanFactory on destruction of a bean.
public void
setConnectTimeout(int connectTimeout)

Set the underlying connect timeout in milliseconds.

public void
setConnectTimeout(Duration connectTimeout)

Set the underlying connect timeout in milliseconds.

public void
setReadTimeout(long readTimeout)

Set the underlying read timeout in milliseconds.

public void
setReadTimeout(Duration readTimeout)

Set the underlying read timeout as Duration.

private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

defaultClientback to summary
private final boolean defaultClient
httpClientback to summary
private final HttpClient httpClient
readTimeoutback to summary
private long readTimeout

Constructor Detail

JettyClientHttpRequestFactoryback to summary
public JettyClientHttpRequestFactory()

Default constructor that creates a new instance of HttpClient.

JettyClientHttpRequestFactoryback to summary
public JettyClientHttpRequestFactory(HttpClient httpClient)

Constructor that takes a customized HttpClient instance.

Parameters
httpClient:HttpClient

the

JettyClientHttpRequestFactoryback to summary
private JettyClientHttpRequestFactory(HttpClient httpClient, boolean defaultClient)

Method Detail

afterPropertiesSetback to summary
public void afterPropertiesSet() throws Exception

Implements org.springframework.beans.factory.InitializingBean.afterPropertiesSet.

Doc from org.springframework.beans.factory.InitializingBean.afterPropertiesSet.

Invoked by the containing BeanFactory after it has set all bean properties and satisfied BeanFactoryAware, ApplicationContextAware etc.

This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.

Annotations
@Override
Exceptions
Exception:
in the event of misconfiguration (such as failure to set an essential property) or if initialization fails for any other reason
createRequestback to summary
public ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod) throws IOException

Implements org.springframework.http.client.ClientHttpRequestFactory.createRequest.

Doc from org.springframework.http.client.ClientHttpRequestFactory.createRequest.

Create a new ClientHttpRequest for the specified URI and HTTP method.

The returned request can be written to, and then executed by calling ClientHttpRequest#execute().

Parameters
uri:URI

the URI to create a request for

httpMethod:HttpMethod

the HTTP method to execute

Returns:ClientHttpRequest

the created request

Annotations
@Override
Exceptions
IOException:
in case of I/O errors
destroyback to summary
public void destroy() throws Exception

Implements org.springframework.beans.factory.DisposableBean.destroy.

Doc from org.springframework.beans.factory.DisposableBean.destroy.

Invoked by the containing BeanFactory on destruction of a bean.

Annotations
@Override
Exceptions
Exception:
in case of shutdown errors. Exceptions will get logged but not rethrown to allow other beans to release their resources as well.
setConnectTimeoutback to summary
public void setConnectTimeout(int connectTimeout)

Set the underlying connect timeout in milliseconds. A value of 0 specifies an infinite timeout.

Default is 5 seconds.

setConnectTimeoutback to summary
public void setConnectTimeout(Duration connectTimeout)

Set the underlying connect timeout in milliseconds. A value of 0 specifies an infinite timeout.

Default is 5 seconds.

setReadTimeoutback to summary
public void setReadTimeout(long readTimeout)

Set the underlying read timeout in milliseconds.

Default is 10 seconds.

setReadTimeoutback to summary
public void setReadTimeout(Duration readTimeout)

Set the underlying read timeout as Duration.

Default is 10 seconds.

startHttpClientback to summary
private void startHttpClient() throws Exception