camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: git commit: CAMEL-7858 Allow to disable Jaxb annotations in JacksonDataFormat
Date Thu, 25 Sep 2014 08:52:26 GMT
Even so it should be possible to configure this from XML also.

Unfortuntanately the json data format is generic, but should have been
jackson data format etc. But we are kinda stuck on this for 2.x.
There is other options already that may only apply to jackson and not
xstream etc. For example jsonView etc.
http://camel.apache.org/json.html

So please add this option in the model so users with xml can configure
it too. We must have 100% 1:1 between java and xml for Camel.

On Thu, Sep 25, 2014 at 4:29 AM, Willem Jiang <willem.jiang@gmail.com> wrote:
> Hi Claus,
>
> I checked the module class JsonDataFormat. As it just provide common option settings
for json-xstream, json-jackson and json-gson, I’m afraid I cannot add enableJaxbAnnotation
option there.
>
>
> --
> Willem Jiang
>
> Red Hat, Inc.
> Web: http://www.redhat.com
> Blog: http://willemjiang.blogspot.com (English)
> http://jnn.iteye.com (Chinese)
> Twitter: willemjiang
> Weibo: 姜宁willem
>
>
>
> On September 24, 2014 at 5:11:28 PM, Claus Ibsen (claus.ibsen@gmail.com) wrote:
>> Hi
>>
>> You need to set a new option as well in the model class, so people can
>> configure it from xml dsl tool.
>>
>> On Wed, Sep 24, 2014 at 11:02 AM, wrote:
>> > Repository: camel
>> > Updated Branches:
>> > refs/heads/master 46ef7cd52 -> cff3b1174
>> >
>> >
>> > CAMEL-7858 Allow to disable Jaxb annotations in JacksonDataFormat
>> >
>> >
>> > Project: http://git-wip-us.apache.org/repos/asf/camel/repo
>> > Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/cff3b117
>> > Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/cff3b117
>> > Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/cff3b117
>> >
>> > Branch: refs/heads/master
>> > Commit: cff3b11749b45ea19c281b73df90c819936fa6b9
>> > Parents: 46ef7cd
>> > Author: Willem Jiang
>> > Authored: Wed Sep 24 17:01:40 2014 +0800
>> > Committer: Willem Jiang
>> > Committed: Wed Sep 24 17:02:02 2014 +0800
>> >
>> > ----------------------------------------------------------------------
>> > .../component/jackson/JacksonDataFormat.java | 21 +++++++++++++++++---
>> > .../jackson/ListJacksonDataFormat.java | 5 +++++
>> > 2 files changed, 23 insertions(+), 3 deletions(-)
>> > ----------------------------------------------------------------------
>> >
>> >
>> > http://git-wip-us.apache.org/repos/asf/camel/blob/cff3b117/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/JacksonDataFormat.java
>> > ----------------------------------------------------------------------
>> > diff --git a/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/JacksonDataFormat.java
>> b/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/JacksonDataFormat.java
>> > index fd50ca6..e567047 100644
>> > --- a/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/JacksonDataFormat.java
>> > +++ b/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/JacksonDataFormat.java
>> > @@ -73,13 +73,28 @@ public class JacksonDataFormat extends ServiceSupport implements
>> DataFormat {
>> > * See also http://wiki.fasterxml.com/JacksonJsonViews
>> > */
>> > public JacksonDataFormat(Class unmarshalType, Class jsonView) {
>> > + this(unmarshalType, jsonView, true);
>> > + }
>> > +
>> > + /**
>> > + * Use the default Jackson {@link ObjectMapper} and with a custom
>> > + * unmarshal type and JSON view
>> > + *
>> > + * @param unmarshalType the custom unmarshal type
>> > + * @param jsonView marker class to specify properties to be included during
marshalling.
>> > + * See also http://wiki.fasterxml.com/JacksonJsonViews
>> > + * @param enableJaxbAnnotationModule if it is true, will enable the JaxbAnnotationModule.
>> > + */
>> > + public JacksonDataFormat(Class unmarshalType, Class jsonView, boolean
>> enableJaxbAnnotationModule) {
>> > this.objectMapper = new ObjectMapper();
>> > this.unmarshalType = unmarshalType;
>> > this.jsonView = jsonView;
>> >
>> > - // Enables JAXB processing
>> > - JaxbAnnotationModule module = new JaxbAnnotationModule();
>> > - this.objectMapper.registerModule(module);
>> > + if (enableJaxbAnnotationModule) {
>> > + // Enables JAXB processing
>> > + JaxbAnnotationModule module = new JaxbAnnotationModule();
>> > + this.objectMapper.registerModule(module);
>> > + }
>> > }
>> >
>> > /**
>> >
>> > http://git-wip-us.apache.org/repos/asf/camel/blob/cff3b117/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/ListJacksonDataFormat.java
>> > ----------------------------------------------------------------------
>> > diff --git a/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/ListJacksonDataFormat.java
>> b/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/ListJacksonDataFormat.java
>> > index cfe78a0..f7ab2ec 100644
>> > --- a/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/ListJacksonDataFormat.java
>> > +++ b/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/ListJacksonDataFormat.java
>> > @@ -36,6 +36,11 @@ public class ListJacksonDataFormat extends JacksonDataFormat
>> {
>> > super(unmarshalType, jsonView);
>> > useList();
>> > }
>> > +
>> > + public ListJacksonDataFormat(Class unmarshalType, Class jsonView, boolean
>> enableJaxbAnnotationModule) {
>> > + super(unmarshalType, jsonView, enableJaxbAnnotationModule);
>> > + useList();
>> > + }
>> >
>> > public ListJacksonDataFormat(ObjectMapper mapper, Class unmarshalType) {
>> > super(mapper, unmarshalType);
>> >
>>
>>
>>
>> --
>> Claus Ibsen
>> -----------------
>> Red Hat, Inc.
>> Email: cibsen@redhat.com
>> Twitter: davsclaus
>> Blog: http://davsclaus.com
>> Author of Camel in Action: http://www.manning.com/ibsen
>> hawtio: http://hawt.io/
>> fabric8: http://fabric8.io/
>>
>



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Mime
View raw message