camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject [3/3] git commit: CAMEL-7375 Added barcode data format with thanks to Claus
Date Wed, 28 May 2014 02:55:27 GMT
CAMEL-7375 Added barcode data format with thanks to Claus


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

Branch: refs/heads/master
Commit: ec85a040dbe8f1b10705794a672464098cb6a4ed
Parents: fbcbb24
Author: Willem Jiang <willem.jiang@gmail.com>
Authored: Wed May 28 10:54:21 2014 +0800
Committer: Willem Jiang <willem.jiang@gmail.com>
Committed: Wed May 28 10:55:01 2014 +0800

----------------------------------------------------------------------
 apache-camel/pom.xml                            |   4 +
 .../src/main/descriptors/common-bin.xml         |   1 +
 components/camel-barcode/pom.xml                |  71 ++++
 .../camel/dataformat/barcode/Barcode.java       |  30 ++
 .../dataformat/barcode/BarcodeDataFormat.java   | 353 +++++++++++++++++++
 .../dataformat/barcode/BarcodeImageType.java    |  40 +++
 .../dataformat/barcode/BarcodeParameters.java   | 149 ++++++++
 .../src/main/resources/META-INF/LICENSE.txt     | 203 +++++++++++
 .../src/main/resources/META-INF/NOTICE.txt      |  11 +
 .../org/apache/camel/dataformat/barcode         |  18 +
 .../barcode/BarcodeDataFormatCamelTest.java     | 174 +++++++++
 .../barcode/BarcodeDataFormatTest.java          | 237 +++++++++++++
 .../dataformat/barcode/BarcodeTestBase.java     |  71 ++++
 .../src/test/resources/log4j.properties         |  14 +
 components/pom.xml                              |   2 +-
 parent/pom.xml                                  |   6 +
 .../features/src/main/resources/features.xml    |   6 +
 17 files changed, 1389 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/ec85a040/apache-camel/pom.xml
----------------------------------------------------------------------
diff --git a/apache-camel/pom.xml b/apache-camel/pom.xml
index 17b0847..c157d3a 100644
--- a/apache-camel/pom.xml
+++ b/apache-camel/pom.xml
@@ -101,6 +101,10 @@
     </dependency>
     <dependency>
       <groupId>org.apache.camel</groupId>
+      <artifactId>camel-barcode</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
       <artifactId>camel-bindy</artifactId>
     </dependency>
     <dependency>

http://git-wip-us.apache.org/repos/asf/camel/blob/ec85a040/apache-camel/src/main/descriptors/common-bin.xml
----------------------------------------------------------------------
diff --git a/apache-camel/src/main/descriptors/common-bin.xml b/apache-camel/src/main/descriptors/common-bin.xml
index a4c7470..e15e9e9 100644
--- a/apache-camel/src/main/descriptors/common-bin.xml
+++ b/apache-camel/src/main/descriptors/common-bin.xml
@@ -33,6 +33,7 @@
         <include>org.apache.camel:camel-aws</include>
         <include>org.apache.camel:camel-avro</include>
         <include>org.apache.camel:camel-bam</include>
+        <include>org.apache.camel:camel-barcode</include>
         <include>org.apache.camel:camel-base64</include>
         <include>org.apache.camel:camel-beanio</include>
         <include>org.apache.camel:camel-bean-validator</include>

http://git-wip-us.apache.org/repos/asf/camel/blob/ec85a040/components/camel-barcode/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-barcode/pom.xml b/components/camel-barcode/pom.xml
new file mode 100644
index 0000000..4f90964
--- /dev/null
+++ b/components/camel-barcode/pom.xml
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+  
+    <parent>
+        <groupId>org.apache.camel</groupId>
+        <artifactId>components</artifactId>
+        <version>2.14-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>camel-barcode</artifactId>
+    <packaging>bundle</packaging>
+    <name>Camel :: Barcode</name>
+    <description>Camel Barcode (e.g. QRcode, PDF417, DataMatrix) support</description>
+
+    <properties>
+        <camel.osgi.export.pkg>org.apache.camel.dataformat.barcode.*</camel.osgi.export.pkg>
+        <camel.osgi.export.service>org.apache.camel.spi.DataFormatResolver;dataformat=barcode</camel.osgi.export.service>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.google.zxing</groupId>
+            <artifactId>core</artifactId>
+            <version>${zxing-version}</version>
+        </dependency>
+        <dependency>
+            <groupId>com.google.zxing</groupId>
+            <artifactId>javase</artifactId>
+            <version>${zxing-version}</version>
+        </dependency>
+
+        <!-- testing -->
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-test-spring</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+</project>

http://git-wip-us.apache.org/repos/asf/camel/blob/ec85a040/components/camel-barcode/src/main/java/org/apache/camel/dataformat/barcode/Barcode.java
----------------------------------------------------------------------
diff --git a/components/camel-barcode/src/main/java/org/apache/camel/dataformat/barcode/Barcode.java b/components/camel-barcode/src/main/java/org/apache/camel/dataformat/barcode/Barcode.java
new file mode 100644
index 0000000..bfed672
--- /dev/null
+++ b/components/camel-barcode/src/main/java/org/apache/camel/dataformat/barcode/Barcode.java
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.dataformat.barcode;
+
+/**
+ * Header variables for the barcode data format.
+ * @author claus.straube
+ */
+public interface Barcode {
+    
+    /**
+     * Format of the barcode (please use {@link BarcodeFormat}).
+     */
+    String BARCODE_FORMAT = "BarcodeFormat";  
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ec85a040/components/camel-barcode/src/main/java/org/apache/camel/dataformat/barcode/BarcodeDataFormat.java
----------------------------------------------------------------------
diff --git a/components/camel-barcode/src/main/java/org/apache/camel/dataformat/barcode/BarcodeDataFormat.java b/components/camel-barcode/src/main/java/org/apache/camel/dataformat/barcode/BarcodeDataFormat.java
new file mode 100644
index 0000000..c41e411
--- /dev/null
+++ b/components/camel-barcode/src/main/java/org/apache/camel/dataformat/barcode/BarcodeDataFormat.java
@@ -0,0 +1,353 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.dataformat.barcode;
+
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+import java.util.EnumMap;
+import java.util.Map;
+
+import javax.imageio.ImageIO;
+
+import com.google.zxing.BarcodeFormat;
+import com.google.zxing.BinaryBitmap;
+import com.google.zxing.DecodeHintType;
+import com.google.zxing.EncodeHintType;
+import com.google.zxing.MultiFormatReader;
+import com.google.zxing.MultiFormatWriter;
+import com.google.zxing.Result;
+import com.google.zxing.WriterException;
+import com.google.zxing.client.j2se.BufferedImageLuminanceSource;
+import com.google.zxing.client.j2se.MatrixToImageWriter;
+import com.google.zxing.common.BitMatrix;
+import com.google.zxing.common.HybridBinarizer;
+import com.google.zxing.datamatrix.encoder.SymbolShapeHint;
+import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.NoTypeConversionAvailableException;
+import org.apache.camel.TypeConversionException;
+import org.apache.camel.spi.DataFormat;
+import org.apache.camel.util.ExchangeHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * {@link DataFormat} to create (encode) and 
+ * read (decode) barcodes. For more info about
+ * the available barcodes have a look at:<br/><br/>
+ * 
+ * https://github.com/zxing/zxing
+ * 
+ * @author claus.straube
+ */
+public class BarcodeDataFormat implements DataFormat {
+
+    /**
+     * Logger.
+     */
+    private static final Logger LOG = LoggerFactory.getLogger(BarcodeDataFormat.class);
+    
+    /**
+     * The bean for the default parameters.
+     */
+    private BarcodeParameters params;
+    
+    /**
+     * The encoding hint map, used for writing a barcode.
+     */
+    private final Map<EncodeHintType, Object> writerHintMap = 
+            new EnumMap<EncodeHintType, Object>(EncodeHintType.class);
+    
+    /**
+     * The decoding hint map, used for reading a barcode.
+     */
+    private final Map<DecodeHintType, Object> readerHintMap = 
+            new EnumMap<DecodeHintType, Object>(DecodeHintType.class);
+            
+
+    /**
+     * Create instance with default parameters.
+     */
+    public BarcodeDataFormat() {
+        this.setDefaultParameters();
+        this.optimizeHints();
+    }
+    
+    /**
+     * Create instance with custom {@link BarcodeFormat}. The other 
+     * values are default.
+     * 
+     * @param format the barcode format
+     */
+    public BarcodeDataFormat(final BarcodeFormat format) {
+        this.setDefaultParameters();
+        this.params.setFormat(format);
+        this.optimizeHints();
+    }
+
+    /**
+     * Create instance with custom height and width. The other 
+     * values are default.
+     * 
+     * @param height the image height
+     * @param width the image width
+     */
+    public BarcodeDataFormat(final int width, final int height) {
+        this.setDefaultParameters();
+        this.params.setHeight(height);
+        this.params.setWidth(width);
+        this.optimizeHints();
+    }
+
+    /**
+     * Create instance with custom {@link BarcodeImageType}. The other 
+     * values are default.
+     * 
+     * @param type the type (format) of the image. e.g. PNG
+     */
+    public BarcodeDataFormat(final BarcodeImageType type) {
+        this.setDefaultParameters();
+        this.params.setType(type);
+        this.optimizeHints();
+    }
+    
+    /**
+     * Create instance with custom height, width and image type. The other 
+     * values are default.
+     * 
+     * @param height the image height
+     * @param width the image width
+     * @param type the type (format) of the image. e.g. PNG
+     * @param format the barcode format
+     */
+    public BarcodeDataFormat(final int width, final int height
+            , final BarcodeImageType type, final BarcodeFormat format) {
+        this.setDefaultParameters();
+        this.params.setHeight(height);
+        this.params.setWidth(width);
+        this.params.setType(type);
+        this.params.setFormat(format);
+        this.optimizeHints();
+    }
+    
+    /**
+     * Marshall a {@link String} payload to a code image.
+     * 
+     * @param exchange
+     * @param graph
+     * @param stream
+     * @throws Exception 
+     */
+    @Override
+    public void marshal(final Exchange exchange, final Object graph
+            , final OutputStream stream) throws Exception {
+        this.printImage(exchange, graph, stream);
+    }
+
+    /**
+     * Unmarshall a code image to a {@link String} payload.
+     * 
+     * @param exchange
+     * @param stream
+     * @return
+     * @throws Exception 
+     */
+    @Override
+    public Object unmarshal(final Exchange exchange, final InputStream stream) throws Exception {
+        return this.readImage(exchange, stream);
+    }
+    
+    /**
+     * Sets the default parameters.
+     */
+    protected final void setDefaultParameters() {
+        this.params = new BarcodeParameters();
+    }
+    
+    /**
+     * Sets hints optimized for different barcode types.
+     */
+    protected final void optimizeHints() {
+        // writer hints
+        this.writerHintMap
+                .put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
+        
+        if (this.params.getFormat().toString()
+                .equals(BarcodeFormat.DATA_MATRIX.toString())) {
+            this.writerHintMap
+                    .put(EncodeHintType.DATA_MATRIX_SHAPE
+                            , SymbolShapeHint.FORCE_SQUARE);
+        }
+        
+        // reader hints
+        this.readerHintMap.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);
+    }
+    
+    /**
+     * Writes the image file to the output stream.
+     * 
+     * @param graph the object graph
+     * @param exchange the camel exchange
+     * @param stream the output stream
+     * @throws WriterException
+     * @throws UnsupportedEncodingException
+     * @throws IOException 
+     * @throws org.apache.camel.NoTypeConversionAvailableException 
+     */
+    private void printImage(final Exchange exchange, final Object graph, final OutputStream stream)
+        throws WriterException, UnsupportedEncodingException, IOException, TypeConversionException,
+        NoTypeConversionAvailableException {
+         
+        final String payload = ExchangeHelper
+                .convertToMandatoryType(exchange, String.class, graph);
+        final MultiFormatWriter writer = new MultiFormatWriter();
+
+        // set values
+        final String type = this.params.getType().toString();
+        final String encoding = this.params.getEncoding(); 
+        
+        // create code image  
+        final BitMatrix matrix = writer.encode(
+                new String(payload.getBytes(encoding), encoding),
+                this.params.getFormat(), 
+                this.params.getWidth(), 
+                this.params.getHeight(), 
+                writerHintMap);
+        
+        // write image back to stream
+        MatrixToImageWriter.writeToStream(matrix, type, stream);
+    }
+    
+    /**
+     * Reads the message from a code.
+     * 
+     * @param exchange
+     * @param stream
+     * @return
+     * @throws Exception
+     */
+    private String readImage(final Exchange exchange, final InputStream stream)
+        throws Exception {
+        final MultiFormatReader reader = new MultiFormatReader();
+        final BufferedInputStream in = exchange.getContext()
+                .getTypeConverter()
+                .mandatoryConvertTo(BufferedInputStream.class, stream);
+        final BinaryBitmap bitmap = new BinaryBitmap(
+                new HybridBinarizer(
+                        new BufferedImageLuminanceSource(ImageIO.read(in))));
+        final Result result = reader.decode(bitmap, readerHintMap);
+        
+        // write the found barcode format into the header
+        exchange.getOut()
+                .setHeader(Barcode.BARCODE_FORMAT, result.getBarcodeFormat());
+        
+        return result.getText();
+    }
+    
+    /**
+     * Adds a new hint value to writer (encode) hint map.
+     * 
+     * @param hintType
+     * @param value 
+     */
+    public final void addToHintMap(final EncodeHintType hintType
+            , final Object value) {
+        this.writerHintMap.put(hintType, value);
+        LOG.info(
+                String.format("Added '%s' with value '%s' to writer hint map."
+                        , hintType.toString(), value.toString()));
+    }
+    
+    /**
+     * Adds a new hint value to reader (decode) hint map.
+     * 
+     * @param hintType
+     * @param value 
+     */
+    public final void addToHintMap(final DecodeHintType hintType
+            , final Object value) {
+        this.readerHintMap.put(hintType, value);
+    }
+    
+    /**
+     * Removes a hint from writer (encode) hint map.
+     * 
+     * @param hintType 
+     */
+    public final void removeFromHintMap(final EncodeHintType hintType) {
+        if (this.writerHintMap.containsKey(hintType)) {
+            this.writerHintMap.remove(hintType);
+            LOG.info(
+                    String.format("Removed '%s' from writer hint map."
+                            , hintType.toString()));
+        } else {
+            LOG.warn(
+                    String.format("Could not find encode hint type '%s' in "
+                            + "writer hint map.", hintType.toString()));
+        }
+    }
+    
+    /**
+     * Removes a hint from reader (decode) hint map.
+     * 
+     * @param hintType 
+     */
+    public final void removeFromHintMap(final DecodeHintType hintType) {
+        if (this.readerHintMap.containsKey(hintType)) {
+            this.readerHintMap.remove(hintType);
+            LOG.info(
+                    String.format("Removed '%s' from reader hint map."
+                            , hintType.toString()));
+        } else {
+            LOG.warn(
+                    String.format("Could not find decode hint type '%s' in"
+                            + " reader hint map.", hintType.toString()));
+        }
+    }
+
+    /**
+     * The (default) parameters.
+     * 
+     * @return 
+     */
+    public final BarcodeParameters getParams() {
+        return params;
+    }
+
+    /**
+     * The writer (encode) hint map.
+     * 
+     * @return 
+     */
+    public final Map<EncodeHintType, Object> getWriterHintMap() {
+        return writerHintMap;
+    }
+
+    /**
+     * The reader (decode) hint map.
+     * 
+     * @return 
+     */
+    public final Map<DecodeHintType, Object> getReaderHintMap() {
+        return readerHintMap;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ec85a040/components/camel-barcode/src/main/java/org/apache/camel/dataformat/barcode/BarcodeImageType.java
----------------------------------------------------------------------
diff --git a/components/camel-barcode/src/main/java/org/apache/camel/dataformat/barcode/BarcodeImageType.java b/components/camel-barcode/src/main/java/org/apache/camel/dataformat/barcode/BarcodeImageType.java
new file mode 100644
index 0000000..50031c0
--- /dev/null
+++ b/components/camel-barcode/src/main/java/org/apache/camel/dataformat/barcode/BarcodeImageType.java
@@ -0,0 +1,40 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.dataformat.barcode;
+
+/**
+ * Endings for the supported image types.
+ * 
+ * @author claus
+ */
+public enum BarcodeImageType {
+    /**
+     * JPEG image.
+     */
+    JPG
+    
+    /**
+     * GIF image.
+     */
+    , GIF
+    
+    /**
+     * PNG image.
+     */
+    , PNG
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ec85a040/components/camel-barcode/src/main/java/org/apache/camel/dataformat/barcode/BarcodeParameters.java
----------------------------------------------------------------------
diff --git a/components/camel-barcode/src/main/java/org/apache/camel/dataformat/barcode/BarcodeParameters.java b/components/camel-barcode/src/main/java/org/apache/camel/dataformat/barcode/BarcodeParameters.java
new file mode 100644
index 0000000..b1197f0
--- /dev/null
+++ b/components/camel-barcode/src/main/java/org/apache/camel/dataformat/barcode/BarcodeParameters.java
@@ -0,0 +1,149 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.dataformat.barcode;
+
+import com.google.zxing.BarcodeFormat;
+
+/**
+ * All configuration parameters for the code component.
+ * 
+ */
+public class BarcodeParameters {
+    
+    /**
+     * Default image type: PNG
+     */
+    public static final BarcodeImageType IMAGE_TYPE = BarcodeImageType.PNG;
+    
+    /**
+     * Default width: 100px
+     */
+    public static final int WIDTH = 100;
+    
+    /**
+     * Default height: 100px
+     */
+    public static final int HEIGHT = 100;
+    
+    /**
+     * Default encoding: UTF-8
+     */
+    public static final String ENCODING = "UTF-8";
+    
+    /**
+     * Default barcode format: QR-CODE
+     */
+    public static final BarcodeFormat FORMAT = BarcodeFormat.QR_CODE;
+    
+    /**
+     * The Image Type. 
+     */
+    private BarcodeImageType type = IMAGE_TYPE;
+    
+    /**
+     * The width of the image.
+     */
+    private Integer width = WIDTH;
+    
+    /**
+     * The height of the image.
+     */
+    private Integer height = HEIGHT;
+    
+    /**
+     * The message encoding.
+     */
+    private String encoding = ENCODING;
+    
+    /**
+     * The barcode format (e.g. QR-Code, DataMatrix,...).
+     */
+    private BarcodeFormat format = FORMAT;
+
+    /**
+     * Default Constructor (creates a bean with default parameters).
+     * 
+     * <ul>
+     *  <li>image type: PNG</li>
+     *  <li>image width: 100px</li>
+     *  <li>image heigth: 100px</li>
+     *  <li>encoding: UTF-8</li>
+     *  <li>format: QR-Code</li>
+     * </ul>
+     */
+    public BarcodeParameters() {
+        
+    }
+    
+    /**
+     * Constructor with parameters.
+     * @param type
+     * @param width
+     * @param height
+     * @param encoding
+     * @param format
+     */
+    public BarcodeParameters(final BarcodeImageType type, final int width, 
+            final int height, final String encoding, final BarcodeFormat format) {
+        this.encoding = encoding;
+        this.height = height;
+        this.width = width;
+        this.type = type;
+        this.format = format;
+    }
+
+    public BarcodeImageType getType() {
+        return type;
+    }
+
+    public void setType(BarcodeImageType type) {
+        this.type = type;
+    }
+
+    public Integer getWidth() {
+        return width;
+    }
+
+    public void setWidth(Integer width) {
+        this.width = width;
+    }
+
+    public Integer getHeight() {
+        return height;
+    }
+
+    public void setHeight(Integer height) {
+        this.height = height;
+    }
+
+    public String getEncoding() {
+        return encoding;
+    }
+
+    public void setEncoding(String encoding) {
+        this.encoding = encoding;
+    }
+
+    public BarcodeFormat getFormat() {
+        return format;
+    }
+
+    public void setFormat(BarcodeFormat format) {
+        this.format = format;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ec85a040/components/camel-barcode/src/main/resources/META-INF/LICENSE.txt
----------------------------------------------------------------------
diff --git a/components/camel-barcode/src/main/resources/META-INF/LICENSE.txt b/components/camel-barcode/src/main/resources/META-INF/LICENSE.txt
new file mode 100644
index 0000000..6b0b127
--- /dev/null
+++ b/components/camel-barcode/src/main/resources/META-INF/LICENSE.txt
@@ -0,0 +1,203 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+

http://git-wip-us.apache.org/repos/asf/camel/blob/ec85a040/components/camel-barcode/src/main/resources/META-INF/NOTICE.txt
----------------------------------------------------------------------
diff --git a/components/camel-barcode/src/main/resources/META-INF/NOTICE.txt b/components/camel-barcode/src/main/resources/META-INF/NOTICE.txt
new file mode 100644
index 0000000..f4f1281
--- /dev/null
+++ b/components/camel-barcode/src/main/resources/META-INF/NOTICE.txt
@@ -0,0 +1,11 @@
+   =========================================================================
+   ==  NOTICE file corresponding to the section 4 d of                    ==
+   ==  the Apache License, Version 2.0,                                   ==
+   ==  in this case for the Apache Camel distribution.                    ==
+   =========================================================================
+
+   This product includes software developed by
+   The Apache Software Foundation (http://www.apache.org/).
+
+   Please read the different LICENSE files present in the licenses directory of
+   this distribution.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/ec85a040/components/camel-barcode/src/main/resources/META-INF/services/org/apache/camel/dataformat/barcode
----------------------------------------------------------------------
diff --git a/components/camel-barcode/src/main/resources/META-INF/services/org/apache/camel/dataformat/barcode b/components/camel-barcode/src/main/resources/META-INF/services/org/apache/camel/dataformat/barcode
new file mode 100644
index 0000000..bd5d1c1
--- /dev/null
+++ b/components/camel-barcode/src/main/resources/META-INF/services/org/apache/camel/dataformat/barcode
@@ -0,0 +1,18 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+class=org.apache.camel.dataformat.barcode.BarcodeDataFormat

http://git-wip-us.apache.org/repos/asf/camel/blob/ec85a040/components/camel-barcode/src/test/java/org/apache/camel/dataformat/barcode/BarcodeDataFormatCamelTest.java
----------------------------------------------------------------------
diff --git a/components/camel-barcode/src/test/java/org/apache/camel/dataformat/barcode/BarcodeDataFormatCamelTest.java b/components/camel-barcode/src/test/java/org/apache/camel/dataformat/barcode/BarcodeDataFormatCamelTest.java
new file mode 100644
index 0000000..c867064
--- /dev/null
+++ b/components/camel-barcode/src/test/java/org/apache/camel/dataformat/barcode/BarcodeDataFormatCamelTest.java
@@ -0,0 +1,174 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.dataformat.barcode;
+
+import java.io.File;
+import java.util.concurrent.TimeUnit;
+
+import com.google.zxing.BarcodeFormat;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.spi.DataFormat;
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class tests all Camel dependend cases for {@link BarcodeDataFormat}. 
+ * 
+ * @author claus.straube
+ */
+public class BarcodeDataFormatCamelTest extends BarcodeTestBase {
+    
+    private static final Logger LOG = LoggerFactory.getLogger(BarcodeDataFormatCamelTest.class);
+    
+    @Before
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
+        
+        // clean directory
+        File directory = new File(PATH);
+        if (!directory.isDirectory() || !directory.exists()) {
+            LOG.error(String.format("cannot delete files from directory '%s', because path is not a directory, or it doesn't exist.", PATH));
+        } else {
+            LOG.info("deleting files from " + PATH + "...");
+            File[] files = directory.listFiles();
+            for (File file : files) {
+                LOG.info(String.format("deleting %s", file.getName()));
+                file.delete();
+            }
+        }
+    }
+
+    /**
+     * tests barcode (QR-Code) generation and reading.
+     * 
+     * @throws Exception 
+     */
+    @Test
+    public void testDefaultQRCode() throws Exception {
+        out.expectedBodiesReceived(MSG);
+        image.expectedMessageCount(1);
+
+        template.sendBody("direct:code1", MSG);
+
+        assertMockEndpointsSatisfied(5, TimeUnit.SECONDS);
+        this.checkImage(image, 100, 100, BarcodeImageType.PNG.toString());
+    }
+    
+    /**
+     * tests barcode (QR-Code) generation with modified size and reading.
+     * 
+     * @throws Exception 
+     */
+    @Test
+    public void testQRCodeWithModifiedSize() throws Exception {
+        out.expectedBodiesReceived(MSG);
+        image.expectedMessageCount(1);
+
+        template.sendBody("direct:code2", MSG);
+
+        assertMockEndpointsSatisfied(5, TimeUnit.SECONDS);
+        this.checkImage(image, 200, 200, BarcodeImageType.PNG.toString());
+    }
+    
+    /**
+     * tests barcode (QR-Code) generation with modified image type and reading.
+     * 
+     * @throws Exception 
+     */
+    @Test
+    public void testQRCodeWithJPEGType() throws Exception {
+        out.expectedBodiesReceived(MSG);
+        image.expectedMessageCount(1);
+
+        template.sendBody("direct:code3", MSG);
+
+        assertMockEndpointsSatisfied(5, TimeUnit.SECONDS);
+        this.checkImage(image, 100, 100, "JPEG");
+    }
+    
+    /**
+     * tests barcode (PDF-417) with modiefied size and image taype generation and reading.
+     * 
+     * @throws Exception 
+     */
+    @Test
+    public void testPDF417CodeWidthModifiedSizeAndImageType() throws Exception {
+        out.expectedBodiesReceived(MSG);
+        image.expectedMessageCount(1);
+
+        template.sendBody("direct:code4", MSG);
+
+        assertMockEndpointsSatisfied(60, TimeUnit.SECONDS);
+        this.checkImage(image, "JPEG");
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() {
+
+                // QR-Code default
+                DataFormat code1 = new BarcodeDataFormat();
+
+                from("direct:code1")
+                        .marshal(code1)
+                        .to(FILE_ENDPOINT);
+
+                // QR-Code with modified size
+                DataFormat code2 = new BarcodeDataFormat(200, 200);
+
+                from("direct:code2")
+                        .marshal(code2)
+                        .to(FILE_ENDPOINT);
+
+                // QR-Code with JPEG type
+                DataFormat code3 = new BarcodeDataFormat(BarcodeImageType.JPG);
+
+                from("direct:code3")
+                        .marshal(code3)
+                        .to(FILE_ENDPOINT);
+
+                // PDF-417 code with modified size and image type
+                DataFormat code4 = new BarcodeDataFormat(200, 200, BarcodeImageType.JPG, BarcodeFormat.PDF_417);
+                
+                from("direct:code4")
+                        .marshal(code4)
+                        .to(FILE_ENDPOINT);
+
+
+                // generic file read --->
+                // 
+                // read file and route it
+                from(FILE_ENDPOINT + "?noop=true")
+                        .multicast().to("direct:marshall", "mock:image");
+
+                // get the message from code
+                from("direct:marshall")
+                        .unmarshal(code1) // for unmarshalling, the instance doesn't matter
+                        .to("log:OUT")
+                        .to("mock:out");
+
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ec85a040/components/camel-barcode/src/test/java/org/apache/camel/dataformat/barcode/BarcodeDataFormatTest.java
----------------------------------------------------------------------
diff --git a/components/camel-barcode/src/test/java/org/apache/camel/dataformat/barcode/BarcodeDataFormatTest.java b/components/camel-barcode/src/test/java/org/apache/camel/dataformat/barcode/BarcodeDataFormatTest.java
new file mode 100644
index 0000000..67cc750
--- /dev/null
+++ b/components/camel-barcode/src/test/java/org/apache/camel/dataformat/barcode/BarcodeDataFormatTest.java
@@ -0,0 +1,237 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.dataformat.barcode;
+
+import java.util.Map;
+
+import com.google.zxing.BarcodeFormat;
+import com.google.zxing.DecodeHintType;
+import com.google.zxing.EncodeHintType;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * This class tests all Camel independend test cases 
+ * for {@link BarcodeDataFormat}.
+ * @author claus.straube
+ */
+public class BarcodeDataFormatTest {
+    
+    /**
+     * Test default constructor.
+     */
+    @Test
+    public final void testDefaultConstructor() {
+        BarcodeDataFormat barcodeDataFormat = new BarcodeDataFormat();
+        this.checkParams(BarcodeParameters.IMAGE_TYPE
+                , BarcodeParameters.WIDTH
+                , BarcodeParameters.HEIGHT
+                , BarcodeParameters.ENCODING
+                , BarcodeParameters.FORMAT
+                , barcodeDataFormat.getParams());
+    }
+    
+    /**
+     * Test constructor with barcode format.
+     */
+    @Test
+    public final void testConstructorWithBarcodeFormat() {
+        BarcodeDataFormat barcodeDataFormat = 
+                new BarcodeDataFormat(BarcodeFormat.AZTEC);
+        this.checkParams(BarcodeParameters.IMAGE_TYPE
+                , BarcodeParameters.WIDTH
+                , BarcodeParameters.HEIGHT
+                , BarcodeParameters.ENCODING
+                , BarcodeFormat.AZTEC
+                , barcodeDataFormat.getParams());
+    }
+    
+    /**
+     * Test constructor with size.
+     */
+    @Test
+    public final void testConstructorWithSize() {
+        BarcodeDataFormat barcodeDataFormat = 
+                new BarcodeDataFormat(200, 250);
+        this.checkParams(BarcodeParameters.IMAGE_TYPE
+                , 200, 250, BarcodeParameters.ENCODING
+                , BarcodeParameters.FORMAT
+                , barcodeDataFormat.getParams());
+    }
+    
+    /**
+     * Test constructor with image type.
+     */
+    @Test
+    public final void testConstructorWithImageType() {
+        BarcodeDataFormat barcodeDataFormat = 
+                new BarcodeDataFormat(BarcodeImageType.JPG);
+        this.checkParams(BarcodeImageType.JPG
+                , BarcodeParameters.WIDTH
+                , BarcodeParameters.HEIGHT
+                , BarcodeParameters.ENCODING
+                , BarcodeParameters.FORMAT
+                , barcodeDataFormat.getParams());
+    }
+    
+    /**
+     * Test constructor with all.
+     */
+    @Test
+    public final void testConstructorWithAll() {
+        BarcodeDataFormat barcodeDataFormat = 
+                new BarcodeDataFormat(200, 250, BarcodeImageType.JPG
+                        , BarcodeFormat.AZTEC);
+        this.checkParams(BarcodeImageType.JPG
+                , 200, 250
+                , BarcodeParameters.ENCODING
+                , BarcodeFormat.AZTEC
+                , barcodeDataFormat.getParams());
+    }
+
+    /**
+     * Test of optimizeHints method, of class BarcodeDataFormat.
+     */
+    @Test
+    public final void testOptimizeHints() {
+        BarcodeDataFormat instance = new BarcodeDataFormat();
+        assertTrue(instance.getWriterHintMap()
+                .containsKey(EncodeHintType.ERROR_CORRECTION));
+        assertTrue(instance.getReaderHintMap()
+                .containsKey(DecodeHintType.TRY_HARDER));
+    }
+    
+    /**
+     * Test optimized hints for data matrix.
+     */
+    @Test
+    public final void testOptimizieHintsForDataMatrix() {
+        BarcodeDataFormat instance = new BarcodeDataFormat(BarcodeFormat.DATA_MATRIX);
+        assertTrue("error correction hint incorrect.", 
+                instance.getWriterHintMap()
+                        .containsKey(EncodeHintType.ERROR_CORRECTION));
+        assertTrue("data matrix shape hint incorrect.", 
+                instance.getWriterHintMap()
+                        .containsKey(EncodeHintType.DATA_MATRIX_SHAPE));
+        assertTrue("try harder hint incorrect.",
+                instance.getReaderHintMap()
+                        .containsKey(DecodeHintType.TRY_HARDER));
+    }
+
+    /**
+     * Test of addToHintMap method, of class BarcodeDataFormat.
+     */
+    @Test
+    public final void testAddToHintMapEncodeHintTypeObject() {
+        EncodeHintType hintType = EncodeHintType.MARGIN;
+        Object value = 10;
+        BarcodeDataFormat instance = new BarcodeDataFormat();
+        instance.addToHintMap(hintType, value);
+        assertTrue(instance.getWriterHintMap().containsKey(hintType));
+        assertEquals(instance.getWriterHintMap().get(hintType), value);
+    }
+
+    /**
+     * Test of addToHintMap method, of class BarcodeDataFormat.
+     */
+    @Test
+    public final void testAddToHintMapDecodeHintTypeObject() {
+        DecodeHintType hintType = DecodeHintType.CHARACTER_SET;
+        Object value = "UTF-8";
+        BarcodeDataFormat instance = new BarcodeDataFormat();
+        instance.addToHintMap(hintType, value);
+        assertTrue(instance.getReaderHintMap().containsKey(hintType));
+        assertEquals(instance.getReaderHintMap().get(hintType), value);
+    }
+
+    /**
+     * Test of removeFromHintMap method, of class BarcodeDataFormat.
+     */
+    @Test
+    public final void testRemoveFromHintMapEncodeHintType() {
+        EncodeHintType hintType = EncodeHintType.ERROR_CORRECTION;
+        BarcodeDataFormat instance = new BarcodeDataFormat();
+        instance.removeFromHintMap(hintType);
+        assertFalse(instance.getWriterHintMap().containsKey(hintType));
+    }
+
+    /**
+     * Test of removeFromHintMap method, of class BarcodeDataFormat.
+     */
+    @Test
+    public final void testRemoveFromHintMapDecodeHintType() {
+        DecodeHintType hintType = DecodeHintType.TRY_HARDER;
+        BarcodeDataFormat instance = new BarcodeDataFormat();
+        instance.removeFromHintMap(hintType);
+        assertFalse(instance.getReaderHintMap().containsKey(hintType));
+    }
+
+    /**
+     * Test of getParams method, of class BarcodeDataFormat.
+     */
+    @Test
+    public final void testGetParams() {
+        BarcodeDataFormat instance = new BarcodeDataFormat();
+        BarcodeParameters result = instance.getParams();
+        assertNotNull(result);
+    }
+
+    /**
+     * Test of getWriterHintMap method, of class BarcodeDataFormat.
+     */
+    @Test
+    public final void testGetWriterHintMap() {
+        BarcodeDataFormat instance = new BarcodeDataFormat();
+        Map<EncodeHintType, Object> result = instance.getWriterHintMap();
+        assertNotNull(result);
+    }
+
+    /**
+     * Test of getReaderHintMap method, of class BarcodeDataFormat.
+     */
+    @Test
+    public final void testGetReaderHintMap() {
+        BarcodeDataFormat instance = new BarcodeDataFormat();
+        Map<DecodeHintType, Object> result = instance.getReaderHintMap();
+        assertNotNull(result);
+    }
+    
+    /**
+     * Helper to check the saved parameters.
+     * 
+     * @param imageType
+     * @param width
+     * @param height
+     * @param encoding
+     * @param format
+     * @param params 
+     */
+    private void checkParams(BarcodeImageType imageType, int width, int height
+            , String encoding, BarcodeFormat format, BarcodeParameters params) {
+        assertEquals(params.getType(), imageType);
+        assertTrue(params.getWidth() == width);
+        assertTrue(params.getHeight() == height);
+        assertEquals(params.getEncoding(), encoding);
+        assertEquals(params.getFormat(), format);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ec85a040/components/camel-barcode/src/test/java/org/apache/camel/dataformat/barcode/BarcodeTestBase.java
----------------------------------------------------------------------
diff --git a/components/camel-barcode/src/test/java/org/apache/camel/dataformat/barcode/BarcodeTestBase.java b/components/camel-barcode/src/test/java/org/apache/camel/dataformat/barcode/BarcodeTestBase.java
new file mode 100644
index 0000000..201dcfa
--- /dev/null
+++ b/components/camel-barcode/src/test/java/org/apache/camel/dataformat/barcode/BarcodeTestBase.java
@@ -0,0 +1,71 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dataformat.barcode;
+
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
+
+import javax.imageio.ImageIO;
+import javax.imageio.ImageReader;
+import javax.imageio.stream.ImageInputStream;
+
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Exchange;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+
+
+public class BarcodeTestBase extends CamelTestSupport {
+
+    protected static final String MSG = "This is a testmessage!";
+    
+    protected static final String PATH = "target/out";
+    protected static final String FILE_ENDPOINT = "file:" + PATH;
+
+    @EndpointInject(uri = "mock:out")
+    MockEndpoint out;
+
+    @EndpointInject(uri = "mock:image")
+    MockEndpoint image;
+
+    protected void checkImage(MockEndpoint mock, int height, int width, String type) throws IOException {
+        Exchange ex = mock.getReceivedExchanges().get(0);
+        File in = ex.getIn().getBody(File.class);
+
+        // check image
+        BufferedImage i = ImageIO.read(in);
+        assertTrue(height >= i.getHeight());
+        assertTrue(width >= i.getWidth());
+        this.checkType(in, type);
+        in.delete();
+    }
+    
+    protected void checkImage(MockEndpoint mock, String type) throws IOException {
+        Exchange ex = mock.getReceivedExchanges().get(0);
+        File in = ex.getIn().getBody(File.class);
+        this.checkType(in, type);
+        in.delete();
+    }
+    
+    private void checkType(File file, String type) throws IOException {
+        ImageInputStream iis = ImageIO.createImageInputStream(file);
+        ImageReader reader = ImageIO.getImageReaders(iis).next();
+        String format = reader.getFormatName();
+        assertEquals(type, format.toUpperCase());
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ec85a040/components/camel-barcode/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/components/camel-barcode/src/test/resources/log4j.properties b/components/camel-barcode/src/test/resources/log4j.properties
new file mode 100644
index 0000000..3b1bd38
--- /dev/null
+++ b/components/camel-barcode/src/test/resources/log4j.properties
@@ -0,0 +1,14 @@
+#
+# The logging properties used
+#
+log4j.rootLogger=INFO, out
+
+# uncomment the following line to turn on Camel debugging
+#log4j.logger.org.apache.camel=DEBUG
+
+# CONSOLE appender not used by default
+log4j.appender.out=org.apache.log4j.ConsoleAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=[%30.30t] %-30.30c{1} %-5p %m%n
+#log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+

http://git-wip-us.apache.org/repos/asf/camel/blob/ec85a040/components/pom.xml
----------------------------------------------------------------------
diff --git a/components/pom.xml b/components/pom.xml
index a8d3109..5d31116 100644
--- a/components/pom.xml
+++ b/components/pom.xml
@@ -64,6 +64,7 @@
     <module>camel-base64</module>
     <module>camel-beanio</module>
     <module>camel-bean-validator</module>
+    <module>camel-barcode</module>
     <module>camel-bindy</module>
     <module>camel-cache</module>
     <module>camel-castor</module>
@@ -165,7 +166,6 @@
     <module>camel-smpp</module>
     <module>camel-snmp</module>
     <module>camel-sjms</module>
-    <module>camel-soap</module>
     <module>camel-solr</module>
     <module>camel-splunk</module>
     <module>camel-spring-batch</module>

http://git-wip-us.apache.org/repos/asf/camel/blob/ec85a040/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index d6ed58a..2cdc419 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -446,6 +446,7 @@
     <xstream-version>1.4.7</xstream-version>
     <xom-version>1.2.5</xom-version>
     <yammer-metrics-version>2.2.0</yammer-metrics-version>
+    <zxing-version>3.0.0</zxing-version>
     <zookeeper-version>3.4.6</zookeeper-version>
 
     <!-- OSGi bundles properties -->
@@ -573,6 +574,11 @@
       </dependency>
       <dependency>
         <groupId>org.apache.camel</groupId>
+        <artifactId>camel-barcode</artifactId>
+        <version>${project.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.camel</groupId>
         <artifactId>camel-bindy</artifactId>
         <version>${project.version}</version>
       </dependency>

http://git-wip-us.apache.org/repos/asf/camel/blob/ec85a040/platforms/karaf/features/src/main/resources/features.xml
----------------------------------------------------------------------
diff --git a/platforms/karaf/features/src/main/resources/features.xml b/platforms/karaf/features/src/main/resources/features.xml
index d52be06..19056a9 100644
--- a/platforms/karaf/features/src/main/resources/features.xml
+++ b/platforms/karaf/features/src/main/resources/features.xml
@@ -162,6 +162,12 @@
     <bundle dependency='true'>mvn:org.beanio/beanio/${beanio-version}</bundle>
     <bundle>mvn:org.apache.camel/camel-beanio/${project.version}</bundle>
   </feature>
+  <feature name='camel-barcode' version='${project.version}' resolver='(obr)' start-level='50'>
+    <feature version='${project.version}'>camel-core</feature>
+    <bundle dependency='true'>mvn:com.google.zxing/core/${zxing-version}</bundle>
+    <bundle dependency='true'>mvn:com.google.zxing/javase/${zxing-version}</bundle>
+    <bundle>mvn:org.apache.camel/camel-barcode/${project.version}</bundle>
+  </feature>
   <feature name='camel-bindy' version='${project.version}' resolver='(obr)' start-level='50'>
     <feature version='${project.version}'>camel-core</feature>
     <bundle>mvn:org.apache.camel/camel-bindy/${project.version}</bundle>


Mime
View raw message