use of org.osgi.service.blueprint.container.Converter in project aries by apache.
the class AggregateConverter method convertWithConverters.
private ConversionResult convertWithConverters(Object source, ReifiedType type) throws Exception {
Converter converter = selectMatchingConverter(source, type);
if (converter == null)
return null;
Object value = converter.convert(source, type);
return new ConversionResult(converter, value);
}
use of org.osgi.service.blueprint.container.Converter in project aries by apache.
the class BlueprintContainerImpl method processTypeConverters.
private void processTypeConverters() throws Exception {
List<String> typeConverters = new ArrayList<String>();
for (Target target : componentDefinitionRegistry.getTypeConverters()) {
if (target instanceof ComponentMetadata) {
typeConverters.add(((ComponentMetadata) target).getId());
} else if (target instanceof RefMetadata) {
typeConverters.add(((RefMetadata) target).getComponentId());
} else {
throw new ComponentDefinitionException("Unexpected metadata for type converter: " + target);
}
}
Map<String, Object> objects = repository.createAll(typeConverters, Arrays.<Class<?>>asList(Converter.class));
for (String name : typeConverters) {
Object obj = objects.get(name);
if (obj instanceof Converter) {
converter.registerConverter((Converter) obj);
} else {
throw new ComponentDefinitionException("Type converter " + obj + " does not implement the " + Converter.class.getName() + " interface");
}
}
}
Aggregations