use of com.fasterxml.jackson.databind.deser.DeserializerFactory in project flink by apache.
the class AWSUtil method setAwsClientConfigProperties.
/**
* Set all prefixed properties on {@link ClientConfiguration}.
*
* @param config
* @param configProps
*/
public static void setAwsClientConfigProperties(ClientConfiguration config, Properties configProps) {
Map<String, Object> awsConfigProperties = new HashMap<>();
for (Map.Entry<Object, Object> entry : configProps.entrySet()) {
String key = (String) entry.getKey();
if (key.startsWith(AWS_CLIENT_CONFIG_PREFIX)) {
awsConfigProperties.put(key.substring(AWS_CLIENT_CONFIG_PREFIX.length()), entry.getValue());
}
}
// Jackson does not like the following properties
String[] ignorableProperties = { "secureRandom" };
BeanDeserializerModifier modifier = new BeanDeserializerModifierForIgnorables(ClientConfiguration.class, ignorableProperties);
DeserializerFactory factory = BeanDeserializerFactory.instance.withDeserializerModifier(modifier);
ObjectMapper mapper = new ObjectMapper(null, null, new DefaultDeserializationContext.Impl(factory));
JsonNode propTree = mapper.convertValue(awsConfigProperties, JsonNode.class);
try {
mapper.readerForUpdating(config).readValue(propTree);
} catch (IOException ex) {
throw new RuntimeException(ex);
}
}
Aggregations