Converter<?> converter = null;
// let one of the SPI implementations build the converter
Iterator<ConverterProvider> providers = ServiceLoader.load(ConverterProvider.class).iterator();
while (providers.hasNext()) {
ConverterProvider provider = providers.next();
if (targetType != null) {
converter = provider.getByTargetType(targetType);
}
else if (converterType != null) {
converter = provider.getByConverterType(converterType);
}
else {
converter = provider.getByConverterId(converterId);
}
if (converter != null) {
break;
}