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
Deprecated.
|
static int |
DEFAULT_MAX_RESPONSE_SIZE
The default maximum response 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)
Deprecated.
as of 4.1.5 this property is no longer supported;
effectively renamed to
setMaxResponseSize(int) . |
void |
setMaxResponseSize(int maxResponseSize)
Set the default maximum response size.
|
void |
setSslContext(io.netty.handler.ssl.SslContext sslContext)
Set the SSL context.
|
@Deprecated public static final int DEFAULT_MAX_REQUEST_SIZE
setMaxRequestSize(int)
,
Constant Field Valuespublic static final int DEFAULT_MAX_RESPONSE_SIZE
setMaxResponseSize(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.
@Deprecated public void setMaxRequestSize(int maxRequestSize)
setMaxResponseSize(int)
.By default this is set to DEFAULT_MAX_REQUEST_SIZE
.
HttpObjectAggregator.HttpObjectAggregator(int)
public void setMaxResponseSize(int maxResponseSize)
By default this is set to DEFAULT_MAX_RESPONSE_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()
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 ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod) throws IOException
ClientHttpRequestFactory
ClientHttpRequest
for the specified URI and HTTP method.
The returned request can be written to, and then executed by calling
ClientHttpRequest.execute()
.
createRequest
in interface ClientHttpRequestFactory
uri
- 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
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 InterruptedException
DisposableBean
destroy
in interface DisposableBean
InterruptedException