public class DefaultRestConnection extends Object implements RestConnection
RestConnection| Constructor and Description |
|---|
DefaultRestConnection(String baseUri,
String configName,
org.mule.runtime.http.api.client.HttpClient httpClient,
org.mule.runtime.http.api.client.auth.HttpAuthentication authentication,
org.mule.runtime.api.util.MultiMap<String,String> defaultQueryParams,
org.mule.runtime.api.util.MultiMap<String,String> defaultHeaders)
Creates a new instance
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
afterStop()
Template method invoked by the
stop() to perform custom actions after the actual stopping
takes place. |
protected void |
beforeStop()
Template method invoked by the
stop() to perform custom actions before the actual stopping
takes place. |
CompletableFuture<org.mule.runtime.extension.api.runtime.operation.Result<String,HttpResponseAttributes>> |
bodylessRequest(org.mule.runtime.http.api.domain.message.request.HttpRequestBuilder requestBuilder,
int responseTimeoutMillis,
org.mule.runtime.extension.api.runtime.streaming.StreamingHelper streamingHelper)
Sends a request for which a response entity is not expected.
|
protected org.mule.runtime.http.api.domain.message.request.HttpRequest |
buildRequest(org.mule.runtime.http.api.domain.message.request.HttpRequestBuilder requestBuilder) |
String |
getBaseUri() |
protected void |
handleResponseError(org.mule.runtime.http.api.domain.message.response.HttpResponse response,
CompletableFuture<org.mule.runtime.extension.api.runtime.operation.Result<InputStream,HttpResponseAttributes>> future,
org.mule.runtime.extension.api.runtime.streaming.StreamingHelper streamingHelper,
RestConnectError error) |
CompletableFuture<org.mule.runtime.extension.api.runtime.operation.Result<InputStream,HttpResponseAttributes>> |
request(org.mule.runtime.http.api.domain.message.request.HttpRequestBuilder requestBuilder,
int responseTimeoutMillis,
org.mule.runtime.extension.api.runtime.streaming.StreamingHelper streamingHelper)
Sends a request and returns a
CompletableFuture with a Result which output is the response body in
the form of an InputStream and a HttpResponseAttributes. |
void |
stop()
Stops this connection by stopping the underlying
HttpClient and freeing other resources. |
protected HttpResponseAttributes |
toAttributes(org.mule.runtime.http.api.domain.message.response.HttpResponse response) |
public DefaultRestConnection(String baseUri, String configName, org.mule.runtime.http.api.client.HttpClient httpClient, org.mule.runtime.http.api.client.auth.HttpAuthentication authentication, org.mule.runtime.api.util.MultiMap<String,String> defaultQueryParams, org.mule.runtime.api.util.MultiMap<String,String> defaultHeaders)
baseUri - the service base uriconfigName - the name of the config that owns this connectionhttpClient - the client to useauthentication - the authentication mechanism to use, or nulldefaultQueryParams - query params to be automatically added to all requests done through this connectiondefaultHeaders - headers to be automatically added to all requests done through this connectionpublic CompletableFuture<org.mule.runtime.extension.api.runtime.operation.Result<String,HttpResponseAttributes>> bodylessRequest(org.mule.runtime.http.api.domain.message.request.HttpRequestBuilder requestBuilder, int responseTimeoutMillis, org.mule.runtime.extension.api.runtime.streaming.StreamingHelper streamingHelper)
CompletableFuture with
a Result which holds an empty String as output and a HttpResponseAttributes.
In case of failure, the future will be exceptionally completed with a RequestException, which
RequestException.getErrorMessage() will have its payload made repeatable through the use of the
streamingHelper
bodylessRequest in interface RestConnectionrequestBuilder - the HttpRequestBuilder on which the request has been configuredresponseTimeoutMillis - the request timeout in millisecondsstreamingHelper - the StreamingHelper in case an error message needs to have its payload made repeatableCompletableFuturepublic CompletableFuture<org.mule.runtime.extension.api.runtime.operation.Result<InputStream,HttpResponseAttributes>> request(org.mule.runtime.http.api.domain.message.request.HttpRequestBuilder requestBuilder, int responseTimeoutMillis, org.mule.runtime.extension.api.runtime.streaming.StreamingHelper streamingHelper)
CompletableFuture with a Result which output is the response body in
the form of an InputStream and a HttpResponseAttributes.
In case of failure, the future will be exceptionally completed with a RequestException, which
RequestException.getErrorMessage() will have its payload made repeatable through the use of the
streamingHelper
request in interface RestConnectionrequestBuilder - the HttpRequestBuilder on which the request has been configuredresponseTimeoutMillis - the request timeout in millisecondsstreamingHelper - the StreamingHelper in case an error message needs to have its payload made repeatableCompletableFutureprotected void handleResponseError(org.mule.runtime.http.api.domain.message.response.HttpResponse response,
CompletableFuture<org.mule.runtime.extension.api.runtime.operation.Result<InputStream,HttpResponseAttributes>> future,
org.mule.runtime.extension.api.runtime.streaming.StreamingHelper streamingHelper,
RestConnectError error)
protected org.mule.runtime.http.api.domain.message.request.HttpRequest buildRequest(org.mule.runtime.http.api.domain.message.request.HttpRequestBuilder requestBuilder)
protected HttpResponseAttributes toAttributes(org.mule.runtime.http.api.domain.message.response.HttpResponse response)
protected void beforeStop()
stop() to perform custom actions before the actual stopping
takes place. This method should not fail, but if it does, it won't stop the actual stopping processprotected void afterStop()
stop() to perform custom actions after the actual stopping
takes place. This method should not fail, but if it does, it won't stop the actual stopping processpublic String getBaseUri()
getBaseUri in interface RestConnectionpublic final void stop()
HttpClient and freeing other resources.
It will perform that task around invokations of beforeStop() and afterStop(), which
allow implementors to customize the stopping process. Notice that those methods should not fail, but if
they do, they won't stop resources from being freed.
stop in interface RestConnectionCopyright © 2019. All rights reserved.