use of org.mule.runtime.module.extension.internal.runtime.resolver.ValueResolver in project mule by mulesoft.
the class OAuthConnectionProviderObjectBuilder method getCustomParameters.
private Map<String, String> getCustomParameters(CoreEvent event) {
Map<String, String> oauthParams = new HashMap<>();
withCustomParameters((parameter, property) -> {
String alias = property.getRequestAlias();
if (StringUtils.isBlank(alias)) {
alias = parameter.getName();
}
ValueResolver resolver = resolverSet.getResolvers().get(alias);
if (resolver != null) {
try {
oauthParams.put(alias, resolveString(event, resolver));
} catch (MuleException e) {
throw new MuleRuntimeException(e);
}
}
});
return oauthParams;
}
use of org.mule.runtime.module.extension.internal.runtime.resolver.ValueResolver in project mule by mulesoft.
the class OAuthConnectionProviderObjectBuilder method staticOnly.
private MapValueResolver staticOnly(MapValueResolver resolver) throws MuleException {
List<ValueResolver> staticKeyResolvers = new ArrayList<>(resolver.getKeyResolvers().size());
List<ValueResolver> staticValueResolvers = new ArrayList<>(resolver.getValueResolvers().size());
Iterator<ValueResolver> keyResolvers = resolver.getKeyResolvers().iterator();
Iterator<ValueResolver> valueResolvers = resolver.getValueResolvers().iterator();
while (keyResolvers.hasNext() && valueResolvers.hasNext()) {
ValueResolver keyResolver = keyResolvers.next();
ValueResolver valueResolver = valueResolvers.next();
if (!keyResolver.isDynamic() && !valueResolver.isDynamic()) {
staticKeyResolvers.add(keyResolver);
staticValueResolvers.add(valueResolver);
}
}
MapValueResolver result = new MapValueResolver(HashMap.class, staticKeyResolvers, staticValueResolvers, getReflectionCache(), muleContext);
initialiseIfNeeded(result, muleContext);
return result;
}
use of org.mule.runtime.module.extension.internal.runtime.resolver.ValueResolver in project mule by mulesoft.
the class SourceAdapter method getNonCallbackParameterValue.
private <T> Optional<T> getNonCallbackParameterValue(String fieldName, Class<T> type) {
ValueResolver<T> valueResolver = (ValueResolver<T>) nonCallbackParameters.getResolvers().get(fieldName);
if (valueResolver == null) {
return empty();
}
T object;
CoreEvent initialiserEvent = null;
try {
initialiserEvent = getInitialiserEvent(muleContext);
object = valueResolver.resolve(from(initialiserEvent));
} catch (MuleException e) {
throw new MuleRuntimeException(createStaticMessage("Unable to get the " + type.getSimpleName() + " value for Message Source"), e);
} finally {
if (initialiserEvent != null) {
((BaseEventContext) initialiserEvent.getContext()).success();
}
}
if (!(type.isInstance(object))) {
throw new IllegalStateException("The resolved value is not a " + type.getSimpleName());
}
return of(object);
}
Aggregations