camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject camel git commit: CAMEL-7808: Add boon data format to the dsl and polished
Date Sun, 15 Mar 2015 10:06:27 GMT
Repository: camel
Updated Branches:
  refs/heads/master 7852d9906 -> 5ce5a5441


CAMEL-7808: Add boon data format to the dsl and polished


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/5ce5a544
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/5ce5a544
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/5ce5a544

Branch: refs/heads/master
Commit: 5ce5a54417908428ed710b7f5b68756ab7259168
Parents: 7852d99
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Sun Mar 15 11:08:08 2015 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Sun Mar 15 11:08:08 2015 +0100

----------------------------------------------------------------------
 .../apache/camel/builder/DataFormatClause.java  | 12 +++++++
 .../apache/camel/model/MarshalDefinition.java   |  2 ++
 .../apache/camel/model/UnmarshalDefinition.java |  2 ++
 .../camel/model/dataformat/BoonDataFormat.java  | 36 ++++++++++++++++++--
 .../model/dataformat/DataFormatsDefinition.java |  1 +
 5 files changed, 50 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/5ce5a544/camel-core/src/main/java/org/apache/camel/builder/DataFormatClause.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/builder/DataFormatClause.java b/camel-core/src/main/java/org/apache/camel/builder/DataFormatClause.java
index 17ff247..48757d1 100644
--- a/camel-core/src/main/java/org/apache/camel/builder/DataFormatClause.java
+++ b/camel-core/src/main/java/org/apache/camel/builder/DataFormatClause.java
@@ -19,6 +19,7 @@ package org.apache.camel.builder;
 import java.util.Map;
 import java.util.zip.Deflater;
 
+import org.apache.camel.model.dataformat.BoonDataFormat;
 import org.w3c.dom.Node;
 
 import org.apache.camel.model.DataFormatDefinition;
@@ -175,6 +176,17 @@ public class DataFormatClause<T extends ProcessorDefinition<?>>
{
     }
 
     /**
+     * Uses the Boon data format
+     *
+     * @param classType the POJO class type
+     */
+    public T boon(Class<?> classType) {
+        BoonDataFormat boon = new BoonDataFormat();
+        boon.setUnmarshalType(classType);
+        return dataFormat(boon);
+    }
+
+    /**
      * Uses the CSV data format
      */
     public T csv() {

http://git-wip-us.apache.org/repos/asf/camel/blob/5ce5a544/camel-core/src/main/java/org/apache/camel/model/MarshalDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/MarshalDefinition.java b/camel-core/src/main/java/org/apache/camel/model/MarshalDefinition.java
index 2e5e721..ddd53a4 100644
--- a/camel-core/src/main/java/org/apache/camel/model/MarshalDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/MarshalDefinition.java
@@ -28,6 +28,7 @@ import org.apache.camel.model.dataformat.AvroDataFormat;
 import org.apache.camel.model.dataformat.Base64DataFormat;
 import org.apache.camel.model.dataformat.BeanioDataFormat;
 import org.apache.camel.model.dataformat.BindyDataFormat;
+import org.apache.camel.model.dataformat.BoonDataFormat;
 import org.apache.camel.model.dataformat.CastorDataFormat;
 import org.apache.camel.model.dataformat.CryptoDataFormat;
 import org.apache.camel.model.dataformat.CsvDataFormat;
@@ -80,6 +81,7 @@ public class MarshalDefinition extends NoOutputDefinition<MarshalDefinition>
{
     @XmlElement(required = false, name = "base64", type = Base64DataFormat.class),
     @XmlElement(required = false, name = "beanio", type = BeanioDataFormat.class),
     @XmlElement(required = false, name = "bindy", type = BindyDataFormat.class),
+    @XmlElement(required = false, name = "boon", type = BoonDataFormat.class),
     @XmlElement(required = false, name = "castor", type = CastorDataFormat.class),
     @XmlElement(required = false, name = "crypto", type = CryptoDataFormat.class),
     @XmlElement(required = false, name = "csv", type = CsvDataFormat.class),

http://git-wip-us.apache.org/repos/asf/camel/blob/5ce5a544/camel-core/src/main/java/org/apache/camel/model/UnmarshalDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/UnmarshalDefinition.java b/camel-core/src/main/java/org/apache/camel/model/UnmarshalDefinition.java
index b9c9a64..de2684f 100644
--- a/camel-core/src/main/java/org/apache/camel/model/UnmarshalDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/UnmarshalDefinition.java
@@ -28,6 +28,7 @@ import org.apache.camel.model.dataformat.AvroDataFormat;
 import org.apache.camel.model.dataformat.Base64DataFormat;
 import org.apache.camel.model.dataformat.BeanioDataFormat;
 import org.apache.camel.model.dataformat.BindyDataFormat;
+import org.apache.camel.model.dataformat.BoonDataFormat;
 import org.apache.camel.model.dataformat.CastorDataFormat;
 import org.apache.camel.model.dataformat.CryptoDataFormat;
 import org.apache.camel.model.dataformat.CsvDataFormat;
@@ -80,6 +81,7 @@ public class UnmarshalDefinition extends NoOutputDefinition<UnmarshalDefinition>
     @XmlElement(required = false, name = "base64", type = Base64DataFormat.class),
     @XmlElement(required = false, name = "beanio", type = BeanioDataFormat.class),
     @XmlElement(required = false, name = "bindy", type = BindyDataFormat.class),
+    @XmlElement(required = false, name = "boon", type = BoonDataFormat.class),
     @XmlElement(required = false, name = "castor", type = CastorDataFormat.class),
     @XmlElement(required = false, name = "crypto", type = CryptoDataFormat.class),
     @XmlElement(required = false, name = "csv", type = CsvDataFormat.class),

http://git-wip-us.apache.org/repos/asf/camel/blob/5ce5a544/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 a1ba363..38e5d75 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
@@ -20,11 +20,14 @@ import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlAttribute;
 import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.model.DataFormatDefinition;
 import org.apache.camel.spi.DataFormat;
 import org.apache.camel.spi.Metadata;
+import org.apache.camel.spi.RouteContext;
+import org.apache.camel.util.ObjectHelper;
 
 /**
  * Boon data format
@@ -35,6 +38,8 @@ import org.apache.camel.spi.Metadata;
 public class BoonDataFormat extends DataFormatDefinition {
 
     @XmlAttribute(required = true)
+    private String unmarshalTypeName;
+    @XmlTransient
     private Class<?> unmarshalType;
 
     public BoonDataFormat() {
@@ -50,15 +55,40 @@ public class BoonDataFormat extends DataFormatDefinition {
         return unmarshalType;
     }
 
+    /**
+     * Class name of the java type to use when unarmshalling
+     */
     public void setUnmarshalType(Class<?> unmarshalType) {
         this.unmarshalType = unmarshalType;
     }
 
+    public String getUnmarshalTypeName() {
+        return unmarshalTypeName;
+    }
+
+    /**
+     * Class name of the java type to use when unarmshalling
+     */
+    public void setUnmarshalTypeName(String unmarshalTypeName) {
+        this.unmarshalTypeName = unmarshalTypeName;
+    }
+
+    @Override
+    protected DataFormat createDataFormat(RouteContext routeContext) {
+        if (unmarshalType == null && unmarshalTypeName != null) {
+            try {
+                unmarshalType = routeContext.getCamelContext().getClassResolver().resolveMandatoryClass(unmarshalTypeName);
+            } catch (ClassNotFoundException e) {
+                throw ObjectHelper.wrapRuntimeCamelException(e);
+            }
+        }
+        return super.createDataFormat(routeContext);
+    }
+
     @Override
     protected void configureDataFormat(DataFormat dataFormat, CamelContext camelContext)
{
-        Class<?> answer = getUnmarshalType();
-        if (answer != null) {
-            setProperty(camelContext, dataFormat, "unmarshalType", answer);
+        if (unmarshalType != null) {
+            setProperty(camelContext, dataFormat, "unmarshalType", unmarshalType);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/5ce5a544/camel-core/src/main/java/org/apache/camel/model/dataformat/DataFormatsDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/dataformat/DataFormatsDefinition.java
b/camel-core/src/main/java/org/apache/camel/model/dataformat/DataFormatsDefinition.java
index bb53675..bb9b386 100644
--- a/camel-core/src/main/java/org/apache/camel/model/dataformat/DataFormatsDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/dataformat/DataFormatsDefinition.java
@@ -43,6 +43,7 @@ public class DataFormatsDefinition {
         @XmlElement(required = false, name = "base64", type = Base64DataFormat.class),
         @XmlElement(required = false, name = "beanio", type = BeanioDataFormat.class),
         @XmlElement(required = false, name = "bindy", type = BindyDataFormat.class),
+        @XmlElement(required = false, name = "boon", type = BoonDataFormat.class),
         @XmlElement(required = false, name = "castor", type = CastorDataFormat.class),
         @XmlElement(required = false, name = "crypto", type = CryptoDataFormat.class),
         @XmlElement(required = false, name = "csv", type = CsvDataFormat.class),


Mime
View raw message