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(RestRequestBuilder requestBuilder,
int responseTimeoutMillis,
org.mule.runtime.api.metadata.MediaType defaultResponseMediaType,
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(RestRequestBuilder requestBuilder) |
String |
getBaseUri() |
protected void |
handleResponseError(org.mule.runtime.http.api.domain.message.response.HttpResponse response,
org.mule.runtime.api.metadata.MediaType defaultResponseMediaType,
CompletableFuture<org.mule.runtime.extension.api.runtime.operation.Result<InputStream,HttpResponseAttributes>> future,
org.mule.runtime.extension.api.runtime.streaming.StreamingHelper streamingHelper,
RestError error) |
CompletableFuture<org.mule.runtime.extension.api.runtime.operation.Result<InputStream,HttpResponseAttributes>> |
request(RestRequestBuilder requestBuilder,
int responseTimeoutMillis,
org.mule.runtime.api.metadata.MediaType defaultResponseMediaType,
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) |
org.mule.runtime.api.connection.ConnectionValidationResult |
validate(ConnectionValidationSettings settings,
int responseTimeoutMillis)
Sends a request as configured using provided settings builder and validates it using the provided conditions.
|
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(RestRequestBuilder requestBuilder, int responseTimeoutMillis, org.mule.runtime.api.metadata.MediaType defaultResponseMediaType, 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 RestRequestBuilder 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(RestRequestBuilder requestBuilder, int responseTimeoutMillis, org.mule.runtime.api.metadata.MediaType defaultResponseMediaType, 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 RestRequestBuilder 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 org.mule.runtime.api.connection.ConnectionValidationResult validate(ConnectionValidationSettings settings, int responseTimeoutMillis)
ConnectionValidationResult corresponding to this validation result.validate in interface RestConnectionsettings - the settings that indicate how to do this request and the validations to do in it's response.responseTimeoutMillis - the request timeout in millisecondsConnectionValidationResult corresponding to this validation resultprotected void handleResponseError(org.mule.runtime.http.api.domain.message.response.HttpResponse response,
org.mule.runtime.api.metadata.MediaType defaultResponseMediaType,
CompletableFuture<org.mule.runtime.extension.api.runtime.operation.Result<InputStream,HttpResponseAttributes>> future,
org.mule.runtime.extension.api.runtime.streaming.StreamingHelper streamingHelper,
RestError error)
protected org.mule.runtime.http.api.domain.message.request.HttpRequest buildRequest(RestRequestBuilder 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 © 2021. All rights reserved.