@MinMuleVersion(value="4.1")
@NoImplement
public interface ExtensionsClient
ExtensionsClient is a simple interface for executing extension operations programmatically.
The operation to execute is referenced through its name and the name of the extension in which it's defined. Notice that the extension is referenced by name and not GAV, which means that the extension is assumed to be present and activated on the current execution context.
Once the operation is located, the operation execution is parameterized by not only providing parameter values, but also config reference, reconnection and streaming strategies, etc.
Note that this client will be reachable through the mule registry, and you will be able to inject it in any class with lifecycle.
A usage example for an operation with this signature public String getName(@UseConfig config, int account) could be:
public class UsingExtensionsClient {
@Inject ExtensionsClient client;
...
public void executeWithClient() {
client.<String, Object>executeAsync("myExtensionName", "getName", params ->
params.withConfigRef("conf").withParameter("account", 12)
).whenComplete((result, e) -> {
if (e != null) {
logError(e);
} else {
processResult(result);
}
});
}
| Modifier and Type | Method and Description |
|---|---|
<T,A> CompletableFuture<Result<T,A>> |
execute(String extension,
String operation,
Consumer<OperationParameterizer> parameters)
Executes an operation asynchronously by returning a
CompletableFuture instance that will complete into a
Result with the corresponding payload and attributes after the operation execution finished. |
<T,A> Result<T,A> |
execute(String extension,
String operation,
OperationParameters parameters)
Deprecated.
since 4.5.0. Use
execute(String, String, Consumer) instead |
<T,A> CompletableFuture<Result<T,A>> |
executeAsync(String extension,
String operation,
OperationParameters parameters)
Deprecated.
since 4.5.0. Use
execute(String, String, Consumer) instead |
@MinMuleVersion(value="4.5.0") <T,A> CompletableFuture<Result<T,A>> execute(String extension, String operation, Consumer<OperationParameterizer> parameters)
CompletableFuture instance that will complete into a
Result with the corresponding payload and attributes after the operation execution finished.
If the executed operation is not asynchronous in nature, the client might choose to actually execute in a synchronous manner.
T - The generic type of the result's payloadA - The generic type of the result's attributeextension - the name of the extension that contains the operation to be executed.operation - the name of the operation to be executed.parameters - CompletableFuture instance that completes into a Result with the payload content and the
corresponding attributes.@Deprecated <T,A> CompletableFuture<Result<T,A>> executeAsync(String extension, String operation, OperationParameters parameters)
execute(String, String, Consumer) insteadCompletableFuture instance that will complete into a
Result with the corresponding payload and attributes after the operation execution finished.
If the executed operation is not asynchronous in nature, the client might choose to actually execute in a synchronous manner.
extension - the name of the extension that contains the operation to be executed.operation - the name of the operation to be executed.parameters - an OperationParameters instance with all the parameters required to execute the operation.CompletableFuture instance that completes into a Result with the payload content and the
corresponding attributes.@Deprecated <T,A> Result<T,A> execute(String extension, String operation, OperationParameters parameters) throws org.mule.runtime.api.exception.MuleException
execute(String, String, Consumer) insteadResult with the operation's output and attributes if available.
Take in mind that if the executed operation is asynchronous in nature, this method will automatically wait for it to complete before returning the value
extension - the name of the extension that contains the operation to be executed.operation - the name of the operation to be executed.parameters - an OperationParameters instance with all the parameters required to execute the operation.Result instance with the payload content and the corresponding attributes after the operation execution.org.mule.runtime.api.exception.MuleException - if any error occurred while executing the operation.Copyright © 2022 MuleSoft, Inc.. All rights reserved.