Search in sources :

Example 6 with TypeConverterRegistry

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;
}
Also used : TypeConverterRegistry(org.apache.camel.spi.TypeConverterRegistry) XmlConverter(org.apache.camel.converter.jaxp.XmlConverter)

Example 7 with TypeConverterRegistry

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;
}
Also used : TypeConverter(org.apache.camel.TypeConverter) TypeConverterRegistry(org.apache.camel.spi.TypeConverterRegistry) InputStream(java.io.InputStream) FallbackConverter(org.apache.camel.FallbackConverter) Converter(org.apache.camel.Converter) TypeConverter(org.apache.camel.TypeConverter)

Aggregations

TypeConverterRegistry (org.apache.camel.spi.TypeConverterRegistry)7 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Channel (org.apache.camel.Channel)1 Consumer (org.apache.camel.Consumer)1 Converter (org.apache.camel.Converter)1 FallbackConverter (org.apache.camel.FallbackConverter)1 NonManagedService (org.apache.camel.NonManagedService)1 Processor (org.apache.camel.Processor)1 Producer (org.apache.camel.Producer)1 TypeConverter (org.apache.camel.TypeConverter)1 RuntimeCamelCatalog (org.apache.camel.catalog.RuntimeCamelCatalog)1 XmlConverter (org.apache.camel.converter.jaxp.XmlConverter)1 ConsumerCache (org.apache.camel.impl.ConsumerCache)1 DefaultEndpointRegistry (org.apache.camel.impl.DefaultEndpointRegistry)1 DefaultTransformerRegistry (org.apache.camel.impl.DefaultTransformerRegistry)1 DefaultValidatorRegistry (org.apache.camel.impl.DefaultValidatorRegistry)1 ProducerCache (org.apache.camel.impl.ProducerCache)1