You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by Claus Ibsen <cl...@gmail.com> on 2015/12/28 13:28:45 UTC

Re: camel git commit: CAMEL-9268: camel-boon - Serializing/Deserializing Lists, Maps with camel-boon

On Mon, Dec 28, 2015 at 1:16 PM,  <ac...@apache.org> wrote:
> Repository: camel
> Updated Branches:
>   refs/heads/master 3cba6ed05 -> 44c2399ee
>
>
> CAMEL-9268: camel-boon - Serializing/Deserializing Lists, Maps with camel-boon
>
>
> Project: http://git-wip-us.apache.org/repos/asf/camel/repo
> Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/44c2399e
> Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/44c2399e
> Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/44c2399e
>
> Branch: refs/heads/master
> Commit: 44c2399eed3ed49b961671aba16cce58065d64b9
> Parents: 3cba6ed
> Author: Andrea Cosentino <an...@gmail.com>
> Authored: Mon Dec 28 13:14:55 2015 +0100
> Committer: Andrea Cosentino <an...@gmail.com>
> Committed: Mon Dec 28 13:15:22 2015 +0100
>
> ----------------------------------------------------------------------
>  .../camel/model/dataformat/BoonDataFormat.java      | 16 ++++++++++++++++
>  .../apache/camel/component/boon/BoonDataFormat.java |  8 +++++---
>  .../camel/component/boon/BoonDataFormatTest.java    |  2 +-
>  3 files changed, 22 insertions(+), 4 deletions(-)
> ----------------------------------------------------------------------
>
>
> http://git-wip-us.apache.org/repos/asf/camel/blob/44c2399e/camel-core/src/main/java/org/apache/camel/model/dataformat/BoonDataFormat.java
> ----------------------------------------------------------------------
> diff --git a/camel-core/src/main/java/org/apache/camel/model/dataformat/BoonDataFormat.java b/camel-core/src/main/java/org/apache/camel/model/dataformat/BoonDataFormat.java
> index 465d09c..c0a3814 100644
> --- a/camel-core/src/main/java/org/apache/camel/model/dataformat/BoonDataFormat.java
> +++ b/camel-core/src/main/java/org/apache/camel/model/dataformat/BoonDataFormat.java
> @@ -41,6 +41,8 @@ public class BoonDataFormat extends DataFormatDefinition {
>      private String unmarshalTypeName;
>      @XmlTransient
>      private Class<?> unmarshalType;
> +    @XmlTransient
> +    private Boolean useList;
>

It should be a @XmlAttribute because its just a boolean type.

@XmlAttribute
private Boolean useList;

The one above with the Class<?> is special because the
unmarshalTypeName is what you use to configure it when using XML.




>      public BoonDataFormat() {
>          super("boon");
> @@ -72,6 +74,17 @@ public class BoonDataFormat extends DataFormatDefinition {
>      public void setUnmarshalTypeName(String unmarshalTypeName) {
>          this.unmarshalTypeName = unmarshalTypeName;
>      }
> +
> +    public boolean isUseList() {
> +        return useList;
> +    }
> +
> +    /**
> +     * To unarmshal to a List of Map or a List of Pojo.
> +     */
> +    public void setUseList(boolean useList) {
> +        this.useList = useList;
> +    }
>
>      @Override
>      protected DataFormat createDataFormat(RouteContext routeContext) {
> @@ -90,5 +103,8 @@ public class BoonDataFormat extends DataFormatDefinition {
>          if (unmarshalType != null) {
>              setProperty(camelContext, dataFormat, "unmarshalType", unmarshalType);
>          }
> +        if (useList != null) {
> +            setProperty(camelContext, dataFormat, "useList", useList);
> +        }
>      }
>  }
>
> http://git-wip-us.apache.org/repos/asf/camel/blob/44c2399e/components/camel-boon/src/main/java/org/apache/camel/component/boon/BoonDataFormat.java
> ----------------------------------------------------------------------
> diff --git a/components/camel-boon/src/main/java/org/apache/camel/component/boon/BoonDataFormat.java b/components/camel-boon/src/main/java/org/apache/camel/component/boon/BoonDataFormat.java
> index f493b38..b7429f6 100644
> --- a/components/camel-boon/src/main/java/org/apache/camel/component/boon/BoonDataFormat.java
> +++ b/components/camel-boon/src/main/java/org/apache/camel/component/boon/BoonDataFormat.java
> @@ -94,7 +94,9 @@ public class BoonDataFormat extends ChildServiceSupport implements DataFormat, D
>
>      @Override
>      protected void doStart() throws Exception {
> -        // noop
> +        if (useList) {
> +               useList();
> +        }
>      }
>
>      @Override
> @@ -117,11 +119,11 @@ public class BoonDataFormat extends ChildServiceSupport implements DataFormat, D
>          return this.objectMapper;
>      }
>
> -    public boolean isUseList() {
> +    public Boolean getUseList() {
>          return useList;
>      }
>
> -    public void setUseList(boolean useList) {
> +    public void setUseList(Boolean useList) {
>          this.useList = useList;
>      }
>
>
> http://git-wip-us.apache.org/repos/asf/camel/blob/44c2399e/components/camel-boon/src/test/java/org/apache/camel/component/boon/BoonDataFormatTest.java
> ----------------------------------------------------------------------
> diff --git a/components/camel-boon/src/test/java/org/apache/camel/component/boon/BoonDataFormatTest.java b/components/camel-boon/src/test/java/org/apache/camel/component/boon/BoonDataFormatTest.java
> index 302eaab..37269ba 100644
> --- a/components/camel-boon/src/test/java/org/apache/camel/component/boon/BoonDataFormatTest.java
> +++ b/components/camel-boon/src/test/java/org/apache/camel/component/boon/BoonDataFormatTest.java
> @@ -126,7 +126,7 @@ public class BoonDataFormatTest extends CamelTestSupport {
>                  from("direct:backPojo").unmarshal(formatPojo).to("mock:reversePojo");
>
>                  BoonDataFormat formatList = new BoonDataFormat();
> -                formatList.useList();
> +                formatList.setUseList(true);
>
>                  from("direct:inList").marshal(formatList);
>                  from("direct:backList").unmarshal(formatList).to("mock:reverseList");
>



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Re: camel git commit: CAMEL-9268: camel-boon - Serializing/Deserializing Lists, Maps with camel-boon

Posted by Andrea Cosentino <an...@yahoo.com.INVALID>.
It should be ok now.. I hope :-)





On Monday, December 28, 2015 1:29 PM, Claus Ibsen <cl...@gmail.com> wrote:
On Mon, Dec 28, 2015 at 1:16 PM,  <ac...@apache.org> wrote:
> Repository: camel
> Updated Branches:
>   refs/heads/master 3cba6ed05 -> 44c2399ee
>
>
> CAMEL-9268: camel-boon - Serializing/Deserializing Lists, Maps with camel-boon
>
>
> Project: http://git-wip-us.apache.org/repos/asf/camel/repo
> Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/44c2399e
> Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/44c2399e
> Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/44c2399e
>
> Branch: refs/heads/master
> Commit: 44c2399eed3ed49b961671aba16cce58065d64b9
> Parents: 3cba6ed
> Author: Andrea Cosentino <an...@gmail.com>
> Authored: Mon Dec 28 13:14:55 2015 +0100
> Committer: Andrea Cosentino <an...@gmail.com>
> Committed: Mon Dec 28 13:15:22 2015 +0100
>
> ----------------------------------------------------------------------
>  .../camel/model/dataformat/BoonDataFormat.java      | 16 ++++++++++++++++
>  .../apache/camel/component/boon/BoonDataFormat.java |  8 +++++---
>  .../camel/component/boon/BoonDataFormatTest.java    |  2 +-
>  3 files changed, 22 insertions(+), 4 deletions(-)
> ----------------------------------------------------------------------
>
>
> http://git-wip-us.apache.org/repos/asf/camel/blob/44c2399e/camel-core/src/main/java/org/apache/camel/model/dataformat/BoonDataFormat.java
> ----------------------------------------------------------------------
> diff --git a/camel-core/src/main/java/org/apache/camel/model/dataformat/BoonDataFormat.java b/camel-core/src/main/java/org/apache/camel/model/dataformat/BoonDataFormat.java
> index 465d09c..c0a3814 100644
> --- a/camel-core/src/main/java/org/apache/camel/model/dataformat/BoonDataFormat.java
> +++ b/camel-core/src/main/java/org/apache/camel/model/dataformat/BoonDataFormat.java
> @@ -41,6 +41,8 @@ public class BoonDataFormat extends DataFormatDefinition {
>      private String unmarshalTypeName;
>      @XmlTransient
>      private Class<?> unmarshalType;
> +    @XmlTransient
> +    private Boolean useList;
>

It should be a @XmlAttribute because its just a boolean type.

@XmlAttribute
private Boolean useList;

The one above with the Class<?> is special because the
unmarshalTypeName is what you use to configure it when using XML.





>      public BoonDataFormat() {
>          super("boon");
> @@ -72,6 +74,17 @@ public class BoonDataFormat extends DataFormatDefinition {
>      public void setUnmarshalTypeName(String unmarshalTypeName) {
>          this.unmarshalTypeName = unmarshalTypeName;
>      }
> +
> +    public boolean isUseList() {
> +        return useList;
> +    }
> +
> +    /**
> +     * To unarmshal to a List of Map or a List of Pojo.
> +     */
> +    public void setUseList(boolean useList) {
> +        this.useList = useList;
> +    }
>
>      @Override
>      protected DataFormat createDataFormat(RouteContext routeContext) {
> @@ -90,5 +103,8 @@ public class BoonDataFormat extends DataFormatDefinition {
>          if (unmarshalType != null) {
>              setProperty(camelContext, dataFormat, "unmarshalType", unmarshalType);
>          }
> +        if (useList != null) {
> +            setProperty(camelContext, dataFormat, "useList", useList);
> +        }
>      }
>  }
>
> http://git-wip-us.apache.org/repos/asf/camel/blob/44c2399e/components/camel-boon/src/main/java/org/apache/camel/component/boon/BoonDataFormat.java
> ----------------------------------------------------------------------
> diff --git a/components/camel-boon/src/main/java/org/apache/camel/component/boon/BoonDataFormat.java b/components/camel-boon/src/main/java/org/apache/camel/component/boon/BoonDataFormat.java
> index f493b38..b7429f6 100644
> --- a/components/camel-boon/src/main/java/org/apache/camel/component/boon/BoonDataFormat.java
> +++ b/components/camel-boon/src/main/java/org/apache/camel/component/boon/BoonDataFormat.java
> @@ -94,7 +94,9 @@ public class BoonDataFormat extends ChildServiceSupport implements DataFormat, D
>
>      @Override
>      protected void doStart() throws Exception {
> -        // noop
> +        if (useList) {
> +               useList();
> +        }
>      }
>
>      @Override
> @@ -117,11 +119,11 @@ public class BoonDataFormat extends ChildServiceSupport implements DataFormat, D
>          return this.objectMapper;
>      }
>
> -    public boolean isUseList() {
> +    public Boolean getUseList() {
>          return useList;
>      }
>
> -    public void setUseList(boolean useList) {
> +    public void setUseList(Boolean useList) {
>          this.useList = useList;
>      }
>
>
> http://git-wip-us.apache.org/repos/asf/camel/blob/44c2399e/components/camel-boon/src/test/java/org/apache/camel/component/boon/BoonDataFormatTest.java
> ----------------------------------------------------------------------
> diff --git a/components/camel-boon/src/test/java/org/apache/camel/component/boon/BoonDataFormatTest.java b/components/camel-boon/src/test/java/org/apache/camel/component/boon/BoonDataFormatTest.java
> index 302eaab..37269ba 100644
> --- a/components/camel-boon/src/test/java/org/apache/camel/component/boon/BoonDataFormatTest.java
> +++ b/components/camel-boon/src/test/java/org/apache/camel/component/boon/BoonDataFormatTest.java
> @@ -126,7 +126,7 @@ public class BoonDataFormatTest extends CamelTestSupport {
>                  from("direct:backPojo").unmarshal(formatPojo).to("mock:reversePojo");
>
>                  BoonDataFormat formatList = new BoonDataFormat();
> -                formatList.useList();
> +                formatList.setUseList(true);
>
>                  from("direct:inList").marshal(formatList);
>                  from("direct:backList").unmarshal(formatList).to("mock:reverseList");
>



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2