Search in sources :

Example 1 with OperationMessageProcessor

use of org.mule.runtime.module.extension.internal.runtime.operation.OperationMessageProcessor in project mule by mulesoft.

the class DefaultExtensionsClient method createProcessor.

/**
 * Creates a new {@link OperationMessageProcessor} for the required operation and parses all the parameters passed by the client
 * user.
 */
private OperationMessageProcessor createProcessor(String extensionName, String operationName, OperationParameters parameters) {
    ExtensionModel extension = findExtension(extensionName);
    OperationModel operation = findOperation(extension, operationName);
    ConfigurationProvider config = parameters.getConfigName().map(this::findConfiguration).orElse(null);
    Map<String, ValueResolver> resolvedParams = resolveParameters(parameters.get(), getEvent());
    try {
        OperationMessageProcessor processor = new OperationMessageProcessorBuilder(extension, operation, policyManager, muleContext, registry).setConfigurationProvider(config).setParameters(resolvedParams).build();
        initialiseIfNeeded(processor, muleContext);
        processor.start();
        return processor;
    } catch (Exception e) {
        throw new MuleRuntimeException(createStaticMessage("Could not create Operation Message Processor"), e);
    }
}
Also used : OperationMessageProcessorBuilder(org.mule.runtime.module.extension.internal.runtime.operation.OperationMessageProcessorBuilder) ConfigurationProvider(org.mule.runtime.extension.api.runtime.config.ConfigurationProvider) StaticValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.StaticValueResolver) ValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.ValueResolver) ExpressionValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.ExpressionValueResolver) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) OperationMessageProcessor(org.mule.runtime.module.extension.internal.runtime.operation.OperationMessageProcessor) InitialisationException(org.mule.runtime.api.lifecycle.InitialisationException) MuleException(org.mule.runtime.api.exception.MuleException) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) ExecutionException(java.util.concurrent.ExecutionException) OperationModel(org.mule.runtime.api.meta.model.operation.OperationModel)

Example 2 with OperationMessageProcessor

use of org.mule.runtime.module.extension.internal.runtime.operation.OperationMessageProcessor in project mule by mulesoft.

the class DefaultExtensionsClient method executeAsync.

/**
 * {@inheritDoc}
 */
@Override
public <T, A> CompletableFuture<Result<T, A>> executeAsync(String extension, String operation, OperationParameters parameters) {
    OperationMessageProcessor processor = createProcessor(extension, operation, parameters);
    Mono<Result<T, A>> resultMono = process(processor).map(event -> Result.<T, A>builder(event.getMessage()).build()).onErrorMap(Exceptions::unwrap).doAfterTerminate(() -> disposeProcessor(processor));
    return resultMono.toFuture();
}
Also used : OperationMessageProcessor(org.mule.runtime.module.extension.internal.runtime.operation.OperationMessageProcessor) Result(org.mule.runtime.extension.api.runtime.operation.Result)

Aggregations

OperationMessageProcessor (org.mule.runtime.module.extension.internal.runtime.operation.OperationMessageProcessor)2 ExecutionException (java.util.concurrent.ExecutionException)1 MuleException (org.mule.runtime.api.exception.MuleException)1 MuleRuntimeException (org.mule.runtime.api.exception.MuleRuntimeException)1 InitialisationException (org.mule.runtime.api.lifecycle.InitialisationException)1 ExtensionModel (org.mule.runtime.api.meta.model.ExtensionModel)1 OperationModel (org.mule.runtime.api.meta.model.operation.OperationModel)1 ConfigurationProvider (org.mule.runtime.extension.api.runtime.config.ConfigurationProvider)1 Result (org.mule.runtime.extension.api.runtime.operation.Result)1 OperationMessageProcessorBuilder (org.mule.runtime.module.extension.internal.runtime.operation.OperationMessageProcessorBuilder)1 ExpressionValueResolver (org.mule.runtime.module.extension.internal.runtime.resolver.ExpressionValueResolver)1 StaticValueResolver (org.mule.runtime.module.extension.internal.runtime.resolver.StaticValueResolver)1 ValueResolver (org.mule.runtime.module.extension.internal.runtime.resolver.ValueResolver)1