public class Netty4ClientHttpRequestFactory extends Object implements ClientHttpRequestFactory, AsyncClientHttpRequestFactory, InitializingBean, DisposableBean
ClientHttpRequestFactory implementation that
uses Netty 4 to create requests.
Allows to use a pre-configured EventLoopGroup instance - useful for sharing
across multiple clients.
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_MAX_REQUEST_SIZE
The default maximum request size.
|
| Constructor and Description |
|---|
Netty4ClientHttpRequestFactory()
Create a new
Netty4ClientHttpRequestFactory with a default
NioEventLoopGroup. |
Netty4ClientHttpRequestFactory(io.netty.channel.EventLoopGroup eventLoopGroup)
Create a new
Netty4ClientHttpRequestFactory with the given
EventLoopGroup. |
| 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. |
ClientHttpRequest |
createRequest(URI uri,
HttpMethod httpMethod)
Create a new
ClientHttpRequest for the specified URI and HTTP method. |
void |
destroy()
Invoked by a BeanFactory on destruction of a singleton.
|
void |
setMaxRequestSize(int maxRequestSize)
Set the default maximum request size.
|
void |
setSslContext(io.netty.handler.ssl.SslContext sslContext)
Set the SSL context.
|
public static final int DEFAULT_MAX_REQUEST_SIZE
setMaxRequestSize(int),
Constant Field Valuespublic Netty4ClientHttpRequestFactory()
Netty4ClientHttpRequestFactory with a default
NioEventLoopGroup.public Netty4ClientHttpRequestFactory(io.netty.channel.EventLoopGroup eventLoopGroup)
Netty4ClientHttpRequestFactory with the given
EventLoopGroup.
NOTE: the given group will not be shutdown by this factory; doing so becomes the responsibility of the caller.
public void setMaxRequestSize(int maxRequestSize)
By default this is set to DEFAULT_MAX_REQUEST_SIZE.
HttpObjectAggregator.HttpObjectAggregator(int)public void setSslContext(io.netty.handler.ssl.SslContext sslContext)
SslHandler in the channel pipeline.
By default this is not set.
public void afterPropertiesSet()
InitializingBeanThis 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 InitializingBeanpublic ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod) throws IOException
ClientHttpRequestFactoryClientHttpRequest for the specified URI and HTTP method.
The returned request can be written to, and then executed by calling
ClientHttpRequest.execute().
createRequest in interface ClientHttpRequestFactoryuri - the URI to create a request forhttpMethod - the HTTP method to executeIOException - in case of I/O errorspublic AsyncClientHttpRequest createAsyncRequest(URI uri, HttpMethod httpMethod) throws IOException
AsyncClientHttpRequestFactoryAsyncClientHttpRequest for the specified URI
and HTTP method.
The returned request can be written to, and then executed by calling
AsyncClientHttpRequest.executeAsync().
createAsyncRequest in interface AsyncClientHttpRequestFactoryuri - the URI to create a request forhttpMethod - the HTTP method to executeIOException - in case of I/O errorspublic void destroy()
throws InterruptedException
DisposableBeandestroy in interface DisposableBeanInterruptedException