Thanks for this information

My route fairly simple actually since I am testing the custom converters:

        <route streamCache="false">
            <from uri="direct:test" />
            <convertBodyTo type="Message" />
            <convertBodyTo type="NotificationType" />
            <bean ref="converter" method="showMsg" />
            <to uri="mock:test" />
        </route>

Message can contains any type of Payload, NotficationType is one of them.
The bean showMsg method simple log the content of the file:

    public NotificationType showMsg(NotificationType msg) {
        System.out.println(msg.xmlText());
        return msg;
    }

The explicit convertion to NotificationType is not necessary since when I
register a converter, it is used automatocally.

The convertion to Message however cannot be deduced automatically.

As I explained, when I used a normal converter this sample works fine :

    @Converter
    private NotificationType toPayload(Message<NotificationType> msg){
        return msg.getPayload();
    }

Since Message can hold ony type of paylaod I would like this method to be
generic, so I tried to use the FallBackconverter like this:

    @FallbackConverter
    public <T> T toPayload(Class<T> type, Exchange exchange, Object value,
TypeConverterRegistry registry){
        if (Message.class.isAssignableFrom(value.getClass())) {
            return ((Message) value).getPayload();
        }
        return null;
    }

I'll try to debug to find the exact source of the problem.
-- 
View this message in context: 
http://camel.465427.n5.nabble.com/Converter-Generics-tp2839250p2840278.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to