You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ra...@apache.org on 2015/09/03 22:55:59 UTC

[1/2] camel git commit: CAMEL-9111 Camel Tarfile dataformat, splitter and aggregation strategy.

Repository: camel
Updated Branches:
  refs/heads/master b1b49bfba -> 2051db4b4


http://git-wip-us.apache.org/repos/asf/camel/blob/2051db4b/components/camel-tarfile/src/test/resources/org/apache/camel/aggregate/tarfile/data/another/hello.txt
----------------------------------------------------------------------
diff --git a/components/camel-tarfile/src/test/resources/org/apache/camel/aggregate/tarfile/data/another/hello.txt b/components/camel-tarfile/src/test/resources/org/apache/camel/aggregate/tarfile/data/another/hello.txt
new file mode 100644
index 0000000..b6fc4c6
--- /dev/null
+++ b/components/camel-tarfile/src/test/resources/org/apache/camel/aggregate/tarfile/data/another/hello.txt
@@ -0,0 +1 @@
+hello
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/2051db4b/components/camel-tarfile/src/test/resources/org/apache/camel/aggregate/tarfile/data/chiau.txt
----------------------------------------------------------------------
diff --git a/components/camel-tarfile/src/test/resources/org/apache/camel/aggregate/tarfile/data/chiau.txt b/components/camel-tarfile/src/test/resources/org/apache/camel/aggregate/tarfile/data/chiau.txt
new file mode 100644
index 0000000..7842486
--- /dev/null
+++ b/components/camel-tarfile/src/test/resources/org/apache/camel/aggregate/tarfile/data/chiau.txt
@@ -0,0 +1 @@
+chau
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/2051db4b/components/camel-tarfile/src/test/resources/org/apache/camel/aggregate/tarfile/data/hi.txt
----------------------------------------------------------------------
diff --git a/components/camel-tarfile/src/test/resources/org/apache/camel/aggregate/tarfile/data/hi.txt b/components/camel-tarfile/src/test/resources/org/apache/camel/aggregate/tarfile/data/hi.txt
new file mode 100644
index 0000000..32f95c0
--- /dev/null
+++ b/components/camel-tarfile/src/test/resources/org/apache/camel/aggregate/tarfile/data/hi.txt
@@ -0,0 +1 @@
+hi
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/2051db4b/components/camel-tarfile/src/test/resources/org/apache/camel/aggregate/tarfile/data/hola.txt
----------------------------------------------------------------------
diff --git a/components/camel-tarfile/src/test/resources/org/apache/camel/aggregate/tarfile/data/hola.txt b/components/camel-tarfile/src/test/resources/org/apache/camel/aggregate/tarfile/data/hola.txt
new file mode 100644
index 0000000..b8b4a4e
--- /dev/null
+++ b/components/camel-tarfile/src/test/resources/org/apache/camel/aggregate/tarfile/data/hola.txt
@@ -0,0 +1 @@
+hola
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/2051db4b/components/camel-tarfile/src/test/resources/org/apache/camel/aggregate/tarfile/data/other/greetings.txt
----------------------------------------------------------------------
diff --git a/components/camel-tarfile/src/test/resources/org/apache/camel/aggregate/tarfile/data/other/greetings.txt b/components/camel-tarfile/src/test/resources/org/apache/camel/aggregate/tarfile/data/other/greetings.txt
new file mode 100644
index 0000000..9eaa11a
--- /dev/null
+++ b/components/camel-tarfile/src/test/resources/org/apache/camel/aggregate/tarfile/data/other/greetings.txt
@@ -0,0 +1 @@
+greetings
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/2051db4b/components/camel-tarfile/src/test/resources/org/apache/camel/dataformat/tarfile/SpringTarSplitterRouteTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-tarfile/src/test/resources/org/apache/camel/dataformat/tarfile/SpringTarSplitterRouteTest.xml b/components/camel-tarfile/src/test/resources/org/apache/camel/dataformat/tarfile/SpringTarSplitterRouteTest.xml
new file mode 100644
index 0000000..8212452
--- /dev/null
+++ b/components/camel-tarfile/src/test/resources/org/apache/camel/dataformat/tarfile/SpringTarSplitterRouteTest.xml
@@ -0,0 +1,42 @@
+<?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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+    ">
+
+  <!-- START SNIPPET: e1 -->
+
+  <!-- use a bean to define a custom expression -->
+  <bean id="tarSplitter" class="org.apache.camel.dataformat.tarfile.TarSplitter"/>
+
+  <camelContext xmlns="http://camel.apache.org/schema/spring">
+    <route>
+      <from uri="file:src/test/resources/org/apache/camel/dataformat/tarfile/data?consumer.delay=1000&amp;noop=true"/>
+      <split streaming="true">
+        <!-- refer to our custom expression, using ref tag -->
+        <ref>tarSplitter</ref>
+        <convertBodyTo type="java.lang.String" charset="UTF-8"/>
+        <to uri="mock:processTarEntry"/>
+      </split>
+    </route>
+  </camelContext>
+  <!-- END SNIPPET: e1 -->
+</beans>

http://git-wip-us.apache.org/repos/asf/camel/blob/2051db4b/components/camel-tarfile/src/test/resources/org/apache/camel/dataformat/tarfile/data/tarfile.tar
----------------------------------------------------------------------
diff --git a/components/camel-tarfile/src/test/resources/org/apache/camel/dataformat/tarfile/data/tarfile.tar b/components/camel-tarfile/src/test/resources/org/apache/camel/dataformat/tarfile/data/tarfile.tar
new file mode 100644
index 0000000..a0d49b0
Binary files /dev/null and b/components/camel-tarfile/src/test/resources/org/apache/camel/dataformat/tarfile/data/tarfile.tar differ

http://git-wip-us.apache.org/repos/asf/camel/blob/2051db4b/components/pom.xml
----------------------------------------------------------------------
diff --git a/components/pom.xml b/components/pom.xml
index cd89967..0725607 100644
--- a/components/pom.xml
+++ b/components/pom.xml
@@ -225,6 +225,7 @@
     <module>camel-syslog</module>
     <module>camel-swagger</module>
     <module>camel-tagsoup</module>
+    <module>camel-tarfile</module>
     <module>camel-twitter</module>
     <module>camel-undertow</module>
     <module>camel-univocity-parsers</module>

http://git-wip-us.apache.org/repos/asf/camel/blob/2051db4b/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 9638402..cf5cd88 100644
--- a/platforms/karaf/features/src/main/resources/features.xml
+++ b/platforms/karaf/features/src/main/resources/features.xml
@@ -1547,6 +1547,11 @@
     <feature version='${project.version}'>camel-core</feature>
     <bundle>mvn:org.apache.camel/camel-tagsoup/${project.version}</bundle>
   </feature>
+  <feature name='camel-tarfile' version='${project.version}' resolver='(obr)' start-level='50'>
+    <feature version='${project.version}'>camel-core</feature>
+    <bundle>mvn:org.apache.camel/camel-tarfile/${project.version}</bundle>
+    <bundle dependency='true'>mvn:org.apache.commons/commons-compress/${commons-compress-version}</bundle>
+  </feature>
   <feature name='camel-test' version='${project.version}' resolver='(obr)' start-level='50'>
     <feature version='${project.version}'>camel-core</feature>
     <feature version='${project.version}'>camel-spring</feature>


[2/2] camel git commit: CAMEL-9111 Camel Tarfile dataformat, splitter and aggregation strategy.

Posted by ra...@apache.org.
CAMEL-9111 Camel Tarfile dataformat, splitter and aggregation strategy.

With thanks to Sverker Abrahamsson. This closes #599.


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

Branch: refs/heads/master
Commit: 2051db4b46b7b423915fa77cad7f54e71358e659
Parents: b1b49bf
Author: Raul Kripalani <ra...@apache.org>
Authored: Thu Sep 3 21:54:51 2015 +0100
Committer: Raul Kripalani <ra...@apache.org>
Committed: Thu Sep 3 21:55:43 2015 +0100

----------------------------------------------------------------------
 .../model/dataformat/TarFileDataFormat.java     |  61 +++++
 components/camel-tarfile/pom.xml                |  78 ++++++
 .../tarfile/TarElementInputStreamWrapper.java   |  46 ++++
 .../dataformat/tarfile/TarFileDataFormat.java   | 111 ++++++++
 .../camel/dataformat/tarfile/TarIterator.java   | 175 +++++++++++++
 .../camel/dataformat/tarfile/TarSplitter.java   |  44 ++++
 .../tarfile/TarAggregationStrategy.java         | 259 +++++++++++++++++++
 .../src/main/resources/META-INF/LICENSE.txt     | 203 +++++++++++++++
 .../src/main/resources/META-INF/NOTICE.txt      |  11 +
 .../org/apache/camel/dataformat/tarfile         |  18 ++
 .../tarfile/SpringTarSplitterRouteTest.java     |  38 +++
 .../tarfile/TarFileDataFormatTest.java          | 221 ++++++++++++++++
 .../TarFileMultipleFilesSplitterTest.java       |  82 ++++++
 .../tarfile/TarSplitterRouteIssueTest.java      |  69 +++++
 .../tarfile/TarSplitterRouteTest.java           |  51 ++++
 ...gregationStrategyWithFilenameHeaderTest.java |  94 +++++++
 ...AggregationStrategyWithPreservationTest.java |  97 +++++++
 .../tarfile/TarAggregationStrategyTest.java     |  87 +++++++
 .../src/test/resources/data/tarfile3.tar        | Bin 0 -> 4096 bytes
 .../src/test/resources/log4j.properties         |  38 +++
 .../aggregate/tarfile/data/another/hello.txt    |   1 +
 .../camel/aggregate/tarfile/data/chiau.txt      |   1 +
 .../apache/camel/aggregate/tarfile/data/hi.txt  |   1 +
 .../camel/aggregate/tarfile/data/hola.txt       |   1 +
 .../aggregate/tarfile/data/other/greetings.txt  |   1 +
 .../tarfile/SpringTarSplitterRouteTest.xml      |  42 +++
 .../camel/dataformat/tarfile/data/tarfile.tar   | Bin 0 -> 7168 bytes
 components/pom.xml                              |   1 +
 .../features/src/main/resources/features.xml    |   5 +
 29 files changed, 1836 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/2051db4b/camel-core/src/main/java/org/apache/camel/model/dataformat/TarFileDataFormat.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/dataformat/TarFileDataFormat.java b/camel-core/src/main/java/org/apache/camel/model/dataformat/TarFileDataFormat.java
new file mode 100644
index 0000000..ecd8e51
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/model/dataformat/TarFileDataFormat.java
@@ -0,0 +1,61 @@
+/**
+ * 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.model.dataformat;
+
+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 org.apache.camel.CamelContext;
+import org.apache.camel.model.DataFormatDefinition;
+import org.apache.camel.spi.DataFormat;
+import org.apache.camel.spi.Metadata;
+
+/**
+ * Represents the TAR file XML {@link org.apache.camel.spi.DataFormat}.
+ */
+@Metadata(label = "dataformat,transformation", title = "Tar File")
+@XmlRootElement(name = "tarfile")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class TarFileDataFormat extends DataFormatDefinition {
+    @XmlAttribute
+    private Boolean usingIterator;
+
+    public TarFileDataFormat() {
+        super("tarfile");
+    }
+
+    @Override
+    protected void configureDataFormat(DataFormat dataFormat, CamelContext camelContext) {
+        if (usingIterator != null) {
+            setProperty(camelContext, dataFormat, "usingIterator", usingIterator);
+        }
+    }
+
+    public Boolean getUsingIterator() {
+        return usingIterator;
+    }
+
+    /**
+     * If the tar file has more then one entry, the setting this option to true, allows to work with the splitter EIP,
+     * to split the data using an iterator in a streaming mode.
+     */
+    public void setUsingIterator(Boolean usingIterator) {
+        this.usingIterator = usingIterator;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/2051db4b/components/camel-tarfile/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-tarfile/pom.xml b/components/camel-tarfile/pom.xml
new file mode 100644
index 0000000..d9c8b53
--- /dev/null
+++ b/components/camel-tarfile/pom.xml
@@ -0,0 +1,78 @@
+<?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.16-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>camel-tarfile</artifactId>
+  <packaging>bundle</packaging>
+  <name>Camel :: Tar File</name>
+  <description>Camel Tar file support</description>
+
+  <properties>
+    <camel.osgi.import>
+    	!org.apache.camel.dataformat.tarfile,
+    	!org.apache.camel.processor.aggregate.tarfile,
+    	*
+    </camel.osgi.import>
+    <camel.osgi.export>
+    	org.apache.camel.dataformat.tarfile;${camel.osgi.version},
+    	org.apache.camel.processor.aggregate.tarfile;${camel.osgi.version}
+    </camel.osgi.export>
+    <camel.osgi.export.service>org.apache.camel.spi.DataFormatResolver;dataformat=tarfile</camel.osgi.export.service>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-core</artifactId>
+    </dependency>
+	<dependency>
+      <groupId>org.apache.commons</groupId>
+	  <artifactId>commons-compress</artifactId>
+	  <version>${commons-compress-version}</version>
+	</dependency>
+
+    <!-- test dependencies -->
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-test</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-spring</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <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>
+  </dependencies>
+</project>

http://git-wip-us.apache.org/repos/asf/camel/blob/2051db4b/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarElementInputStreamWrapper.java
----------------------------------------------------------------------
diff --git a/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarElementInputStreamWrapper.java b/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarElementInputStreamWrapper.java
new file mode 100644
index 0000000..b8e7ebd
--- /dev/null
+++ b/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarElementInputStreamWrapper.java
@@ -0,0 +1,46 @@
+/**
+ * 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.tarfile;
+
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * Keeps a handle on the original {@link InputStream} even after closing the buffered input stream.
+ */
+public class TarElementInputStreamWrapper extends BufferedInputStream {
+
+    public TarElementInputStreamWrapper(InputStream in, int size) {
+        super(in, size);
+    }
+
+    public TarElementInputStreamWrapper(InputStream in) {
+        super(in);
+    }
+
+    @Override
+    public void close() throws IOException {
+        InputStream input = in;
+        try {
+            in = null;
+            super.close();
+        } finally {
+            in = input;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/2051db4b/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarFileDataFormat.java
----------------------------------------------------------------------
diff --git a/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarFileDataFormat.java b/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarFileDataFormat.java
new file mode 100644
index 0000000..754d932
--- /dev/null
+++ b/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarFileDataFormat.java
@@ -0,0 +1,111 @@
+/**
+ * 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.tarfile;
+
+import java.io.BufferedInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.spi.DataFormat;
+import org.apache.camel.util.IOHelper;
+import org.apache.camel.util.StringHelper;
+import org.apache.commons.compress.archivers.ArchiveStreamFactory;
+import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
+import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
+import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
+
+import static org.apache.camel.Exchange.FILE_LENGTH;
+import static org.apache.camel.Exchange.FILE_NAME;
+
+/**
+ * Tar file data format.
+ * Based on ZipFileDataFormat from camel-zipfile component
+ */
+public class TarFileDataFormat implements DataFormat {
+    private boolean usingIterator;
+
+    public void setUsingIterator(boolean usingIterator) {
+        this.usingIterator = usingIterator;
+    }
+
+    @Override
+    public void marshal(Exchange exchange, Object graph, OutputStream stream) throws Exception {
+        String filename = exchange.getIn().getHeader(FILE_NAME, String.class);
+        Long filelength = exchange.getIn().getHeader(FILE_LENGTH, Long.class);
+        if (filename != null) {
+            filename = new File(filename).getName(); // remove any path elements
+        } else {
+            // generate the file name as the camel file component would do
+            filename = StringHelper.sanitize(exchange.getIn().getMessageId());
+        }
+
+        TarArchiveOutputStream tos = new TarArchiveOutputStream(stream);
+        tos.setLongFileMode(TarArchiveOutputStream.LONGFILE_POSIX);
+        tos.setBigNumberMode(TarArchiveOutputStream.BIGNUMBER_POSIX);
+
+        InputStream is = exchange.getContext().getTypeConverter().mandatoryConvertTo(InputStream.class, graph);
+        if (filelength == null) {
+            filelength = (long) is.available();
+        }
+
+        TarArchiveEntry entry = new TarArchiveEntry(filename);
+        entry.setSize(filelength);
+        tos.putArchiveEntry(entry);
+
+        try {
+            IOHelper.copy(is, tos);
+        } finally {
+            tos.closeArchiveEntry();
+            IOHelper.close(is, tos);
+        }
+
+        String newFilename = filename + ".tar";
+        exchange.getOut().setHeader(FILE_NAME, newFilename);
+    }
+
+    @Override
+    public Object unmarshal(Exchange exchange, InputStream stream) throws Exception {
+        if (usingIterator) {
+            return new TarIterator(exchange.getIn(), stream);
+        } else {
+            InputStream is = exchange.getIn().getMandatoryBody(InputStream.class);
+            TarArchiveInputStream tis = (TarArchiveInputStream) new ArchiveStreamFactory().createArchiveInputStream(ArchiveStreamFactory.TAR, new BufferedInputStream(is));
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+            try {
+                TarArchiveEntry entry = tis.getNextTarEntry();
+                if (entry != null) {
+                    exchange.getOut().setHeader(FILE_NAME, entry.getName());
+                    IOHelper.copy(tis, baos);
+                }
+
+                entry = tis.getNextTarEntry();
+                if (entry != null) {
+                    throw new IllegalStateException("Tar file has more than 1 entry.");
+                }
+
+                return baos.toByteArray();
+
+            } finally {
+                IOHelper.close(tis, baos);
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/2051db4b/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarIterator.java
----------------------------------------------------------------------
diff --git a/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarIterator.java b/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarIterator.java
new file mode 100644
index 0000000..943ea44
--- /dev/null
+++ b/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarIterator.java
@@ -0,0 +1,175 @@
+/**
+ * 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.tarfile;
+
+import java.io.BufferedInputStream;
+import java.io.ByteArrayInputStream;
+import java.io.Closeable;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Iterator;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.impl.DefaultMessage;
+import org.apache.camel.util.IOHelper;
+import org.apache.commons.compress.archivers.ArchiveException;
+import org.apache.commons.compress.archivers.ArchiveInputStream;
+import org.apache.commons.compress.archivers.ArchiveStreamFactory;
+import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
+import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The Iterator which can go through the TarArchiveInputStream according to TarArchiveEntry
+ * Based on ZipIterator from camel-zipfile component
+ */
+public class TarIterator implements Iterator<Message>, Closeable {
+
+    /**
+     * Header where this {@link TarIterator} will insert the current entry's file name.
+     */
+    public static final String TARFILE_ENTRY_NAME_HEADER = "CamelTarFileEntryName";
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(TarIterator.class);
+
+    private final Message inputMessage;
+    private TarArchiveInputStream tarInputStream;
+    private Message parent;
+
+    public TarIterator(Message inputMessage, InputStream inputStream) {
+        this.inputMessage = inputMessage;
+        //InputStream inputStream = inputMessage.getBody(InputStream.class);
+
+        if (inputStream instanceof TarArchiveInputStream) {
+            tarInputStream = (TarArchiveInputStream) inputStream;
+        } else {
+            try {
+                ArchiveInputStream input = new ArchiveStreamFactory().createArchiveInputStream(ArchiveStreamFactory.TAR, new BufferedInputStream(inputStream));
+                tarInputStream = (TarArchiveInputStream) input;
+            } catch (ArchiveException e) {
+                throw new RuntimeException(e.getMessage(), e);
+            }
+        }
+        parent = null;
+    }
+
+    @Override
+    public boolean hasNext() {
+        try {
+            if (tarInputStream == null) {
+                return false;
+            }
+            boolean availableDataInCurrentEntry = tarInputStream.available() > 0;
+            if (!availableDataInCurrentEntry) {
+                // advance to the next entry.
+                parent = getNextElement();
+                if (parent == null) {
+                    tarInputStream.close();
+                    availableDataInCurrentEntry = false;
+                } else {
+                    availableDataInCurrentEntry = true;
+                }
+            }
+            return availableDataInCurrentEntry;
+        } catch (IOException exception) {
+            //Just wrap the IOException as CamelRuntimeException
+            throw new RuntimeCamelException(exception);
+        }
+    }
+
+    @Override
+    public Message next() {
+        if (parent == null) {
+            parent = getNextElement();
+        }
+
+        Message answer = parent;
+        parent = null;
+        checkNullAnswer(answer);
+
+        return answer;
+    }
+
+    private Message getNextElement() {
+        Message answer = null;
+
+        if (tarInputStream == null) {
+            return answer;
+        }
+
+        try {
+            TarArchiveEntry current = getNextEntry();
+
+            if (current != null) {
+                LOGGER.debug("Reading tarEntry {}", current.getName());
+                answer = new DefaultMessage();
+                answer.getHeaders().putAll(inputMessage.getHeaders());
+                answer.setHeader(TARFILE_ENTRY_NAME_HEADER, current.getName());
+                answer.setHeader(Exchange.FILE_NAME, current.getName());
+                if (current.getSize() > 0) {
+                    answer.setBody(new TarElementInputStreamWrapper(tarInputStream));
+                } else {
+                    // Workaround for the case when the entry is zero bytes big
+                    answer.setBody(new ByteArrayInputStream(new byte[0]));
+                }
+                return answer;
+            } else {
+                LOGGER.trace("Closed tarInputStream");
+            }
+        } catch (IOException exception) {
+            //Just wrap the IOException as CamelRuntimeException
+            throw new RuntimeCamelException(exception);
+        }
+
+        return answer;
+    }
+
+    public void checkNullAnswer(Message answer) {
+        if (answer == null && tarInputStream != null) {
+            IOHelper.close(tarInputStream);
+            tarInputStream = null;
+        }
+    }
+
+    private TarArchiveEntry getNextEntry() throws IOException {
+        TarArchiveEntry entry;
+
+        while ((entry = tarInputStream.getNextTarEntry()) != null) {
+            if (!entry.isDirectory()) {
+                return entry;
+            }
+        }
+
+        return null;
+    }
+
+    @Override
+    public void remove() {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void close() throws IOException {
+        if (tarInputStream != null) {
+            tarInputStream.close();
+            tarInputStream = null;
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/2051db4b/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarSplitter.java
----------------------------------------------------------------------
diff --git a/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarSplitter.java b/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarSplitter.java
new file mode 100644
index 0000000..132dd55
--- /dev/null
+++ b/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarSplitter.java
@@ -0,0 +1,44 @@
+/**
+ * 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.tarfile;
+
+import java.io.InputStream;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Expression;
+import org.apache.camel.Message;
+
+/**
+ * TarSplitter the expression builder which can be used after the splitter
+ * Based on the ZipSplitter from camel-zipfile component
+ */
+public class TarSplitter implements Expression {
+
+    public TarSplitter() {
+    }
+
+    public Object evaluate(Exchange exchange) {
+        Message inputMessage = exchange.getIn();
+        return new TarIterator(inputMessage, inputMessage.getBody(InputStream.class));
+    }
+
+    @Override
+    public <T> T evaluate(Exchange exchange, Class<T> type) {
+        Object result = evaluate(exchange);
+        return exchange.getContext().getTypeConverter().convertTo(type, exchange, result);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/2051db4b/components/camel-tarfile/src/main/java/org/apache/camel/processor/aggregate/tarfile/TarAggregationStrategy.java
----------------------------------------------------------------------
diff --git a/components/camel-tarfile/src/main/java/org/apache/camel/processor/aggregate/tarfile/TarAggregationStrategy.java b/components/camel-tarfile/src/main/java/org/apache/camel/processor/aggregate/tarfile/TarAggregationStrategy.java
new file mode 100644
index 0000000..ae4ba2b
--- /dev/null
+++ b/components/camel-tarfile/src/main/java/org/apache/camel/processor/aggregate/tarfile/TarAggregationStrategy.java
@@ -0,0 +1,259 @@
+/**
+ * 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.processor.aggregate.tarfile;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.component.file.FileConsumer;
+import org.apache.camel.component.file.GenericFile;
+import org.apache.camel.component.file.GenericFileMessage;
+import org.apache.camel.component.file.GenericFileOperationFailedException;
+import org.apache.camel.processor.aggregate.AggregationStrategy;
+import org.apache.camel.spi.Synchronization;
+import org.apache.camel.util.FileUtil;
+import org.apache.camel.util.IOHelper;
+import org.apache.commons.compress.archivers.ArchiveEntry;
+import org.apache.commons.compress.archivers.ArchiveException;
+import org.apache.commons.compress.archivers.ArchiveStreamFactory;
+import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
+import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
+import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
+import org.apache.commons.compress.utils.IOUtils;
+
+/**
+ * This aggregation strategy will aggregate all incoming messages into a TAR file.
+ * <p>If the incoming exchanges contain {@link GenericFileMessage} file name will 
+ * be taken from the body otherwise the body content will be treated as a byte 
+ * array and the TAR entry will be named using the message id (unless the flag
+ * useFilenameHeader is set to true.</p>
+ * <p><b>NOTE 1:</b> Please note that this aggregation strategy requires eager
+ * completion check to work properly.</p>
+ *
+ * <p><b>NOTE 2:</b> This implementation is very inefficient especially on big files since the tar
+ * file is completely rewritten for each file that is added to it. Investigate if the
+ * files can be collected and at completion stored to tar file.</p>
+ */
+public class TarAggregationStrategy implements AggregationStrategy {
+
+    private String filePrefix;
+    private String fileSuffix = ".tar";
+    private boolean preserveFolderStructure;
+    private boolean useFilenameHeader;
+
+    public TarAggregationStrategy() {
+        this(false, false);
+    }
+
+    /**
+     * @param preserveFolderStructure if true, the folder structure is preserved when the source is
+     * a type of {@link GenericFileMessage}.  If used with a file, use recursive=true.
+     */
+    public TarAggregationStrategy(boolean preserveFolderStructure) {
+        this(preserveFolderStructure, false);
+    }
+
+    /**
+     * @param preserveFolderStructure if true, the folder structure is preserved when the source is
+     * a type of {@link GenericFileMessage}.  If used with a file, use recursive=true.
+     * @param useFilenameHeader if true, the filename header will be used to name aggregated byte arrays
+     * within the TAR file.
+     */
+    public TarAggregationStrategy(boolean preserveFolderStructure, boolean useFilenameHeader) {
+        this.preserveFolderStructure = preserveFolderStructure;
+        this.useFilenameHeader = useFilenameHeader;
+    }
+
+    /**
+     * Gets the prefix used when creating the TAR file name.
+     * @return the prefix
+     */
+    public String getFilePrefix() {
+        return filePrefix;
+    }
+
+    /**
+     * Sets the prefix that will be used when creating the TAR filename.
+     * @param filePrefix prefix to use on TAR file.
+     */
+    public void setFilePrefix(String filePrefix) {
+        this.filePrefix = filePrefix;
+    }
+
+    /**
+     * Gets the suffix used when creating the TAR file name.
+     * @return the suffix
+     */
+    public String getFileSuffix() {
+        return fileSuffix;
+    }
+
+    /**
+     * Sets the suffix that will be used when creating the ZIP filename.
+     * @param fileSuffix suffix to use on ZIP file.
+     */
+    public void setFileSuffix(String fileSuffix) {
+        this.fileSuffix = fileSuffix;
+    }
+
+    @Override
+    public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
+        File tarFile;
+        Exchange answer = oldExchange;
+
+        // Guard against empty new exchanges
+        if (newExchange == null) {
+            return oldExchange;
+        }
+
+        // First time for this aggregation
+        if (oldExchange == null) {
+            try {
+                tarFile = FileUtil.createTempFile(this.filePrefix, this.fileSuffix, new File(System.getProperty("java.io.tmpdir")));
+            } catch (IOException e) {
+                throw new GenericFileOperationFailedException(e.getMessage(), e);
+            }
+            answer = newExchange;
+            answer.addOnCompletion(new DeleteTarFileOnCompletion(tarFile));
+        } else {
+            tarFile = oldExchange.getIn().getBody(File.class);
+        }
+
+        // Handle GenericFileMessages
+        if (GenericFileMessage.class.isAssignableFrom(newExchange.getIn().getClass())) {
+            try {
+                File appendFile = newExchange.getIn().getMandatoryBody(File.class);
+                if (appendFile != null) {
+                    addFileToTar(tarFile, appendFile, this.preserveFolderStructure ? newExchange.getIn().toString() : null);
+                    GenericFile<File> genericFile =
+                            FileConsumer.asGenericFile(
+                                    tarFile.getParent(),
+                                    tarFile,
+                                    null);    // Do not set charset here, that will cause the tar file to be handled as ASCII later which breaks it..
+                    genericFile.bindToExchange(answer);
+                }
+            } catch (Exception e) {
+                throw new GenericFileOperationFailedException(e.getMessage(), e);
+            }
+        } else {
+            // Handle all other messages
+            try {
+                byte[] buffer = newExchange.getIn().getMandatoryBody(byte[].class);
+                String entryName = useFilenameHeader ? newExchange.getIn().getHeader(Exchange.FILE_NAME, String.class) : newExchange.getIn()
+                        .getMessageId();
+                addEntryToTar(tarFile, entryName, buffer, buffer.length);
+                GenericFile<File> genericFile = FileConsumer.asGenericFile(
+                        tarFile.getParent(), tarFile, null);
+                genericFile.bindToExchange(answer);
+            } catch (Exception e) {
+                throw new GenericFileOperationFailedException(e.getMessage(), e);
+            }
+        }
+
+        return answer;
+    }
+
+    private static void addFileToTar(File source, File file, String fileName) throws IOException, ArchiveException {
+        File tmpTar = File.createTempFile(source.getName(), null);
+        tmpTar.delete();
+        if (!source.renameTo(tmpTar)) {
+            throw new IOException("Could not make temp file (" + source.getName() + ")");
+        }
+
+        TarArchiveInputStream tin = (TarArchiveInputStream) new ArchiveStreamFactory().createArchiveInputStream(ArchiveStreamFactory.TAR, new FileInputStream(tmpTar));
+        TarArchiveOutputStream tos = new TarArchiveOutputStream(new FileOutputStream(source));
+        tos.setLongFileMode(TarArchiveOutputStream.LONGFILE_POSIX);
+        tos.setBigNumberMode(TarArchiveOutputStream.BIGNUMBER_POSIX);
+
+        InputStream in = new FileInputStream(file);
+
+        // copy the existing entries    
+        ArchiveEntry nextEntry;
+        while ((nextEntry = tin.getNextEntry()) != null) {
+            tos.putArchiveEntry(nextEntry);
+            IOUtils.copy(tin, tos);
+            tos.closeArchiveEntry();
+        }
+
+        // Add the new entry
+        TarArchiveEntry entry = new TarArchiveEntry(fileName == null ? file.getName() : fileName);
+        entry.setSize(file.length());
+        tos.putArchiveEntry(entry);
+        IOUtils.copy(in, tos);
+        tos.closeArchiveEntry();
+
+        IOHelper.close(in);
+        IOHelper.close(tin);
+        IOHelper.close(tos);
+    }
+
+    private static void addEntryToTar(File source, String entryName, byte[] buffer, int length) throws IOException, ArchiveException {
+        File tmpTar = File.createTempFile(source.getName(), null);
+        tmpTar.delete();
+        if (!source.renameTo(tmpTar)) {
+            throw new IOException("Cannot create temp file: " + source.getName());
+        }
+        TarArchiveInputStream tin = (TarArchiveInputStream) new ArchiveStreamFactory().createArchiveInputStream(ArchiveStreamFactory.TAR, new FileInputStream(tmpTar));
+        TarArchiveOutputStream tos = new TarArchiveOutputStream(new FileOutputStream(source));
+        tos.setLongFileMode(TarArchiveOutputStream.LONGFILE_POSIX);
+        tos.setBigNumberMode(TarArchiveOutputStream.BIGNUMBER_POSIX);
+
+        // copy the existing entries    
+        ArchiveEntry nextEntry;
+        while ((nextEntry = tin.getNextEntry()) != null) {
+            tos.putArchiveEntry(nextEntry);
+            IOUtils.copy(tin, tos);
+            tos.closeArchiveEntry();
+        }
+
+        // Create new entry
+        TarArchiveEntry entry = new TarArchiveEntry(entryName);
+        entry.setSize(length);
+        tos.putArchiveEntry(entry);
+        tos.write(buffer, 0, length);
+        tos.closeArchiveEntry();
+
+        IOHelper.close(tin);
+        IOHelper.close(tos);
+    }
+
+    /**
+     * This callback class is used to clean up the temporary TAR file once the exchange has completed.
+     */
+    private class DeleteTarFileOnCompletion implements Synchronization {
+
+        private final File fileToDelete;
+
+        public DeleteTarFileOnCompletion(File fileToDelete) {
+            this.fileToDelete = fileToDelete;
+        }
+
+        @Override
+        public void onFailure(Exchange exchange) {
+            // Keep the file if something gone a miss.
+        }
+
+        @Override
+        public void onComplete(Exchange exchange) {
+            FileUtil.deleteFile(this.fileToDelete);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/2051db4b/components/camel-tarfile/src/main/resources/META-INF/LICENSE.txt
----------------------------------------------------------------------
diff --git a/components/camel-tarfile/src/main/resources/META-INF/LICENSE.txt b/components/camel-tarfile/src/main/resources/META-INF/LICENSE.txt
new file mode 100644
index 0000000..6b0b127
--- /dev/null
+++ b/components/camel-tarfile/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/2051db4b/components/camel-tarfile/src/main/resources/META-INF/NOTICE.txt
----------------------------------------------------------------------
diff --git a/components/camel-tarfile/src/main/resources/META-INF/NOTICE.txt b/components/camel-tarfile/src/main/resources/META-INF/NOTICE.txt
new file mode 100644
index 0000000..2e215bf
--- /dev/null
+++ b/components/camel-tarfile/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.

http://git-wip-us.apache.org/repos/asf/camel/blob/2051db4b/components/camel-tarfile/src/main/resources/META-INF/services/org/apache/camel/dataformat/tarfile
----------------------------------------------------------------------
diff --git a/components/camel-tarfile/src/main/resources/META-INF/services/org/apache/camel/dataformat/tarfile b/components/camel-tarfile/src/main/resources/META-INF/services/org/apache/camel/dataformat/tarfile
new file mode 100644
index 0000000..c596e72
--- /dev/null
+++ b/components/camel-tarfile/src/main/resources/META-INF/services/org/apache/camel/dataformat/tarfile
@@ -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.tarfile.TarFileDataFormat

http://git-wip-us.apache.org/repos/asf/camel/blob/2051db4b/components/camel-tarfile/src/test/java/org/apache/camel/dataformat/tarfile/SpringTarSplitterRouteTest.java
----------------------------------------------------------------------
diff --git a/components/camel-tarfile/src/test/java/org/apache/camel/dataformat/tarfile/SpringTarSplitterRouteTest.java b/components/camel-tarfile/src/test/java/org/apache/camel/dataformat/tarfile/SpringTarSplitterRouteTest.java
new file mode 100644
index 0000000..eba45de
--- /dev/null
+++ b/components/camel-tarfile/src/test/java/org/apache/camel/dataformat/tarfile/SpringTarSplitterRouteTest.java
@@ -0,0 +1,38 @@
+/**
+ * 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.tarfile;
+
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.spring.CamelSpringTestSupport;
+import org.junit.Test;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class SpringTarSplitterRouteTest extends CamelSpringTestSupport {
+
+    @Test
+    public void testSplitter() throws InterruptedException {
+        MockEndpoint processTarEntry = getMockEndpoint("mock:processTarEntry");
+        processTarEntry.expectedBodiesReceivedInAnyOrder("chau", "hi", "hola", "hello", "greetings");
+        assertMockEndpointsSatisfied();
+    }
+    
+    @Override
+    protected ClassPathXmlApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/camel/dataformat/tarfile/SpringTarSplitterRouteTest.xml");
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/2051db4b/components/camel-tarfile/src/test/java/org/apache/camel/dataformat/tarfile/TarFileDataFormatTest.java
----------------------------------------------------------------------
diff --git a/components/camel-tarfile/src/test/java/org/apache/camel/dataformat/tarfile/TarFileDataFormatTest.java b/components/camel-tarfile/src/test/java/org/apache/camel/dataformat/tarfile/TarFileDataFormatTest.java
new file mode 100644
index 0000000..39ebb4b
--- /dev/null
+++ b/components/camel-tarfile/src/test/java/org/apache/camel/dataformat/tarfile/TarFileDataFormatTest.java
@@ -0,0 +1,221 @@
+/**
+ * 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.tarfile;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.NotifyBuilder;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.util.IOHelper;
+import org.apache.camel.util.ObjectHelper;
+import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
+import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
+import org.junit.Test;
+
+import static org.apache.camel.Exchange.FILE_NAME;
+
+/**
+ * Unit tests for {@link TarFileDataFormat}.
+ */
+public class TarFileDataFormatTest extends CamelTestSupport {
+
+    private static final String TEXT = "The Masque of Queen Bersabe (excerpt) \n"
+            + "by: Algernon Charles Swinburne \n\n"
+            + "My lips kissed dumb the word of Ah \n"
+            + "Sighed on strange lips grown sick thereby. \n"
+            + "God wrought to me my royal bed; \n"
+            + "The inner work thereof was red, \n"
+            + "The outer work was ivory. \n"
+            + "My mouth's heat was the heat of flame \n"
+            + "For lust towards the kings that came \n"
+            + "With horsemen riding royally.";
+
+    private static final File TEST_DIR = new File("target/tar");
+
+    @Test
+    public void testTarWithoutFileName() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:tar");
+        mock.expectedMessageCount(1);
+
+        template.sendBody("direct:tar", TEXT);
+
+        assertMockEndpointsSatisfied();
+
+        Exchange exchange = mock.getReceivedExchanges().get(0);
+        assertEquals(exchange.getIn().getMessageId() + ".tar", exchange.getIn().getHeader(FILE_NAME));
+        assertTrue(ObjectHelper.equalByteArray(getTaredText(exchange.getIn().getMessageId()), (byte[]) exchange.getIn().getBody()));
+    }
+
+    @Test
+    public void testTarWithFileName() throws Exception {
+        getMockEndpoint("mock:tar").expectedBodiesReceived(getTaredText("poem.txt"));
+        getMockEndpoint("mock:tar").expectedHeaderReceived(FILE_NAME, "poem.txt.tar");
+
+        template.sendBodyAndHeader("direct:tar", TEXT, FILE_NAME, "poem.txt");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Test
+    public void testUntar() throws Exception {
+        getMockEndpoint("mock:untar").expectedBodiesReceived(TEXT);
+        getMockEndpoint("mock:untar").expectedHeaderReceived(FILE_NAME, "file");
+
+        template.sendBody("direct:untar", getTaredText("file"));
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Test
+    public void testTarAndUntar() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:tarAndUntar");
+        mock.expectedMessageCount(1);
+
+        template.sendBody("direct:tarAndUntar", TEXT);
+
+        assertMockEndpointsSatisfied();
+
+        Exchange exchange = mock.getReceivedExchanges().get(0);
+        assertEquals(exchange.getIn().getMessageId(), exchange.getIn().getHeader(FILE_NAME));
+        assertEquals(TEXT, new String((byte[]) exchange.getIn().getBody(), "UTF-8"));
+    }
+
+    @Test
+    public void testTarToFileWithoutFileName() throws Exception {
+        NotifyBuilder notify = new NotifyBuilder(context).whenDone(1).create();
+
+        String[] files = TEST_DIR.list();
+        assertTrue(files == null || files.length == 0);
+
+        MockEndpoint mock = getMockEndpoint("mock:intercepted");
+        mock.expectedMessageCount(1);
+
+        template.sendBody("direct:tarToFile", TEXT);
+
+        assertMockEndpointsSatisfied();
+
+        // use builder to ensure the exchange is fully done before we check for file exists
+        assertTrue(notify.matches(5, TimeUnit.SECONDS));
+
+        Exchange exchange = mock.getReceivedExchanges().get(0);
+        File file = new File(TEST_DIR, exchange.getIn().getMessageId() + ".tar");
+        assertTrue(file.exists());
+        assertTrue(ObjectHelper.equalByteArray(getTaredText(exchange.getIn().getMessageId()), getBytes(file)));
+    }
+
+    @Test
+    public void testTarToFileWithFileName() throws Exception {
+        NotifyBuilder notify = new NotifyBuilder(context).whenDone(1).create();
+
+        MockEndpoint mock = getMockEndpoint("mock:tarToFile");
+        mock.expectedMessageCount(1);
+
+        File file = new File(TEST_DIR, "poem.txt.tar");
+        assertFalse(file.exists());
+
+        template.sendBodyAndHeader("direct:tarToFile", TEXT, FILE_NAME, "poem.txt");
+
+        // just make sure the file is created
+        mock.assertIsSatisfied();
+
+        // use builder to ensure the exchange is fully done before we check for file exists
+        assertTrue(notify.matches(5, TimeUnit.SECONDS));
+
+        assertTrue(file.exists());
+        assertTrue(ObjectHelper.equalByteArray(getTaredText("poem.txt"), getBytes(file)));
+    }
+
+    @Test
+    public void testDslTar() throws Exception {
+        getMockEndpoint("mock:dslTar").expectedBodiesReceived(getTaredText("poem.txt"));
+        getMockEndpoint("mock:dslTar").expectedHeaderReceived(FILE_NAME, "poem.txt.tar");
+
+        template.sendBodyAndHeader("direct:dslTar", TEXT, FILE_NAME, "poem.txt");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Test
+    public void testDslUntar() throws Exception {
+        getMockEndpoint("mock:dslUntar").expectedBodiesReceived(TEXT);
+        getMockEndpoint("mock:dslUntar").expectedHeaderReceived(FILE_NAME, "test.txt");
+
+        template.sendBody("direct:dslUntar", getTaredText("test.txt"));
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    public void setUp() throws Exception {
+        deleteDirectory(TEST_DIR);
+        super.setUp();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                interceptSendToEndpoint("file:*").to("mock:intercepted");
+
+                TarFileDataFormat tar = new TarFileDataFormat();
+
+                from("direct:tar").marshal(tar).to("mock:tar");
+                from("direct:untar").unmarshal(tar).to("mock:untar");
+                from("direct:tarAndUntar").marshal(tar).unmarshal(tar).to("mock:tarAndUntar");
+                from("direct:tarToFile").marshal(tar).to("file:" + TEST_DIR.getPath()).to("mock:tarToFile");
+                from("direct:dslTar").marshal(tar).to("mock:dslTar");
+                from("direct:dslUntar").unmarshal(tar).to("mock:dslUntar");
+            }
+        };
+    }
+
+    private static byte[] getTaredText(String entryName) throws IOException {
+        ByteArrayInputStream bais = new ByteArrayInputStream(TEXT.getBytes("UTF-8"));
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        TarArchiveOutputStream tos = new TarArchiveOutputStream(baos);
+        try {
+            TarArchiveEntry entry = new TarArchiveEntry(entryName);
+            entry.setSize(bais.available());
+            tos.putArchiveEntry(entry);
+            IOHelper.copy(bais, tos);
+        } finally {
+            tos.closeArchiveEntry();
+            IOHelper.close(bais, tos);
+        }
+        return baos.toByteArray();
+    }
+
+    private static byte[] getBytes(File file) throws IOException {
+        FileInputStream fis = new FileInputStream(file);
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        try {
+            IOHelper.copy(fis, baos);
+        } finally {
+            IOHelper.close(fis, baos);
+        }
+        return baos.toByteArray();
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/2051db4b/components/camel-tarfile/src/test/java/org/apache/camel/dataformat/tarfile/TarFileMultipleFilesSplitterTest.java
----------------------------------------------------------------------
diff --git a/components/camel-tarfile/src/test/java/org/apache/camel/dataformat/tarfile/TarFileMultipleFilesSplitterTest.java b/components/camel-tarfile/src/test/java/org/apache/camel/dataformat/tarfile/TarFileMultipleFilesSplitterTest.java
new file mode 100644
index 0000000..51dd3c9
--- /dev/null
+++ b/components/camel-tarfile/src/test/java/org/apache/camel/dataformat/tarfile/TarFileMultipleFilesSplitterTest.java
@@ -0,0 +1,82 @@
+/**
+ * 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.tarfile;
+
+import java.util.Iterator;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.processor.aggregate.AggregationStrategy;
+import org.junit.Test;
+
+public class TarFileMultipleFilesSplitterTest extends TarSplitterRouteTest {
+    static final String PROCESSED_FILES_HEADER_NAME = "processedFiles";
+    
+    @Test
+    public void testSplitter() throws InterruptedException {
+        MockEndpoint processTarEntry = getMockEndpoint("mock:processTarEntry");
+        MockEndpoint splitResult = getMockEndpoint("mock:splitResult");
+        processTarEntry.expectedBodiesReceivedInAnyOrder("chau", "hi", "hola", "hello", "greetings");
+        splitResult.expectedBodiesReceivedInAnyOrder("chiau.txt", "hi.txt", "hola.txt", "another/hello.txt", "other/greetings.txt");
+        assertMockEndpointsSatisfied();
+    }
+    
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                // Untar file and Split it according to FileEntry
+                TarFileDataFormat tarFile = new TarFileDataFormat();
+                tarFile.setUsingIterator(true);
+                from("file:src/test/resources/org/apache/camel/dataformat/tarfile/data/?consumer.delay=1000&noop=true")
+                    .unmarshal(tarFile)
+                    .split(bodyAs(Iterator.class))
+                        .streaming()
+                        .aggregationStrategy(updateHeader())
+                        .convertBodyTo(String.class)
+                        .to("mock:processTarEntry")
+                    .end()
+                    .log("Done processing big file: ${header.CamelFileName}")
+                    .setBody().header(PROCESSED_FILES_HEADER_NAME)
+                    .split().body()
+                        .to("mock:splitResult");
+            }
+        };
+
+    }
+    
+    private AggregationStrategy updateHeader() {
+        return new AggregationStrategy() {
+            @Override
+            public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
+                if (oldExchange != null) {
+                    String processedFiles = oldExchange.getIn().getHeader(PROCESSED_FILES_HEADER_NAME, String.class);
+                    if (processedFiles == null) {
+                        processedFiles = oldExchange.getIn().getHeader(TarIterator.TARFILE_ENTRY_NAME_HEADER, String.class);
+                    }
+                    processedFiles = processedFiles + "," + newExchange.getIn().getHeader(TarIterator.TARFILE_ENTRY_NAME_HEADER, String.class);
+                    newExchange.getIn().setHeader(PROCESSED_FILES_HEADER_NAME, processedFiles);
+                }
+                return newExchange;
+            }
+            
+        };
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/2051db4b/components/camel-tarfile/src/test/java/org/apache/camel/dataformat/tarfile/TarSplitterRouteIssueTest.java
----------------------------------------------------------------------
diff --git a/components/camel-tarfile/src/test/java/org/apache/camel/dataformat/tarfile/TarSplitterRouteIssueTest.java b/components/camel-tarfile/src/test/java/org/apache/camel/dataformat/tarfile/TarSplitterRouteIssueTest.java
new file mode 100644
index 0000000..2e785ad
--- /dev/null
+++ b/components/camel-tarfile/src/test/java/org/apache/camel/dataformat/tarfile/TarSplitterRouteIssueTest.java
@@ -0,0 +1,69 @@
+/**
+ * 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.tarfile;
+
+import java.io.File;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class TarSplitterRouteIssueTest extends CamelTestSupport {
+
+    @Override
+    public void setUp() throws Exception {
+        deleteDirectory("target/tar");
+        super.setUp();
+    }
+
+    @Test
+    public void testSplitter() throws Exception {
+        getMockEndpoint("mock:entry").expectedMessageCount(3);
+
+        template.sendBody("seda:decompressFiles", new File("src/test/resources/data/tarfile3.tar"));
+
+        assertMockEndpointsSatisfied();
+    }
+    
+    @Test
+    public void testSplitterWithWrongFile() throws Exception {
+        getMockEndpoint("mock:entry").expectedMessageCount(0);
+        getMockEndpoint("mock:errors").expectedMessageCount(1);
+        //Send a file which is not exit
+        template.sendBody("seda:decompressFiles", new File("src/test/resources/data"));
+        
+        assertMockEndpointsSatisfied();
+        
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                errorHandler(deadLetterChannel("mock:errors"));
+                
+                from("seda:decompressFiles")
+                    .split(new TarSplitter()).streaming().shareUnitOfWork()
+                        .log("we are splitting")
+                        .to("mock:entry");
+                        //.to("file:target/tar/?fileName=decompressed.txt&fileExist=Append");
+            }
+        };
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/2051db4b/components/camel-tarfile/src/test/java/org/apache/camel/dataformat/tarfile/TarSplitterRouteTest.java
----------------------------------------------------------------------
diff --git a/components/camel-tarfile/src/test/java/org/apache/camel/dataformat/tarfile/TarSplitterRouteTest.java b/components/camel-tarfile/src/test/java/org/apache/camel/dataformat/tarfile/TarSplitterRouteTest.java
new file mode 100644
index 0000000..53f8d4e
--- /dev/null
+++ b/components/camel-tarfile/src/test/java/org/apache/camel/dataformat/tarfile/TarSplitterRouteTest.java
@@ -0,0 +1,51 @@
+/**
+ * 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.tarfile;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class TarSplitterRouteTest extends CamelTestSupport {
+
+    @Test
+    public void testSplitter() throws InterruptedException {
+        MockEndpoint processTarEntry = getMockEndpoint("mock:processTarEntry");
+        processTarEntry.expectedBodiesReceivedInAnyOrder("chau", "hi", "hola", "hello", "greetings");
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                // Untar file and Split it according to FileEntry
+                from("file:src/test/resources/org/apache/camel/dataformat/tarfile/data?consumer.delay=1000&noop=true")
+                    .log("Start processing big file: ${header.CamelFileName}")
+                    .split(new TarSplitter()).streaming()
+                        .to("log:entry")
+                        .convertBodyTo(String.class).to("mock:processTarEntry")
+                    .end()
+                    .log("Done processing big file: ${header.CamelFileName}");
+            }
+        };
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/2051db4b/components/camel-tarfile/src/test/java/org/apache/camel/processor/aggregate/tarfile/AggregationStrategyWithFilenameHeaderTest.java
----------------------------------------------------------------------
diff --git a/components/camel-tarfile/src/test/java/org/apache/camel/processor/aggregate/tarfile/AggregationStrategyWithFilenameHeaderTest.java b/components/camel-tarfile/src/test/java/org/apache/camel/processor/aggregate/tarfile/AggregationStrategyWithFilenameHeaderTest.java
new file mode 100644
index 0000000..84ed738
--- /dev/null
+++ b/components/camel-tarfile/src/test/java/org/apache/camel/processor/aggregate/tarfile/AggregationStrategyWithFilenameHeaderTest.java
@@ -0,0 +1,94 @@
+/**
+ * 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.processor.aggregate.tarfile;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.util.IOHelper;
+import org.apache.commons.compress.archivers.ArchiveStreamFactory;
+import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
+import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
+import org.junit.Test;
+
+public class AggregationStrategyWithFilenameHeaderTest extends CamelTestSupport {
+
+    private static final List<String> FILE_NAMES = Arrays.asList("foo", "bar");
+
+    @Override
+    public void setUp() throws Exception {
+        deleteDirectory("target/out");
+        super.setUp();
+    }
+
+    @Test
+    public void testSplitter() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:aggregateToTarEntry");
+        mock.expectedMessageCount(1);
+
+        template.setDefaultEndpointUri("direct:start");
+        template.sendBodyAndHeader("foo", Exchange.FILE_NAME, FILE_NAMES.get(0));
+        template.sendBodyAndHeader("bar", Exchange.FILE_NAME, FILE_NAMES.get(1));
+        assertMockEndpointsSatisfied();
+
+        Thread.sleep(500);
+
+        File[] files = new File("target/out").listFiles();
+        assertTrue(files != null);
+        assertTrue("Should be a file in target/out directory", files.length > 0);
+
+        File resultFile = files[0];
+
+        final TarArchiveInputStream tis = (TarArchiveInputStream)
+                new ArchiveStreamFactory().createArchiveInputStream(ArchiveStreamFactory.TAR,
+                        new BufferedInputStream(new FileInputStream(resultFile)));
+        try {
+            int fileCount = 0;
+            for (TarArchiveEntry entry = tis.getNextTarEntry(); entry != null; entry = tis.getNextTarEntry()) {
+                fileCount++;
+                assertTrue("Tar entry file name should be on of: " + FILE_NAMES, FILE_NAMES.contains(entry.getName()));
+            }
+            assertEquals("Tar file should contain " + FILE_NAMES.size() + " files", FILE_NAMES.size(), fileCount);
+        } finally {
+            IOHelper.close(tis);
+        }
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start")
+                        .aggregate(new TarAggregationStrategy(false, true))
+                        .constant(true)
+                        .completionTimeout(50)
+                            .to("file:target/out")
+                        .to("mock:aggregateToTarEntry")
+                        .log("Done processing tar file: ${header.CamelFileName}");
+            }
+        };
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/2051db4b/components/camel-tarfile/src/test/java/org/apache/camel/processor/aggregate/tarfile/AggregationStrategyWithPreservationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-tarfile/src/test/java/org/apache/camel/processor/aggregate/tarfile/AggregationStrategyWithPreservationTest.java b/components/camel-tarfile/src/test/java/org/apache/camel/processor/aggregate/tarfile/AggregationStrategyWithPreservationTest.java
new file mode 100644
index 0000000..603511b
--- /dev/null
+++ b/components/camel-tarfile/src/test/java/org/apache/camel/processor/aggregate/tarfile/AggregationStrategyWithPreservationTest.java
@@ -0,0 +1,97 @@
+/**
+ * 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.processor.aggregate.tarfile;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.util.IOHelper;
+import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
+import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
+import org.junit.Test;
+
+public class AggregationStrategyWithPreservationTest extends CamelTestSupport {
+
+    private static final int EXPECTED_NO_FILES = 5;
+
+    @Override
+    public void setUp() throws Exception {
+        deleteDirectory("target/out");
+        super.setUp();
+    }
+
+    @Test
+    public void testSplitter() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:aggregateToTarEntry");
+        mock.expectedMessageCount(1);
+
+        assertMockEndpointsSatisfied();
+
+        Thread.sleep(500);
+
+        File[] files = new File("target/out").listFiles();
+        assertTrue("Should be a file in target/out directory", files.length > 0);
+
+        File resultFile = files[0];
+        Set<String> expectedTarFiles = new HashSet<String>(Arrays.asList("another/hello.txt",
+                "other/greetings.txt",
+                "chiau.txt", "hi.txt", "hola.txt"));
+        TarArchiveInputStream tin = new TarArchiveInputStream(new FileInputStream(resultFile));
+        try {
+            int fileCount = 0;
+            for (TarArchiveEntry te = tin.getNextTarEntry(); te != null; te = tin.getNextTarEntry()) {
+                String name = te.getName();
+                if (expectedTarFiles.contains(name)) {
+                    expectedTarFiles.remove(te.getName());
+                } else {
+                    fail("Unexpected name in tarfile: " + name);
+                }
+                fileCount++;
+            }
+            assertTrue("Tar file should contains " + AggregationStrategyWithPreservationTest.EXPECTED_NO_FILES + " files",
+                    fileCount == AggregationStrategyWithPreservationTest.EXPECTED_NO_FILES);
+            assertEquals("Should have found all of the tar files in the file.", 0, expectedTarFiles.size());
+        } finally {
+            IOHelper.close(tin);
+        }
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                // Untar file and Split it according to FileEntry
+                from("file:src/test/resources/org/apache/camel/aggregate/tarfile/data?consumer.delay=1000&noop=true&recursive=true")
+                        .aggregate(new TarAggregationStrategy(true, true))
+                        .constant(true)
+                        .completionFromBatchConsumer()
+                        .eagerCheckCompletion()
+                            .to("file:target/out")
+                        .to("mock:aggregateToTarEntry")
+                        .log("Done processing tar file: ${header.CamelFileName}");
+            }
+        };
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/2051db4b/components/camel-tarfile/src/test/java/org/apache/camel/processor/aggregate/tarfile/TarAggregationStrategyTest.java
----------------------------------------------------------------------
diff --git a/components/camel-tarfile/src/test/java/org/apache/camel/processor/aggregate/tarfile/TarAggregationStrategyTest.java b/components/camel-tarfile/src/test/java/org/apache/camel/processor/aggregate/tarfile/TarAggregationStrategyTest.java
new file mode 100644
index 0000000..b0aaec7
--- /dev/null
+++ b/components/camel-tarfile/src/test/java/org/apache/camel/processor/aggregate/tarfile/TarAggregationStrategyTest.java
@@ -0,0 +1,87 @@
+/**
+ * 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.processor.aggregate.tarfile;
+
+import java.io.File;
+import java.io.FileInputStream;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.util.IOHelper;
+import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
+import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
+import org.junit.Test;
+
+public class TarAggregationStrategyTest extends CamelTestSupport {
+
+    private static final int EXPECTED_NO_FILES = 3;
+
+    @Override
+    public void setUp() throws Exception {
+        deleteDirectory("target/out");
+        super.setUp();
+    }
+
+    @Test
+    public void testSplitter() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:aggregateToTarEntry");
+        mock.expectedMessageCount(1);
+        mock.expectedHeaderReceived("foo", "bar");
+
+        assertMockEndpointsSatisfied();
+
+        Thread.sleep(500);
+
+        File[] files = new File("target/out").listFiles();
+        assertTrue(files != null);
+        assertTrue("Should be a file in target/out directory", files.length > 0);
+
+        File resultFile = files[0];
+
+        TarArchiveInputStream tin = new TarArchiveInputStream(new FileInputStream(resultFile));
+        try {
+            int fileCount = 0;
+            for (TarArchiveEntry te = tin.getNextTarEntry(); te != null; te = tin.getNextTarEntry()) {
+                fileCount = fileCount + 1;
+            }
+            assertEquals("Tar file should contains " + TarAggregationStrategyTest.EXPECTED_NO_FILES + " files", TarAggregationStrategyTest.EXPECTED_NO_FILES, fileCount);
+        } finally {
+            IOHelper.close(tin);
+        }
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                // Untar file and Split it according to FileEntry
+                from("file:src/test/resources/org/apache/camel/aggregate/tarfile/data?consumer.delay=1000&noop=true")
+                    .setHeader("foo", constant("bar"))
+                    .aggregate(new TarAggregationStrategy())
+                        .constant(true)
+                        .completionFromBatchConsumer()
+                        .eagerCheckCompletion()
+                    .to("file:target/out")
+                    .to("mock:aggregateToTarEntry")
+                    .log("Done processing tar file: ${header.CamelFileName}");
+            }
+        };
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/2051db4b/components/camel-tarfile/src/test/resources/data/tarfile3.tar
----------------------------------------------------------------------
diff --git a/components/camel-tarfile/src/test/resources/data/tarfile3.tar b/components/camel-tarfile/src/test/resources/data/tarfile3.tar
new file mode 100644
index 0000000..f0ccd9c
Binary files /dev/null and b/components/camel-tarfile/src/test/resources/data/tarfile3.tar differ

http://git-wip-us.apache.org/repos/asf/camel/blob/2051db4b/components/camel-tarfile/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/components/camel-tarfile/src/test/resources/log4j.properties b/components/camel-tarfile/src/test/resources/log4j.properties
new file mode 100644
index 0000000..5c88226
--- /dev/null
+++ b/components/camel-tarfile/src/test/resources/log4j.properties
@@ -0,0 +1,38 @@
+## ------------------------------------------------------------------------
+## 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.
+## ------------------------------------------------------------------------
+
+#
+# The logging properties used for testing.
+#
+log4j.rootLogger=INFO, file
+
+#
+# uncomment the following line to enable debugging of Camel
+#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
+
+# File appender
+log4j.appender.file=org.apache.log4j.FileAppender
+log4j.appender.file.layout=org.apache.log4j.PatternLayout
+log4j.appender.file.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+log4j.appender.file.file=target/camel-tarfile-test.log
+log4j.appender.file.append=true