public interface ExtensionsClient
ExtensionsClient is a simple common interface for executing extension operations programmatically without the
need of much manual coding and allowing to scale quickly all of this without a the need of compile dependency to
the executed extension.
This API is simple and easy to use, the user just needs to define the extension and the corresponding operation
that want's to invoke and pass a set of named parameters that will be attached when the operation gets executed. This implies
that the user should know the parameter names and types to create them using an OperationParameters instance. The idea
is that different extensions can provide different OperationParameters implementations for key operations.
This client lets the user reference complex configurations defined in the application and also has the capability to resolve expressions.
Note that this client will be reachable through the mule registry and you will be able to inject it in any class with lifecycle.
An usage example for an operation with this signature public String getName(@UseConfig config, int account) could be:
{@code
public class UsingExtensionsClient {| Modifier and Type | Method and Description |
|---|---|
<T,A> Result<T,A> |
execute(String extension,
String operation,
OperationParameters parameters)
Executes an operation synchronously and returns a
Result with the operation's output and attributes if available. |
<T,A> CompletableFuture<Result<T,A>> |
executeAsync(String extension,
String operation,
OperationParameters 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> CompletableFuture<Result<T,A>> executeAsync(String extension, String operation, OperationParameters parameters)
CompletableFuture instance that will complete into a
Result with the corresponding payload and attributes after the operation execution finished.
This is the recommended method to use when the executed operation is non-blocking.
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.<T,A> Result<T,A> execute(String extension, String operation, OperationParameters parameters) throws org.mule.runtime.api.exception.MuleException
Result 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 © 2017 MuleSoft, Inc.. All rights reserved.