Search in sources :

Example 1 with ValueProvider

use of org.mule.runtime.extension.api.values.ValueProvider in project mule by mulesoft.

the class ValueProviderFactory method createValueProvider.

ValueProvider createValueProvider() throws ValueResolvingException {
    Class<? extends ValueProvider> resolverClass = factoryModelProperty.getValueProvider();
    try {
        ValueProvider resolver = instantiateClass(resolverClass);
        initialiseIfNeeded(resolver, true, muleContext);
        injectValueProviderFields(resolver);
        if (factoryModelProperty.usesConnection()) {
            injectValueIntoField(resolver, connectionSupplier.get(), connectionField);
        }
        if (factoryModelProperty.usesConfig()) {
            injectValueIntoField(resolver, configurationSupplier.get(), configField);
        }
        return resolver;
    } catch (ValueResolvingException e) {
        throw e;
    } catch (Exception e) {
        throw new ValueResolvingException("An error occurred trying to create a ValueProvider", UNKNOWN, e);
    }
}
Also used : ValueProvider(org.mule.runtime.extension.api.values.ValueProvider) ValueResolvingException(org.mule.runtime.extension.api.values.ValueResolvingException) ValueResolvingException(org.mule.runtime.extension.api.values.ValueResolvingException)

Example 2 with ValueProvider

use of org.mule.runtime.extension.api.values.ValueProvider in project mule by mulesoft.

the class ValueProviderMediator method resolveValues.

private Set<Value> resolveValues(List<ParameterModel> parameters, ValueProviderFactoryModelProperty factoryModelProperty, ParameterValueResolver parameterValueResolver, Supplier<Object> connectionSupplier, Supplier<Object> configurationSupplier) throws NoSuchMethodException, InstantiationException, IllegalAccessException, java.lang.reflect.InvocationTargetException, InitialisationException, org.mule.runtime.module.extension.internal.runtime.ValueResolvingException, ValueResolvingException {
    ValueProvider valueProvider = factoryModelProperty.createFactory(parameterValueResolver, connectionSupplier, configurationSupplier, reflectionCache.get(), muleContext.get()).createValueProvider();
    Set<Value> valueSet = valueProvider.resolve();
    return valueSet.stream().map(option -> cloneAndEnrichValue(option, parameters)).map(ValueBuilder::build).collect(toSet());
}
Also used : ValueProviderUtils.cloneAndEnrichValue(org.mule.runtime.module.extension.internal.value.ValueProviderUtils.cloneAndEnrichValue) Value(org.mule.runtime.api.value.Value) ValueProvider(org.mule.runtime.extension.api.values.ValueProvider)

Aggregations

ValueProvider (org.mule.runtime.extension.api.values.ValueProvider)2 Value (org.mule.runtime.api.value.Value)1 ValueResolvingException (org.mule.runtime.extension.api.values.ValueResolvingException)1 ValueProviderUtils.cloneAndEnrichValue (org.mule.runtime.module.extension.internal.value.ValueProviderUtils.cloneAndEnrichValue)1