use of org.mule.runtime.module.extension.internal.runtime.resolver.ValueResolver 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);
}
}
use of org.mule.runtime.module.extension.internal.runtime.resolver.ValueResolver in project mule by mulesoft.
the class OAuthConnectionProviderObjectBuilder method buildOAuthObjectStoreConfig.
private Optional<OAuthObjectStoreConfig> buildOAuthObjectStoreConfig(CoreEvent event) throws MuleException {
final ValueResolver resolver = resolverSet.getResolvers().get(OAUTH_STORE_CONFIG_GROUP_NAME);
if (resolver == null) {
return empty();
}
Map<String, Object> map = (Map<String, Object>) resolver.resolve(from(event));
return map != null ? of(new OAuthObjectStoreConfig((String) map.get(OBJECT_STORE_PARAMETER_NAME))) : empty();
}
use of org.mule.runtime.module.extension.internal.runtime.resolver.ValueResolver in project mule by mulesoft.
the class MuleExtensionUtils method toMap.
public static Map<String, Object> toMap(ResolverSet resolverSet, CoreEvent event) throws MuleException {
final ValueResolvingContext ctx = from(event);
ImmutableMap.Builder<String, Object> map = ImmutableMap.builder();
for (Entry<String, ValueResolver<?>> entry : resolverSet.getResolvers().entrySet()) {
Object value = entry.getValue().resolve(ctx);
if (value != null) {
map.put(entry.getKey(), value);
}
}
return map.build();
}
use of org.mule.runtime.module.extension.internal.runtime.resolver.ValueResolver in project mule by mulesoft.
the class DefaultObjectBuilderTestCase method getResolver.
private ValueResolver getResolver(Object value, boolean dynamic) throws Exception {
ValueResolver resolver = ExtensionsTestUtils.getResolver(value, resolvingContext, dynamic);
resolvers.add(resolver);
return resolver;
}
use of org.mule.runtime.module.extension.internal.runtime.resolver.ValueResolver in project mule by mulesoft.
the class ExtensionsTestUtils method getResolver.
public static ValueResolver getResolver(Object value, ValueResolvingContext context, boolean dynamic, Class<?>... extraInterfaces) throws Exception {
ValueResolver resolver;
if (isEmpty(extraInterfaces)) {
resolver = mock(ValueResolver.class);
} else {
resolver = mock(ValueResolver.class, withSettings().extraInterfaces(extraInterfaces));
}
when(resolver.resolve(context != null ? same(context) : any(ValueResolvingContext.class))).thenReturn(value);
when(resolver.isDynamic()).thenReturn(dynamic);
return resolver;
}
Aggregations