ServiceLoader<BarcodableSchema> consumerLoader = ServiceLoader.load(BarcodableSchema.class);
Iterator<BarcodableSchema> consumerIterator = consumerLoader.iterator();
contextMap = new HashMap<String, BarcodableSchema>();
while (consumerIterator.hasNext()) {
BarcodableSchema p = consumerIterator.next();
if (!contextMap.containsKey(p.getName())) {
contextMap.put(p.getName(), p);
}
else {
if (contextMap.get(p.getName()) != p) {
String msg = "Multiple different BarcodableSchemas with the same schema name " +
"('" + p.getName() + "') are present on the classpath. Schema names must be unique.";
log.error(msg);
throw new ServiceConfigurationError(msg);
}
}
}