use of org.apache.camel.spi.TypeConverterRegistry in project camel by apache.
the class ModelHelper method newXmlConverter.
/**
* Creates a new {@link XmlConverter}
*
* @param context CamelContext if provided
* @return a new XmlConverter instance
*/
private static XmlConverter newXmlConverter(CamelContext context) {
XmlConverter xmlConverter;
if (context != null) {
TypeConverterRegistry registry = context.getTypeConverterRegistry();
xmlConverter = registry.getInjector().newInstance(XmlConverter.class);
} else {
xmlConverter = new XmlConverter();
}
return xmlConverter;
}
use of org.apache.camel.spi.TypeConverterRegistry in project camel by apache.
the class CxfConverter method toInputStream.
@Converter
public static InputStream toInputStream(Response response, Exchange exchange) {
Object obj = response.getEntity();
if (obj == null) {
return null;
}
if (obj instanceof InputStream) {
// short circuit the lookup
return (InputStream) obj;
}
TypeConverterRegistry registry = exchange.getContext().getTypeConverterRegistry();
TypeConverter tc = registry.lookup(InputStream.class, obj.getClass());
if (tc != null) {
return tc.convertTo(InputStream.class, exchange, obj);
}
return null;
}
Aggregations