java.lang.Object | ||
↳ | org.springframework.remoting.httpinvoker.AbstractHttpInvokerRequestExecutor | |
↳ | org.springframework.remoting.httpinvoker.CommonsHttpInvokerRequestExecutor |
HttpInvokerRequestExecutor
implementation that uses
Jakarta Commons HttpClient
to execute POST requests. Requires Commons HttpClient 3.0 or higher.
Allows to use a pre-configured org.apache.commons.httpclient.HttpClient instance, potentially with authentication, HTTP connection pooling, etc. Also designed for easy subclassing, providing specific template methods.
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.springframework.remoting.httpinvoker.AbstractHttpInvokerRequestExecutor
|
[Expand]
Inherited Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.springframework.remoting.httpinvoker.AbstractHttpInvokerRequestExecutor
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Create a new CommonsHttpInvokerRequestExecutor with a default
HttpClient that uses a default MultiThreadedHttpConnectionManager.
| |||||||||||
Create a new CommonsHttpInvokerRequestExecutor with the given
HttpClient instance.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Return the HttpClient instance that this request executor uses.
| |||||||||||
Set the HttpClient instance to use for this request executor.
| |||||||||||
Set the socket read timeout for the underlying HttpClient.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Create a PostMethod for the given configuration.
| |||||||||||
Execute the given request through Commons HttpClient.
| |||||||||||
Execute the given PostMethod instance.
| |||||||||||
Extract the response body from the given executed remote invocation
request.
| |||||||||||
Determine whether the given response indicates a GZIP response.
| |||||||||||
Set the given serialized remote invocation as request body.
| |||||||||||
Validate the given response as contained in the PostMethod object,
throwing an exception if it does not correspond to a successful HTTP response.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.springframework.remoting.httpinvoker.AbstractHttpInvokerRequestExecutor
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
org.springframework.beans.factory.BeanClassLoaderAware
| |||||||||||
From interface
org.springframework.remoting.httpinvoker.HttpInvokerRequestExecutor
|
Create a new CommonsHttpInvokerRequestExecutor with a default HttpClient that uses a default MultiThreadedHttpConnectionManager. Sets the socket read timeout to #DEFAULT_READ_TIMEOUT_MILLISECONDS.
Create a new CommonsHttpInvokerRequestExecutor with the given HttpClient instance. The socket read timeout of the provided HttpClient will not be changed.
httpClient | the HttpClient instance to use for this request executor |
---|
Return the HttpClient instance that this request executor uses.
Set the HttpClient instance to use for this request executor.
Set the socket read timeout for the underlying HttpClient. A value
of 0 means
timeout | the timeout value in milliseconds |
---|
Create a PostMethod for the given configuration.
The default implementation creates a standard PostMethod with "application/x-java-serialized-object" as "Content-Type" header.
config | the HTTP invoker configuration that specifies the target service |
---|
IOException | if thrown by I/O methods |
---|
Execute the given request through Commons HttpClient.
This method implements the basic processing workflow: The actual work happens in this class's template methods.
config | the HTTP invoker configuration that specifies the target service |
---|---|
baos | the ByteArrayOutputStream that contains the serialized RemoteInvocation object |
createPostMethod(HttpInvokerClientConfiguration)
setRequestBody(HttpInvokerClientConfiguration, PostMethod, ByteArrayOutputStream)
executePostMethod(HttpInvokerClientConfiguration, HttpClient, PostMethod)
validateResponse(HttpInvokerClientConfiguration, PostMethod)
getResponseBody(HttpInvokerClientConfiguration, PostMethod)
Execute the given PostMethod instance.
config | the HTTP invoker configuration that specifies the target service |
---|---|
httpClient | the HttpClient to execute on |
postMethod | the PostMethod to execute |
IOException | if thrown by I/O methods |
---|
Extract the response body from the given executed remote invocation request.
The default implementation simply fetches the PostMethod's response body stream. If the response is recognized as GZIP response, the InputStream will get wrapped in a GZIPInputStream.
config | the HTTP invoker configuration that specifies the target service |
---|---|
postMethod | the PostMethod to read the response body from |
IOException | if thrown by I/O methods |
---|
isGzipResponse(PostMethod)
Determine whether the given response indicates a GZIP response.
Default implementation checks whether the HTTP "Content-Encoding" header contains "gzip" (in any casing).
postMethod | the PostMethod to check |
---|
Set the given serialized remote invocation as request body.
The default implementation simply sets the serialized invocation as the PostMethod's request body. This can be overridden, for example, to write a specific encoding and potentially set appropriate HTTP request headers.
config | the HTTP invoker configuration that specifies the target service |
---|---|
postMethod | the PostMethod to set the request body on |
baos | the ByteArrayOutputStream that contains the serialized RemoteInvocation object |
IOException | if thrown by I/O methods |
---|
Validate the given response as contained in the PostMethod object, throwing an exception if it does not correspond to a successful HTTP response.
Default implementation rejects any HTTP status code beyond 2xx, to avoid parsing the response body and trying to deserialize from a corrupted stream.
config | the HTTP invoker configuration that specifies the target service |
---|---|
postMethod | the executed PostMethod to validate |
IOException | if validation failed |
---|