camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Babak Vahdat <>
Subject Re: RestBindingProcessor JSON Data Format Config
Date Mon, 29 Sep 2014 10:33:16 GMT

The "json" and "outJson" variables you mentioned will *not* resolve to the
same Java object (because of Camel Injector being invoked here behind the
scenes while resolving), well almost always ... depending if e.g. an object
under the name "json-jackson" is already bound to the Camel registery which
isn't really typical. The following code snippet should make both cases
clear to you:

        CamelContext context = new DefaultCamelContext();

        DataFormat first = context.resolveDataFormat("json-jackson");
        DataFormat second = context.resolveDataFormat("json-jackson");

        System.out.println(first != second); // true

        JndiRegistry registry = new JndiRegistry();
        registry.bind("json-jackson", new
        ((DefaultCamelContext) context).setRegistry(registry);

        DataFormat third = context.resolveDataFormat("json-jackson");
        DataFormat fourth = context.resolveDataFormat("json-jackson");

        System.out.println(third == fourth); // true

        System.out.println(third != first); // true
        System.out.println(fourth != first); // true

If interested, looking into the different implementations of Camel’s
DataFormatResolver should clarify this to you, specially the
DefaultDataFormatResolver one.


sohrab wrote
> I was just looking through the latest code for
> and I am not quite sure
> how this works so I'd appreciate if someone can explain it to me. 
> createProcessor() method looks up both JSON data formats using the same
> name:
> DataFormat json = context.resolveDataFormat(name);
> DataFormat outJson = context.resolveDataFormat(name);
> And further down, it sets the properties for "json" and then "outJson".
> Now I am wondering if that name resolves to the same DataFormat object
> (especially when you have RestConfiguration.jsonDataFormat set), what
> stops setting "outJson" properties, such as unmarshalType, not overriding
> the properties we just set for "json"?

View this message in context:
Sent from the Camel - Users mailing list archive at

View raw message