[jboss-svn-commits] JBoss Common SVN: r4761 - in shrinkwrap/trunk: api/src/main/java/org/jboss/shrinkwrap/api and 10 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sat Jul 17 20:52:40 EDT 2010


Author: ALRubinger
Date: 2010-07-17 20:52:38 -0400 (Sat, 17 Jul 2010)
New Revision: 4761

Removed:
   shrinkwrap/trunk/api/src/main/java/org/jboss/shrinkwrap/api/exporter/StreamExporter.java
   shrinkwrap/trunk/extension-tar/
   shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/exporter/AbstractStreamExporterImpl.java
   shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/exporter/StreamExporterDelegateBase.java
   shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/exporter/StreamExporterTestBase.java
Modified:
   shrinkwrap/trunk/api/src/main/java/org/jboss/shrinkwrap/api/Archive.java
   shrinkwrap/trunk/api/src/main/java/org/jboss/shrinkwrap/api/exporter/ZipExporter.java
   shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/ArchiveBase.java
   shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/MemoryMapArchiveBase.java
   shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/asset/ArchiveAsset.java
   shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/container/ContainerBase.java
   shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/container/EnterpriseContainerBase.java
   shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/exporter/AbstractExporterDelegate.java
   shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/exporter/ExplodedExporterImpl.java
   shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/exporter/FutureCompletionInputStream.java
   shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/exporter/JdkZipExporterDelegate.java
   shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/exporter/ZipArchiveInputStreamFactory.java
   shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/exporter/ZipExporterImpl.java
   shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/serialization/ZipSerializableViewImpl.java
   shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/exporter/ExplodedExporterTestCase.java
   shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/exporter/ExportTestBase.java
   shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/exporter/ZipExporterStressTest.java
   shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/exporter/ZipExporterTestCase.java
   shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/importer/ZipImporterImplTestCase.java
   shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/serialization/ZipSerializableOriginalImpl.java
   shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/test/ArchiveTestBase.java
   shrinkwrap/trunk/pom.xml
Log:
[SHRINKWRAP-194][SHRINKWRAP-199] Revert all work on TAR export and the ArchiveAsset.openStream until after 1.0.0-alpha-11

Modified: shrinkwrap/trunk/api/src/main/java/org/jboss/shrinkwrap/api/Archive.java
===================================================================
--- shrinkwrap/trunk/api/src/main/java/org/jboss/shrinkwrap/api/Archive.java	2010-07-18 00:36:30 UTC (rev 4760)
+++ shrinkwrap/trunk/api/src/main/java/org/jboss/shrinkwrap/api/Archive.java	2010-07-18 00:52:38 UTC (rev 4761)
@@ -19,7 +19,6 @@
 import java.util.Map;
 
 import org.jboss.shrinkwrap.api.asset.Asset;
-import org.jboss.shrinkwrap.api.exporter.StreamExporter;
 import org.jboss.shrinkwrap.api.formatter.Formatter;
 import org.jboss.shrinkwrap.api.formatter.Formatters;
 
@@ -210,29 +209,24 @@
    Map<ArchivePath, Node> getContent(Filter<ArchivePath> filter);
 
    /**
-    * Add an archive under a specific context and maintain the archive name as 
-    * context path.
+    * Add an archive under a specific context and maintain the archive name as context path.
     * 
     * @param path to use 
     * @param archive to add
-    * @param exporter Exporter type to use in fulfilling the {@link Asset#openStream()} contract for 
-    *   the added (nested) archive.  
     * @return
-    * @throws IllegalArgumentException If any argument is not specified
+    * @throws IllegalArgumentException If the path or archive are not specified 
     */
-   T add(Archive<?> archive, ArchivePath path, Class<? extends StreamExporter> exporter) throws IllegalArgumentException;
+   T add(Archive<?> archive, ArchivePath path) throws IllegalArgumentException;
    
    /**
     * Add an archive under a specific context and maintain the archive name as context path.
     * 
     * @param path to use 
     * @param archive to add
-    * @param exporter Exporter type to use in fulfilling the {@link Asset#openStream()} contract for 
-    *   the added (nested) archive.  
     * @return
     * @throws IllegalArgumentException If the path or archive are not specified 
     */
-   T add(Archive<?> archive, String path, Class<? extends StreamExporter> exporter) throws IllegalArgumentException;
+   T add(Archive<?> archive, String path) throws IllegalArgumentException;
 
    /**
     * Merge the contents from an existing archive without 

Deleted: shrinkwrap/trunk/api/src/main/java/org/jboss/shrinkwrap/api/exporter/StreamExporter.java
===================================================================
--- shrinkwrap/trunk/api/src/main/java/org/jboss/shrinkwrap/api/exporter/StreamExporter.java	2010-07-18 00:36:30 UTC (rev 4760)
+++ shrinkwrap/trunk/api/src/main/java/org/jboss/shrinkwrap/api/exporter/StreamExporter.java	2010-07-18 00:52:38 UTC (rev 4761)
@@ -1,56 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * 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.
- */
-package org.jboss.shrinkwrap.api.exporter;
-
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import org.jboss.shrinkwrap.api.Assignable;
-
-/**
- * Generic exporter capable of representing an {@link Assignable}
- * as an {@link InputStream}, or writing its contents to
- * a provided {@link OutputStream}.
- * 
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-public interface StreamExporter extends Assignable
-{
-   //-------------------------------------------------------------------------------------||
-   // Contracts --------------------------------------------------------------------------||
-   //-------------------------------------------------------------------------------------||
-
-   /**
-    * Exports this reference in an implementation-specific
-    * format represented by the returned {@link InputStream}
-    * 
-    * @return {@link InputStream} to read the exported view
-    */
-   InputStream export();
-
-   /**
-    * Exports provided archive in an implementation-specific format, 
-    * written to the specified {@link OutputStream} target.  The specified
-    * target will be closed upon completion.
-    * 
-    * @param target
-    * @throws ArchiveExportException
-    * @throws IllegalArgumentException If the target is not specified or is closed
-    */
-   void export(OutputStream target) throws ArchiveExportException, IllegalArgumentException;
-}

Modified: shrinkwrap/trunk/api/src/main/java/org/jboss/shrinkwrap/api/exporter/ZipExporter.java
===================================================================
--- shrinkwrap/trunk/api/src/main/java/org/jboss/shrinkwrap/api/exporter/ZipExporter.java	2010-07-18 00:36:30 UTC (rev 4760)
+++ shrinkwrap/trunk/api/src/main/java/org/jboss/shrinkwrap/api/exporter/ZipExporter.java	2010-07-18 00:52:38 UTC (rev 4761)
@@ -18,6 +18,7 @@
 
 import java.io.File;
 import java.io.InputStream;
+import java.io.OutputStream;
 
 import org.jboss.shrinkwrap.api.Assignable;
 
@@ -30,13 +31,20 @@
  * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
  * @version $Revision: $
  */
-public interface ZipExporter extends StreamExporter
+public interface ZipExporter extends Assignable
 {
    //-------------------------------------------------------------------------------------||
    // Contracts --------------------------------------------------------------------------||
    //-------------------------------------------------------------------------------------||
 
    /**
+    * Exports this reference as a Zip archive.
+    * 
+    * @return {@link InputStream} for exported Zip
+    */
+   InputStream exportZip();
+
+   /**
     * Exports provided archive as a ZIP archive, written to the 
     * specified {@link File} target.  If the target exists this call will
     * fail with {@link IllegalArgumentException}
@@ -51,6 +59,17 @@
 
    /**
     * Exports provided archive as a ZIP archive, written to the 
+    * specified {@link OutputStream} target.  The specified
+    * target will be closed upon completion.
+    * 
+    * @param target
+    * @throws ArchiveExportException
+    * @throws IllegalArgumentException If the target is not specified
+    */
+   void exportZip(OutputStream target) throws ArchiveExportException, IllegalArgumentException;
+
+   /**
+    * Exports provided archive as a ZIP archive, written to the 
     * specified {@link File} target.  If the target both exists and the "overwrite"
     * flag is true, this call will allow the existing file to be overwritten, else
     * the invocation will fail with {@link IllegalArgumentException}

Modified: shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/ArchiveBase.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/ArchiveBase.java	2010-07-18 00:36:30 UTC (rev 4760)
+++ shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/ArchiveBase.java	2010-07-18 00:52:38 UTC (rev 4761)
@@ -32,7 +32,6 @@
 import org.jboss.shrinkwrap.api.Filters;
 import org.jboss.shrinkwrap.api.Node;
 import org.jboss.shrinkwrap.api.asset.Asset;
-import org.jboss.shrinkwrap.api.exporter.StreamExporter;
 import org.jboss.shrinkwrap.api.formatter.Formatter;
 import org.jboss.shrinkwrap.api.formatter.Formatters;
 import org.jboss.shrinkwrap.impl.base.asset.ArchiveAsset;
@@ -90,7 +89,8 @@
     * @param configuration The configuration for this archive
     * @throws IllegalArgumentException If the name was not specified
     */
-   protected ArchiveBase(final String name, final Configuration configuration) throws IllegalArgumentException
+   protected ArchiveBase(final String name, final Configuration configuration)
+         throws IllegalArgumentException
    {
       // Precondition checks
       Validate.notNullOrEmpty(name, "name must be specified");
@@ -173,22 +173,21 @@
 
    /**
     * {@inheritDoc}
-    * @see org.jboss.shrinkwrap.api.Archive#add(org.jboss.shrinkwrap.api.Archive, org.jboss.shrinkwrap.api.ArchivePath, java.lang.Class)
+    * @see org.jboss.shrinkwrap.api.Archive#add(org.jboss.shrinkwrap.api.ArchivePath, org.jboss.shrinkwrap.api.Archive)
     */
    @Override
-   public T add(final Archive<?> archive, final ArchivePath path, Class<? extends StreamExporter> exporter)
+   public T add(final Archive<?> archive, final ArchivePath path)
    {
       // Precondition checks
       Validate.notNull(path, "No path was specified");
       Validate.notNull(archive, "No archive was specified");
-      Validate.notNull(exporter, "No exporter was specified");
 
       // Make a Path
       final String archiveName = archive.getName();
       final ArchivePath contentPath = new BasicPath(path, archiveName);
 
       // Create ArchiveAsset 
-      final ArchiveAsset archiveAsset = new ArchiveAsset(archive,exporter);
+      ArchiveAsset archiveAsset = new ArchiveAsset(archive);
 
       // Delegate
       return add(archiveAsset, contentPath);

Modified: shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/MemoryMapArchiveBase.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/MemoryMapArchiveBase.java	2010-07-18 00:36:30 UTC (rev 4760)
+++ shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/MemoryMapArchiveBase.java	2010-07-18 00:52:38 UTC (rev 4761)
@@ -26,12 +26,11 @@
 import org.jboss.shrinkwrap.api.Archive;
 import org.jboss.shrinkwrap.api.ArchivePath;
 import org.jboss.shrinkwrap.api.ArchivePaths;
-import org.jboss.shrinkwrap.api.Configuration;
 import org.jboss.shrinkwrap.api.Filter;
 import org.jboss.shrinkwrap.api.IllegalArchivePathException;
 import org.jboss.shrinkwrap.api.Node;
+import org.jboss.shrinkwrap.api.Configuration;
 import org.jboss.shrinkwrap.api.asset.Asset;
-import org.jboss.shrinkwrap.api.exporter.StreamExporter;
 import org.jboss.shrinkwrap.impl.base.asset.ArchiveAsset;
 import org.jboss.shrinkwrap.impl.base.path.BasicPath;
 import org.jboss.shrinkwrap.impl.base.path.PathUtil;
@@ -139,37 +138,35 @@
    
    /**
     * {@inheritDoc}
-    * @see org.jboss.shrinkwrap.api.Archive#add(org.jboss.shrinkwrap.api.Archive, java.lang.String, java.lang.Class)
+    * @see org.jboss.shrinkwrap.api.Archive#add(org.jboss.shrinkwrap.api.Archive, java.lang.String)
     */
    @Override
-   public T add(final Archive<?> archive, final String path, final Class<? extends StreamExporter> exporter)
+   public T add(Archive<?> archive, String path)
    {
-      Validate.notNull(archive, "Archive must be specified");
       Validate.notNullOrEmpty(path, "Archive Path must be specified");
-      Validate.notNull(exporter, "exporter must be specified");
-      return this.add(archive, ArchivePaths.create(path), exporter);
+      return this.add(archive, ArchivePaths.create(path));
    }
 
    /**
     * {@inheritDoc}
-    * @see org.jboss.shrinkwrap.impl.base.ArchiveBase#add(org.jboss.shrinkwrap.api.Archive, org.jboss.shrinkwrap.api.ArchivePath, java.lang.Class)
+    * @see org.jboss.shrinkwrap.impl.base.ArchiveBase#add(org.jboss.shrinkwrap.api.Archive, org.jboss.shrinkwrap.api.ArchivePath)
     */
    @Override
-   public T add(final Archive<?> archive, final ArchivePath path, final Class<? extends StreamExporter> exporter)
+   public T add(Archive<?> archive, ArchivePath path)
    {
       // Add archive asset
-      super.add(archive, path, exporter);
+      super.add(archive, path);
 
       // Expected Archive Path
-      final ArchivePath archivePath = new BasicPath(path, archive.getName());
+      ArchivePath archivePath = new BasicPath(path, archive.getName());
 
       // Get the Asset that was just added 
-      final Node node = get(archivePath);
+      Node node = get(archivePath);
 
       // Make sure it is an ArchiveAsset
       if (node.getAsset() != null && node.getAsset() instanceof ArchiveAsset)
       {
-         final ArchiveAsset archiveAsset = ArchiveAsset.class.cast(node.getAsset());
+         ArchiveAsset archiveAsset = ArchiveAsset.class.cast(node.getAsset());
          // Add asset to ArchiveAsset Map
          nestedArchives.put(archivePath, archiveAsset);
       }

Modified: shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/asset/ArchiveAsset.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/asset/ArchiveAsset.java	2010-07-18 00:36:30 UTC (rev 4760)
+++ shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/asset/ArchiveAsset.java	2010-07-18 00:52:38 UTC (rev 4761)
@@ -20,16 +20,15 @@
 
 import org.jboss.shrinkwrap.api.Archive;
 import org.jboss.shrinkwrap.api.asset.Asset;
-import org.jboss.shrinkwrap.api.exporter.StreamExporter;
+import org.jboss.shrinkwrap.impl.base.ArchiveInputStreamFactory;
 import org.jboss.shrinkwrap.impl.base.Validate;
 
 /**
- * An {@link Asset} representing an {@link Archive}; a
- * specified {@link StreamExporter} type will be used to 
- * fulfill the {@link Asset#openStream()} contract.
+ * ArchiveAsset
+ * 
+ * An {@link Asset} representing an {@link Archive}
  *
  * @author <a href="mailto:baileyje at gmail.com">John Bailey</a>
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
  * @version $Revision: $
  */
 public class ArchiveAsset implements Asset
@@ -44,46 +43,34 @@
     */
    private final Archive<?> archive;
 
-   /**
-    * Exporter used to represent this archive as a {@link InputStream}
-    */
-   private final Class<? extends StreamExporter> exporter;
-
    //-------------------------------------------------------------------------------------||
    // Constructor ------------------------------------------------------------------------||
    //-------------------------------------------------------------------------------------||
 
    /**
-    * Creates a new instance wrapping the specified {@link Archive}, which
-    * will use the specified {@link StreamExporter} to represent the archive as
-    * an {@link InputStream} in {@link Asset#openStream()}.
-    * 
-    * @param archive
-    * @param exporter
-    * @throws IllegalArgumentException If either argument is not specified 
+    * Creates an ArchiveAsset with and archive and a byte array of archive contents
+    * @throws IllegalArgumentException if no archive is provided 
     */
-   public ArchiveAsset(final Archive<?> archive, final Class<? extends StreamExporter> exporter)
+   public ArchiveAsset(Archive<?> archive)
    {
       Validate.notNull(archive, "archive must be specified");
-      Validate.notNull(exporter, "exporter must be specified");
 
       this.archive = archive;
-      this.exporter = exporter;
    }
 
    //-------------------------------------------------------------------------------------||
    // Required Implementations -----------------------------------------------------------||
    //-------------------------------------------------------------------------------------||
 
-   /**
+   /*
     * {@inheritDoc}
-    * @see org.jboss.shrinkwrap.api.asset.Asset#openStream()
+    * @see org.jboss.shrinkwrap.api.Asset#getStream()
     */
    @Override
    public InputStream openStream()
    {
-      // Export via the specified exporter
-      return this.getArchive().as(this.exporter).export();
+      // Get the input stream from the ArchiveInputStreamFactory
+      return ArchiveInputStreamFactory.getInputStream(getArchive());
    }
 
    /**

Modified: shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/container/ContainerBase.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/container/ContainerBase.java	2010-07-18 00:36:30 UTC (rev 4760)
+++ shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/container/ContainerBase.java	2010-07-18 00:52:38 UTC (rev 4761)
@@ -35,8 +35,6 @@
 import org.jboss.shrinkwrap.api.container.LibraryContainer;
 import org.jboss.shrinkwrap.api.container.ManifestContainer;
 import org.jboss.shrinkwrap.api.container.ResourceContainer;
-import org.jboss.shrinkwrap.api.exporter.StreamExporter;
-import org.jboss.shrinkwrap.api.exporter.ZipExporter;
 import org.jboss.shrinkwrap.api.formatter.Formatter;
 import org.jboss.shrinkwrap.impl.base.AssignableBase;
 import org.jboss.shrinkwrap.impl.base.URLPackageScanner;
@@ -113,23 +111,22 @@
 
    /**
     * {@inheritDoc}
-    * @see org.jboss.shrinkwrap.api.Archive#add(org.jboss.shrinkwrap.api.Archive, java.lang.String, java.lang.Class)
+    * @see org.jboss.shrinkwrap.api.Archive#add(org.jboss.shrinkwrap.api.Archive, java.lang.String)
     */
    @Override
-   public T add(final Archive<?> archive, final String path, final Class<? extends StreamExporter> exporter)
+   public T add(Archive<?> archive, String path)
    {
-      this.archive.add(archive, path, exporter);
+      this.archive.add(archive, path);
       return covarientReturn();
    }
-
-   /**
-    * {@inheritDoc}
-    * @see org.jboss.shrinkwrap.api.Archive#add(org.jboss.shrinkwrap.api.Archive, org.jboss.shrinkwrap.api.ArchivePath, java.lang.Class)
+   
+   /* (non-Javadoc)
+    * @see org.jboss.shrinkwrap.api.Archive#add(org.jboss.shrinkwrap.api.Archive, org.jboss.shrinkwrap.api.Path)
     */
    @Override
-   public T add(final Archive<?> archive, final ArchivePath path, final Class<? extends StreamExporter> exporter)
+   public T add(Archive<?> archive, ArchivePath path)
    {
-      this.archive.add(archive, path, exporter);
+      this.archive.add(archive, path);
       return covarientReturn();
    }
    
@@ -1020,20 +1017,17 @@
     */
    protected abstract ArchivePath getLibraryPath();
    
-   /**
-    * {@inheritDoc}
-    * @see org.jboss.shrinkwrap.api.container.LibraryContainer#addLibrary(org.jboss.shrinkwrap.api.Archive)
+   /* (non-Javadoc)
+    * @see org.jboss.declarchive.api.container.LibraryContainer#addLibrary(org.jboss.declarchive.api.Archive)
     */
-   public T addLibrary(final Archive<?> archive) throws IllegalArgumentException
+   public T addLibrary(Archive<?> archive) throws IllegalArgumentException 
    {
       Validate.notNull(archive, "Archive must be specified");
-      // Libraries are JARs, so add as ZIP
-      return add(archive, getLibraryPath(), ZipExporter.class);
+      return add(archive, getLibraryPath());
    };
 
-   /**
-    * {@inheritDoc}
-    * @see org.jboss.shrinkwrap.api.container.LibraryContainer#addLibrary(java.lang.String)
+   /* (non-Javadoc)
+    * @see org.jboss.declarchive.api.container.LibraryContainer#addLibrary(java.lang.String)
     */
    @Override
    public T addLibrary(String resourceName) throws IllegalArgumentException
@@ -1042,8 +1036,7 @@
       return addLibrary(new ClassLoaderAsset(resourceName), resourceName);
    }
    
-   /**
-    * {@inheritDoc}
+   /* (non-Javadoc)
     * @see org.jboss.shrinkwrap.api.container.LibraryContainer#addLibrary(java.io.File)
     */
    @Override
@@ -1053,8 +1046,7 @@
       return addLibrary(new FileAsset(resource), resource.getName());
    }
    
-   /**
-    * {@inheritDoc}
+   /* (non-Javadoc)
     * @see org.jboss.shrinkwrap.api.container.LibraryContainer#addLibrary(java.lang.String, java.lang.String)
     */
    @Override
@@ -1066,8 +1058,7 @@
       return addLibrary(new ClassLoaderAsset(resourceName), target);
    }
    
-   /**
-    * {@inheritDoc}
+   /* (non-Javadoc)
     * @see org.jboss.shrinkwrap.api.container.LibraryContainer#addLibrary(java.io.File, java.lang.String)
     */
    @Override

Modified: shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/container/EnterpriseContainerBase.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/container/EnterpriseContainerBase.java	2010-07-18 00:36:30 UTC (rev 4760)
+++ shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/container/EnterpriseContainerBase.java	2010-07-18 00:52:38 UTC (rev 4761)
@@ -26,7 +26,6 @@
 import org.jboss.shrinkwrap.api.asset.FileAsset;
 import org.jboss.shrinkwrap.api.asset.UrlAsset;
 import org.jboss.shrinkwrap.api.container.EnterpriseContainer;
-import org.jboss.shrinkwrap.api.exporter.ZipExporter;
 import org.jboss.shrinkwrap.impl.base.Validate;
 import org.jboss.shrinkwrap.impl.base.asset.AssetUtil;
 import org.jboss.shrinkwrap.impl.base.asset.ClassLoaderAsset;
@@ -301,22 +300,19 @@
     */
    protected abstract ArchivePath getModulePath();
    
-   /**
-    * {@inheritDoc}
-    * @see org.jboss.shrinkwrap.api.container.EnterpriseContainer#addModule(org.jboss.shrinkwrap.api.Archive)
+   /* (non-Javadoc)
+    * @see org.jboss.declarchive.api.container.EnterpriseContainer#addModule(org.jboss.declarchive.api.Archive)
     */
    @Override
-   public T addModule(final Archive<?> archive) throws IllegalArgumentException
+   public T addModule(Archive<?> archive) throws IllegalArgumentException
    {
       Validate.notNull(archive, "Archive must be specified");
       
-      // Add as ZIP, as JARs are :)
-      return add(archive, getModulePath(),ZipExporter.class);
+      return add(archive, getModulePath());
    }
    
-   /**
-    * {@inheritDoc}
-    * @see org.jboss.shrinkwrap.api.container.EnterpriseContainer#addModule(java.lang.String)
+   /* (non-Javadoc)
+    * @see org.jboss.declarchive.api.container.EnterpriseContainer#addModule(java.lang.String)
     */
    @Override
    public T addModule(String resourceName)

Modified: shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/exporter/AbstractExporterDelegate.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/exporter/AbstractExporterDelegate.java	2010-07-18 00:36:30 UTC (rev 4760)
+++ shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/exporter/AbstractExporterDelegate.java	2010-07-18 00:52:38 UTC (rev 4761)
@@ -66,52 +66,39 @@
       super();
       this.archive = archive;
    }
-   
-   /**
-    * Runs the export operation, returning the result
-    * @return
-    */
-   public final T export()
-   {
-      // Perform the actual export
-      this.doExport();
 
-      // Return the result
-      return this.getResult();
-   }
-
    /**
     * Primary method providing a template for exporting the contents of an archive
     */
-   protected void doExport()
+   protected void export()
    {
       // Get archive
-      final Archive<?> archive = getArchive();
+      Archive<?> archive = getArchive();
       if (log.isLoggable(Level.FINE))
       {
          log.fine("Exporting archive - " + archive.getName());
       }
 
-      // Obtain the root
-      final Node rootNode = archive.get(ArchivePaths.root());
-
-      // Recursively process the root children
-      for (Node child : rootNode.getChildren())
+      // Obtain all content
+      final Node rootNode = archive.get(ArchivePaths.create("/"));
+      
+      // recursively process the node childs
+      for (Node child : rootNode.getChildren()) 
       {
          processNode(child);
       }
    }
-
+   
    /**
     * Recursive call to process all the node hierarchy
     * @param node
     */
-   private void processNode(final Node node)
+   protected void processNode(final Node node) 
    {
       processNode(node.getPath(), node);
-
+      
       Set<Node> children = node.getChildren();
-      for (Node child : children)
+      for (Node child : children) 
       {
          processNode(child);
       }

Deleted: shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/exporter/AbstractStreamExporterImpl.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/exporter/AbstractStreamExporterImpl.java	2010-07-18 00:36:30 UTC (rev 4760)
+++ shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/exporter/AbstractStreamExporterImpl.java	2010-07-18 00:52:38 UTC (rev 4761)
@@ -1,113 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * 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.
- */
-package org.jboss.shrinkwrap.impl.base.exporter;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.OutputStream;
-
-import org.jboss.shrinkwrap.api.Archive;
-import org.jboss.shrinkwrap.api.exporter.ArchiveExportException;
-import org.jboss.shrinkwrap.api.exporter.FileExistsException;
-import org.jboss.shrinkwrap.impl.base.AssignableBase;
-import org.jboss.shrinkwrap.impl.base.Validate;
-
-/**
- * Base support for I/O Stream-based exporters
- * 
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- */
-public abstract class AbstractStreamExporterImpl extends AssignableBase
-{
-   
-   //-------------------------------------------------------------------------------------||
-   // Instance Members -------------------------------------------------------------------||
-   //-------------------------------------------------------------------------------------||
-
-   /**
-    * Archive to import into. 
-    */
-   private final Archive<?> archive;
-   
-   //-------------------------------------------------------------------------------------||
-   // Constructor ------------------------------------------------------------------------||
-   //-------------------------------------------------------------------------------------||
-   
-   public AbstractStreamExporterImpl(final Archive<?> archive)
-   {
-      Validate.notNull(archive, "Archive must be specified");
-      this.archive = archive;
-   }
-   
-   //-------------------------------------------------------------------------------------||
-   // Required Implementations -----------------------------------------------------------||
-   //-------------------------------------------------------------------------------------||
-   
-   /**
-    * {@inheritDoc}
-    * @see org.jboss.shrinkwrap.impl.base.AssignableBase#getArchive()
-    */
-   @Override
-   protected Archive<?> getArchive()
-   {
-      return archive;
-   }
-   
-   //-------------------------------------------------------------------------------------||
-   // Functional Methods -----------------------------------------------------------------||
-   //-------------------------------------------------------------------------------------||
-
-   /**
-    * Obtains an {@link OuputStream} to the provided {@link File}.
-    * @param target
-    * @param overwrite Whether we may overwrite an existing file
-    * @return
-    * @throws FileExistsException If the specified file exists and the overwrite flag is false
-    * @throws IllegalArgumentException If the file target is not specified
-    */
-   protected final OutputStream getOutputStreamToFile(final File target, final boolean overwrite)
-         throws FileExistsException, IllegalArgumentException
-   {
-      // Precondition checks
-      if (target == null)
-      {
-         throw new IllegalArgumentException("Target file must be specified");
-      }
-      // If target exists and we're not allowed to overwrite it
-      if (target.exists() && !overwrite)
-      {
-         throw new FileExistsException("Target exists and we haven't been flagged to overwrite it: "
-               + target.getAbsolutePath());
-      }
-
-      // Get Stream
-      final OutputStream out;
-      try
-      {
-         out = new FileOutputStream(target);
-      }
-      catch (final FileNotFoundException e)
-      {
-         throw new ArchiveExportException("File could not be created: " + target);
-      }
-
-      // Return
-      return out;
-   }
-
-}

Modified: shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/exporter/ExplodedExporterImpl.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/exporter/ExplodedExporterImpl.java	2010-07-18 00:36:30 UTC (rev 4760)
+++ shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/exporter/ExplodedExporterImpl.java	2010-07-18 00:52:38 UTC (rev 4761)
@@ -78,12 +78,11 @@
    // Required Implementations - ExplodedExporter ----------------------------------------||
    //-------------------------------------------------------------------------------------||
 
-   /**
-    * {@inheritDoc}
+   /* (non-Javadoc)
     * @see org.jboss.shrinkwrap.api.exporter.ExplodedExporter#exportExploded(java.io.File)
     */
    @Override
-   public File exportExploded(final File baseDirectory)
+   public File exportExploded(File baseDirectory)
    {
       Validate.notNull(archive, "No archive provided");
       Validate.notNull(baseDirectory, "No baseDirectory provided");
@@ -100,10 +99,13 @@
       }
 
       // Get the export delegate
-      final ExplodedExporterDelegate exporterDelegate = new ExplodedExporterDelegate(archive, baseDirectory);
+      ExplodedExporterDelegate exporterDelegate = new ExplodedExporterDelegate(archive, baseDirectory);
+
+      // Run the export
+      exporterDelegate.export();
       
-      // Run the export and get the result
-      final File explodedDirectory = exporterDelegate.export();
+      // Get Result
+      File explodedDirectory = exporterDelegate.getResult();
 
       if (log.isLoggable(Level.FINE))
       {

Modified: shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/exporter/FutureCompletionInputStream.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/exporter/FutureCompletionInputStream.java	2010-07-18 00:36:30 UTC (rev 4760)
+++ shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/exporter/FutureCompletionInputStream.java	2010-07-18 00:52:38 UTC (rev 4761)
@@ -33,7 +33,7 @@
  * @param <T> Response type of the {@link Future}
  * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
  */
-public class FutureCompletionInputStream extends PipedInputStream
+class FutureCompletionInputStream extends PipedInputStream
 {
 
    //-------------------------------------------------------------------------------------||

Modified: shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/exporter/JdkZipExporterDelegate.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/exporter/JdkZipExporterDelegate.java	2010-07-18 00:36:30 UTC (rev 4760)
+++ shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/exporter/JdkZipExporterDelegate.java	2010-07-18 00:52:38 UTC (rev 4761)
@@ -17,17 +17,32 @@
 package org.jboss.shrinkwrap.impl.base.exporter;
 
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.OutputStream;
+import java.io.PipedOutputStream;
+import java.util.HashSet;
 import java.util.Set;
 import java.util.concurrent.Callable;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.zip.ZipEntry;
+import java.util.zip.ZipException;
 import java.util.zip.ZipOutputStream;
 
 import org.jboss.shrinkwrap.api.Archive;
 import org.jboss.shrinkwrap.api.ArchivePath;
+import org.jboss.shrinkwrap.api.Node;
 import org.jboss.shrinkwrap.api.asset.Asset;
+import org.jboss.shrinkwrap.api.exporter.ArchiveExportException;
+import org.jboss.shrinkwrap.impl.base.io.IOUtil;
+import org.jboss.shrinkwrap.impl.base.io.StreamErrorHandler;
+import org.jboss.shrinkwrap.impl.base.io.StreamTask;
+import org.jboss.shrinkwrap.impl.base.path.PathUtil;
+import org.jboss.shrinkwrap.spi.Configurable;
 
 /**
  * JDK-based implementation of a ZIP exporter.  Cannot handle archives
@@ -37,7 +52,7 @@
  * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
  * @version $Revision: $
  */
-public class JdkZipExporterDelegate extends StreamExporterDelegateBase<ZipOutputStream>
+public class JdkZipExporterDelegate extends AbstractExporterDelegate<InputStream>
 {
    //-------------------------------------------------------------------------------------||
    // Class Members ----------------------------------------------------------------------||
@@ -49,11 +64,35 @@
    private static final Logger log = Logger.getLogger(JdkZipExporterDelegate.class.getName());
 
    //-------------------------------------------------------------------------------------||
+   // Instance Members -------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * ZipOutputStream used to write the zip entries
+    */
+   private ZipOutputStream zipOutputStream;
+
+   /**
+    * {@link InputStream} to be returned to the caller
+    */
+   private InputStream inputStream;
+
+   /**
+    * Used to see if we have exported at least one node
+    */
+   private Set<ArchivePath> pathsExported = new HashSet<ArchivePath>();
+
+   /**
+    * Synchronization point where the encoding process will wait until all streams have been set up
+    */
+   private final CountDownLatch latch = new CountDownLatch(1);
+
+   //-------------------------------------------------------------------------------------||
    // Constructor ------------------------------------------------------------------------||
    //-------------------------------------------------------------------------------------||
 
    /**
-    * Creates a new exporter delegate for exporting archives as ZIP
+    * Creates a new exporter delegate for exporting archives as Zip
     * 
     * @throws IllegalArgumentException If the archive has no {@link Asset}s; JDK ZIP
     * handling cannot support writing out to a {@link ZipOutputStream} with no
@@ -78,46 +117,13 @@
 
    /**
     * {@inheritDoc}
-    * @see org.jboss.shrinkwrap.impl.base.exporter.StreamExporterDelegateBase#closeEntry(java.io.OutputStream)
+    * @see org.jboss.shrinkwrap.impl.base.exporter.AbstractExporterDelegate#export()
     */
-   @Override
-   protected final void closeEntry(final ZipOutputStream outputStream) throws IOException
+   protected void export()
    {
-      // Close the entry
-      outputStream.closeEntry();
-   }
 
-   /**
-    * {@inheritDoc}
-    * @see org.jboss.shrinkwrap.impl.base.exporter.StreamExporterDelegateBase#createOutputStream(java.io.OutputStream)
-    */
-   @Override
-   protected final ZipOutputStream createOutputStream(final OutputStream out) throws IOException
-   {
-      // Create and return
-      return new ZipOutputStream(out);
-   }
-
-   /**
-    * {@inheritDoc}
-    * @see org.jboss.shrinkwrap.impl.base.exporter.StreamExporterDelegateBase#putNextExtry(java.io.OutputStream, java.lang.String)
-    */
-   @Override
-   protected final void putNextExtry(final ZipOutputStream outputStream, final String context) throws IOException
-   {
-      // Put
-      outputStream.putNextEntry(new ZipEntry(context));
-   }
-
-   /**
-    * {@inheritDoc}
-    * @see org.jboss.shrinkwrap.impl.base.exporter.StreamExporterDelegateBase#getExportTask()
-    */
-   @Override
-   protected Callable<Void> getExportTask(final Callable<Void> wrappedTask)
-   {
-      assert wrappedTask != null : "Wrapped task must be specified";
-      return new Callable<Void>()
+      // Define the task to operate in another Thread so we can pipe the output to an InStream
+      final Callable<Void> exportTask = new Callable<Void>()
       {
 
          @Override
@@ -125,8 +131,7 @@
          {
             try
             {
-               // Attempt the wrapped task
-               wrappedTask.call();
+               JdkZipExporterDelegate.super.export();
             }
             catch (final Exception e)
             {
@@ -135,8 +140,7 @@
                // be able to get the underlying cause from the Future 
                log.log(Level.WARNING, "Exception encountered during export of archive", e);
 
-               // SHRINKWRAP-133 - if the output is empty, it won't close and a deadlock is triggered
-               final Set<ArchivePath> pathsExported = JdkZipExporterDelegate.this.getExportedPaths();
+               // SHRINKWRAP-133 - if the Zip is empty, it won't close and a deadlock is triggered
                if (pathsExported.isEmpty())
                {
                   // Ensure the streams are set up before we do any work on them;
@@ -145,8 +149,7 @@
                   // SHRINKWRAP-137
                   latch.await();
 
-                  // Write a dummy entry just so the JDK ZIP impl can close cleanly
-                  putNextExtry(outputStream, "dummy.txt");
+                  zipOutputStream.putNextEntry(new ZipEntry("dummy.txt"));
                }
 
                throw e;
@@ -156,7 +159,7 @@
 
                try
                {
-                  outputStream.close();
+                  zipOutputStream.close();
                }
                catch (final IOException ioe)
                {
@@ -170,5 +173,156 @@
             return null;
          }
       };
+
+      // Get an ExecutorService to which we may submit jobs.  This is either supplied by the user
+      // in a custom domain, or if one has not been specified, we'll make one and shut it down right
+      // here.  ExecutorServices supplied by the user are under the user's lifecycle, therefore it's
+      // user responsibility to shut it down appropriately.
+      boolean executorServiceIsOurs = false;
+      ExecutorService service = this.getArchive().as(Configurable.class).getConfiguration().getExecutorService();
+      if (service == null)
+      {
+         service = Executors.newSingleThreadExecutor();
+         executorServiceIsOurs = true;
+      }
+
+      // Get a handle and return it to the caller
+      final Future<Void> job = service.submit(exportTask);
+
+      // If we've created the ES
+      if (executorServiceIsOurs)
+      {
+         // Tell the service to shut down after the job has completed, and accept no new jobs
+         service.shutdown();
+      }
+
+      /*
+       * At this point the job will start, but hit the latch until we set up the streams
+       * and tell it to proceed.
+       */
+
+      // Stream to return to the caller
+      final FutureCompletionInputStream input = new FutureCompletionInputStream(job);
+      inputStream = input;
+
+      /**
+       * OutputStream which will be associated with the returned InStream, and the 
+       * chained IO point for the Zip OutStrea,
+       */
+      final OutputStream output;
+      try
+      {
+         output = new PipedOutputStream(input);
+      }
+      catch (final IOException e)
+      {
+         throw new RuntimeException("Error in setting up output stream", e);
+      }
+
+      // Set up the stream to which we'll write entries, backed by the piped stream
+      zipOutputStream = new ZipOutputStream(output);
+
+      /*
+       * The job is now waiting on us to signal that we've set up the streams; 
+       * let it continue
+       */
+      latch.countDown();
    }
+
+   /**
+    * {@inheritDoc}
+    * @see org.jboss.shrinkwrap.impl.base.exporter.AbstractExporterDelegate#processNode(ArchivePath, Node)
+    */
+   @Override
+   protected void processNode(final ArchivePath path, final Node node)
+   {
+      // Precondition checks
+      if (path == null)
+      {
+         throw new IllegalArgumentException("Path must be specified");
+      }
+      if (node == null)
+      {
+         throw new IllegalArgumentException("asset must be specified");
+      }
+
+      // Mark if we're writing a directory
+      final boolean isDirectory = node.getAsset() == null;
+
+      InputStream stream = null;
+      if (!isDirectory)
+      {
+         stream = node.getAsset().openStream();
+      }
+
+      final String pathName = PathUtil.optionallyRemovePrecedingSlash(path.get());
+
+      // Make a task for this stream and close when done
+      IOUtil.closeOnComplete(stream, new StreamTask<InputStream>()
+      {
+
+         @Override
+         public void execute(InputStream stream) throws Exception
+         {
+            String resolvedPath = pathName;
+            if (isDirectory)
+            {
+               resolvedPath = PathUtil.optionallyAppendSlash(resolvedPath);
+            }
+
+            // Make a ZipEntry
+            final ZipEntry entry = new ZipEntry(resolvedPath);
+
+            /*
+             * Wait until all streams have been set up for encoding, or
+             * do nothing if everything's set up already
+             */
+            latch.await();
+
+            // Write the Asset under the same Path name in the Zip
+            try
+            {
+               zipOutputStream.putNextEntry(entry);
+            }
+            catch (final ZipException ze)
+            {
+               log.log(Level.SEVERE, pathsExported.toString());
+               throw new RuntimeException(ze);
+            }
+
+            // Mark that we've written this Path 
+            pathsExported.add(path);
+
+            // Read the contents of the asset and write to the JAR, 
+            // if we're not just a directory
+            if (!isDirectory)
+            {
+               IOUtil.copy(stream, zipOutputStream);
+            }
+
+            // Close up the instream and the entry
+            zipOutputStream.closeEntry();
+         }
+
+      }, new StreamErrorHandler()
+      {
+
+         @Override
+         public void handle(Throwable t)
+         {
+            throw new ArchiveExportException("Failed to write asset to Zip: " + path.get(), t);
+         }
+
+      });
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.shrinkwrap.impl.base.exporter.AbstractExporterDelegate#getResult()
+    */
+   @Override
+   protected InputStream getResult()
+   {
+      return inputStream;
+   }
+
 }

Deleted: shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/exporter/StreamExporterDelegateBase.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/exporter/StreamExporterDelegateBase.java	2010-07-18 00:36:30 UTC (rev 4760)
+++ shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/exporter/StreamExporterDelegateBase.java	2010-07-18 00:52:38 UTC (rev 4761)
@@ -1,321 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * 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.
- */
-package org.jboss.shrinkwrap.impl.base.exporter;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.PipedOutputStream;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.concurrent.Callable;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.jboss.shrinkwrap.api.Archive;
-import org.jboss.shrinkwrap.api.ArchivePath;
-import org.jboss.shrinkwrap.api.Node;
-import org.jboss.shrinkwrap.api.exporter.ArchiveExportException;
-import org.jboss.shrinkwrap.impl.base.io.IOUtil;
-import org.jboss.shrinkwrap.impl.base.io.StreamErrorHandler;
-import org.jboss.shrinkwrap.impl.base.io.StreamTask;
-import org.jboss.shrinkwrap.impl.base.path.PathUtil;
-import org.jboss.shrinkwrap.spi.Configurable;
-
-/**
- * Base for exporters capable of writing to some implementation
- * of {@link OutputStream}
- * 
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-public abstract class StreamExporterDelegateBase<O extends OutputStream> extends AbstractExporterDelegate<InputStream>
-{
-   //-------------------------------------------------------------------------------------||
-   // Class Members ----------------------------------------------------------------------||
-   //-------------------------------------------------------------------------------------||
-
-   /**
-    * Logger
-    */
-   private static final Logger log = Logger.getLogger(StreamExporterDelegateBase.class.getName());
-
-   //-------------------------------------------------------------------------------------||
-   // Instance Members -------------------------------------------------------------------||
-   //-------------------------------------------------------------------------------------||
-
-   /**
-    * {@link OutputStream} used to write the individual entries
-    */
-   protected O outputStream;
-
-   /**
-    * {@link InputStream} to be returned to the caller
-    */
-   private InputStream inputStream;
-
-   /**
-    * Used to see if we have exported at least one node
-    */
-   private Set<ArchivePath> pathsExported = new HashSet<ArchivePath>();
-
-   /**
-    * Synchronization point where the encoding process will wait until all streams have been set up
-    */
-   protected final CountDownLatch latch = new CountDownLatch(1);
-
-   //-------------------------------------------------------------------------------------||
-   // Constructor ------------------------------------------------------------------------||
-   //-------------------------------------------------------------------------------------||
-
-   /**
-    * Creates a new exporter delegate for exporting archives
-    */
-   public StreamExporterDelegateBase(final Archive<?> archive) throws IllegalArgumentException
-   {
-      // Delegate to super
-      super(archive);
-   }
-
-   //-------------------------------------------------------------------------------------||
-   // Required Implementations -----------------------------------------------------------||
-   //-------------------------------------------------------------------------------------||
-
-   /**
-    * Returns the task used to run the export operation in another Thread.  Exposed
-    * such that the specified task (which handles the export) may be wrapped in some 
-    * error handling logic specific to the export process. 
-    * @param wrappedTask The export task to be wrapped in more specific handling logic
-    */
-   protected abstract Callable<Void> getExportTask(Callable<Void> wrappedTask);
-
-   /**
-    * {@inheritDoc}
-    * @see org.jboss.shrinkwrap.impl.base.exporter.AbstractExporterDelegate#doExport()
-    */
-   protected void doExport()
-   {
-      // Define the task to operate in another Thread so we can pipe the output to an InStream
-      final Callable<Void> exportTask = this.getExportTask(new Callable<Void>()
-      {
-
-         // Wrapped task is the super implementation
-         @Override
-         public Void call() throws Exception
-         {
-            StreamExporterDelegateBase.super.doExport();
-            return null;
-         }
-
-      });
-
-      // Get an ExecutorService to which we may submit jobs.  This is either supplied by the user
-      // in a custom domain, or if one has not been specified, we'll make one and shut it down right
-      // here.  ExecutorServices supplied by the user are under the user's lifecycle, therefore it's
-      // user responsibility to shut it down appropriately.
-      boolean executorServiceIsOurs = false;
-      ExecutorService service = this.getArchive().as(Configurable.class).getConfiguration().getExecutorService();
-      if (service == null)
-      {
-         service = Executors.newSingleThreadExecutor();
-         executorServiceIsOurs = true;
-      }
-
-      // Get a handle and return it to the caller
-      final Future<Void> job = service.submit(exportTask);
-
-      // If we've created the ES
-      if (executorServiceIsOurs)
-      {
-         // Tell the service to shut down after the job has completed, and accept no new jobs
-         service.shutdown();
-      }
-
-      /*
-       * At this point the job will start, but hit the latch until we set up the streams
-       * and tell it to proceed.
-       */
-
-      // Stream to return to the caller
-      final FutureCompletionInputStream input = new FutureCompletionInputStream(job);
-      inputStream = input;
-
-      /**
-       * OutputStream which will be associated with the returned InStream, and the 
-       * chained IO point for the final OutStream
-       */
-      final OutputStream output;
-      try
-      {
-         output = new PipedOutputStream(input);
-      }
-      catch (final IOException e)
-      {
-         throw new RuntimeException("Error in setting up output stream", e);
-      }
-
-      // Set up the stream to which we'll write entries, backed by the piped stream
-      try
-      {
-         outputStream = StreamExporterDelegateBase.this.createOutputStream(output);
-      }
-      catch (final IOException e)
-      {
-         throw new ArchiveExportException("Could not create the underlying stream to export: "
-               + this.getArchive().toString(), e);
-      }
-
-      /*
-       * The job is now waiting on us to signal that we've set up the streams; 
-       * let it continue
-       */
-      latch.countDown();
-   }
-
-   /**
-    * Writes the next entry (demarcates a new file/folder
-    * is to be written)
-    * @param outputStream
-    * @param context
-    * @throws IOException If an error occurred writing the entry
-    */
-   protected abstract void putNextExtry(O outputStream, String context) throws IOException;
-
-   /**
-    * Closes the current entry context for the specified {@link OutputStream}
-    * @param outputStream
-    */
-   protected abstract void closeEntry(O outputStream) throws IOException;
-
-   /**
-    * Creates the real {@link OutputStream} to which we'll write, 
-    * wrapping the provided target.
-    * @param out
-    * @return
-    * @throws IOException If an error occurred in creating the stream
-    */
-   protected abstract O createOutputStream(OutputStream out) throws IOException;
-
-   /**
-    * {@inheritDoc}
-    * @see org.jboss.shrinkwrap.impl.base.exporter.AbstractExporterDelegate#processNode(ArchivePath, Node)
-    */
-   @Override
-   protected void processNode(final ArchivePath path, final Node node)
-   {
-      // Precondition checks
-      if (path == null)
-      {
-         throw new IllegalArgumentException("Path must be specified");
-      }
-      if (node == null)
-      {
-         throw new IllegalArgumentException("asset must be specified");
-      }
-
-      // Mark if we're writing a directory
-      final boolean isDirectory = node.getAsset() == null;
-
-      InputStream stream = null;
-      if (!isDirectory)
-      {
-         stream = node.getAsset().openStream();
-      }
-
-      final String pathName = PathUtil.optionallyRemovePrecedingSlash(path.get());
-
-      // Make a task for this stream and close when done
-      IOUtil.closeOnComplete(stream, new StreamTask<InputStream>()
-      {
-
-         @Override
-         public void execute(final InputStream stream) throws Exception
-         {
-            String resolvedPath = pathName;
-            if (isDirectory)
-            {
-               resolvedPath = PathUtil.optionallyAppendSlash(resolvedPath);
-            }
-
-            /*
-             * Wait until all streams have been set up for encoding, or
-             * do nothing if everything's set up already
-             */
-            latch.await();
-
-            // Write the Asset under the same Path name in the output
-            try
-            {
-               putNextExtry(outputStream, resolvedPath);
-            }
-            catch (final IOException ze)
-            {
-               log.log(Level.SEVERE, pathsExported.toString());
-               throw new RuntimeException(ze);
-            }
-
-            // Mark that we've written this Path 
-            pathsExported.add(path);
-
-            // Read the contents of the asset and write to the JAR, 
-            // if we're not just a directory
-            if (!isDirectory)
-            {
-               IOUtil.copy(stream, outputStream);
-            }
-
-            // Close up the instream and the entry
-            StreamExporterDelegateBase.this.closeEntry(outputStream);
-         }
-
-      }, new StreamErrorHandler()
-      {
-
-         @Override
-         public void handle(Throwable t)
-         {
-            throw new ArchiveExportException("Failed to write asset to output: " + path.get(), t);
-         }
-
-      });
-   }
-
-   /**
-    * {@inheritDoc}
-    * @see org.jboss.shrinkwrap.impl.base.exporter.AbstractExporterDelegate#getResult()
-    */
-   @Override
-   protected InputStream getResult()
-   {
-      return inputStream;
-   }
-
-   /**
-    * Returns an immutable view of all {@link ArchivePath}s currently exported
-    * @return
-    */
-   protected final Set<ArchivePath> getExportedPaths()
-   {
-      return Collections.unmodifiableSet(this.pathsExported);
-   }
-
-}

Modified: shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/exporter/ZipArchiveInputStreamFactory.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/exporter/ZipArchiveInputStreamFactory.java	2010-07-18 00:36:30 UTC (rev 4760)
+++ shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/exporter/ZipArchiveInputStreamFactory.java	2010-07-18 00:52:38 UTC (rev 4761)
@@ -45,7 +45,7 @@
    protected InputStream doGetInputStream(Archive<?> archive)
    {
       // Get InputStream from the ZipExporter
-      final InputStream inputStream = archive.as(ZipExporter.class).export();
+      final InputStream inputStream = archive.as(ZipExporter.class).exportZip();
       // Return input stream
       return inputStream;
    }

Modified: shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/exporter/ZipExporterImpl.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/exporter/ZipExporterImpl.java	2010-07-18 00:36:30 UTC (rev 4760)
+++ shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/exporter/ZipExporterImpl.java	2010-07-18 00:52:38 UTC (rev 4761)
@@ -17,6 +17,8 @@
 package org.jboss.shrinkwrap.impl.base.exporter;
 
 import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -26,6 +28,8 @@
 import org.jboss.shrinkwrap.api.exporter.ArchiveExportException;
 import org.jboss.shrinkwrap.api.exporter.FileExistsException;
 import org.jboss.shrinkwrap.api.exporter.ZipExporter;
+import org.jboss.shrinkwrap.impl.base.AssignableBase;
+import org.jboss.shrinkwrap.impl.base.Validate;
 import org.jboss.shrinkwrap.impl.base.io.IOUtil;
 
 /**
@@ -36,7 +40,7 @@
  * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
  * @version $Revision: $
  */
-public class ZipExporterImpl extends AbstractStreamExporterImpl implements ZipExporter
+public class ZipExporterImpl extends AssignableBase implements ZipExporter
 {
 
    //-------------------------------------------------------------------------------------||
@@ -46,42 +50,64 @@
    /**
     * Logger
     */
-   @SuppressWarnings("unused")
    private static final Logger log = Logger.getLogger(ZipExporterImpl.class.getName());
 
+   /**
+    * Archive to import into. 
+    */
+   private Archive<?> archive;
+
    //-------------------------------------------------------------------------------------||
    // Constructor ------------------------------------------------------------------------||
    //-------------------------------------------------------------------------------------||
 
    public ZipExporterImpl(final Archive<?> archive)
    {
-      super(archive);
+      Validate.notNull(archive, "Archive must be specified");
+      this.archive = archive;
    }
 
    //-------------------------------------------------------------------------------------||
+   // Required Implementations -----------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /* (non-Javadoc)
+    * @see org.jboss.shrinkwrap.impl.base.SpecializedBase#getArchive()
+    */
+   @Override
+   protected Archive<?> getArchive()
+   {
+      return archive;
+   }
+
+   //-------------------------------------------------------------------------------------||
    // Required Implementations - ZipExporter ---------------------------------------------||
    //-------------------------------------------------------------------------------------||
 
    /**
     * {@inheritDoc}
-    * @see org.jboss.shrinkwrap.api.exporter.StreamExporter#export()
+    * @see org.jboss.shrinkwrap.api.exporter.ZipExporter#exportZip()
     */
    @Override
-   public InputStream export()
+   public InputStream exportZip()
    {
       // Create export delegate
-      AbstractExporterDelegate<InputStream> exportDelegate = new JdkZipExporterDelegate(this.getArchive());
+      AbstractExporterDelegate<InputStream> exportDelegate = new JdkZipExporterDelegate(archive);
 
-      // Export and get result
-      return exportDelegate.export();
+      // Execute export
+      exportDelegate.export();
+      // Get results
+      InputStream stream = exportDelegate.getResult();
+
+      // Return 
+      return stream;
    }
 
    /**
-    * {@inheritDoc}
-    * @see org.jboss.shrinkwrap.api.exporter.StreamExporter#export(java.io.OutputStream)
+    * @see org.jboss.shrinkwrap.api.exporter.ZipExporter#exportZip(java.io.OutputStream)
     */
    @Override
-   public void export(final OutputStream target) throws ArchiveExportException, IllegalArgumentException
+   public void exportZip(final OutputStream target) throws ArchiveExportException, IllegalArgumentException
    {
       // Precondition checks
       if (target == null)
@@ -90,7 +116,7 @@
       }
 
       // Get Stream
-      final InputStream in = this.export();
+      final InputStream in = this.exportZip();
 
       // Write out
       try
@@ -111,11 +137,31 @@
    public void exportZip(final File target, final boolean overwrite) throws ArchiveExportException,
          FileExistsException, IllegalArgumentException
    {
-      // Get stream and perform precondition checks
-      final OutputStream out = this.getOutputStreamToFile(target, overwrite);
+      // Precondition checks
+      if (target == null)
+      {
+         throw new IllegalArgumentException("Target file must be specified");
+      }
+      // If target exists and we're not allowed to overwrite it
+      if (target.exists() && !overwrite)
+      {
+         throw new FileExistsException("Target exists and we haven't been flagged to overwrite it: "
+               + target.getAbsolutePath());
+      }
 
+      // Get Stream
+      final OutputStream out;
+      try
+      {
+         out = new FileOutputStream(target);
+      }
+      catch (final FileNotFoundException e)
+      {
+         throw new ArchiveExportException("File could not be created: " + target);
+      }
+
       // Write out
-      this.export(out);
+      this.exportZip(out);
    }
 
    /**

Modified: shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/serialization/ZipSerializableViewImpl.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/serialization/ZipSerializableViewImpl.java	2010-07-18 00:36:30 UTC (rev 4760)
+++ shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/serialization/ZipSerializableViewImpl.java	2010-07-18 00:52:38 UTC (rev 4761)
@@ -123,7 +123,7 @@
       out.defaultWriteObject();
 
       // Write as ZIP 
-      final InputStream in = archive.as(ZipExporter.class).export();
+      final InputStream in = archive.as(ZipExporter.class).exportZip();
       try
       {
          IOUtil.copy(in, out); // Don't close the outstream

Modified: shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/exporter/ExplodedExporterTestCase.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/exporter/ExplodedExporterTestCase.java	2010-07-18 00:36:30 UTC (rev 4760)
+++ shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/exporter/ExplodedExporterTestCase.java	2010-07-18 00:52:38 UTC (rev 4761)
@@ -31,8 +31,6 @@
 import org.jboss.shrinkwrap.api.asset.Asset;
 import org.jboss.shrinkwrap.api.exporter.ArchiveExportException;
 import org.jboss.shrinkwrap.api.exporter.ExplodedExporter;
-import org.jboss.shrinkwrap.api.exporter.StreamExporter;
-import org.jboss.shrinkwrap.api.exporter.ZipExporter;
 import org.jboss.shrinkwrap.impl.base.TestIOUtil;
 import org.jboss.shrinkwrap.impl.base.io.IOUtil;
 import org.jboss.shrinkwrap.impl.base.path.BasicPath;
@@ -59,35 +57,6 @@
     * Logger
     */
    private static final Logger log = Logger.getLogger(ExplodedExporterTestCase.class.getName());
-   
-   /**
-    * Extension for exploded archives
-    */
-   private static final String EXTENSION = ".jar";
-   
-   //-------------------------------------------------------------------------------------||
-   // Required Implementations -----------------------------------------------------------||
-   //-------------------------------------------------------------------------------------||
-   
-   /**
-    * {@inheritDoc
-    * @see org.jboss.shrinkwrap.impl.base.exporter.ExportTestBase#getArchiveExtension()
-    */
-   @Override
-   protected String getArchiveExtension()
-   {
-      return EXTENSION;
-   }
-   
-   /**
-    * {@inheritDoc}
-    * @see org.jboss.shrinkwrap.impl.base.exporter.ExportTestBase#getStreamExporter()
-    */
-   @Override
-   protected Class<? extends StreamExporter> getStreamExporter()
-   {
-      return ZipExporter.class;
-   }
 
    //-------------------------------------------------------------------------------------||
    // Tests ------------------------------------------------------------------------------||
@@ -151,12 +120,12 @@
       Assert.assertEquals(expectedDirectory, explodedDirectory);
 
       // Validate nested archive entries were written out
-      ArchivePath nestedArchivePath = new BasicPath(NAME_NESTED_ARCHIVE + this.getArchiveExtension());
+      ArchivePath nestedArchivePath = new BasicPath(NAME_NESTED_ARCHIVE);
 
       assertAssetInExploded(explodedDirectory, new BasicPath(nestedArchivePath, PATH_ONE), ASSET_ONE);
       assertAssetInExploded(explodedDirectory, new BasicPath(nestedArchivePath, PATH_TWO), ASSET_TWO);
 
-      ArchivePath nestedArchivePathTwo = new BasicPath(NESTED_PATH, NAME_NESTED_ARCHIVE_2 + this.getArchiveExtension());
+      ArchivePath nestedArchivePathTwo = new BasicPath(NESTED_PATH, NAME_NESTED_ARCHIVE_2);
 
       assertAssetInExploded(explodedDirectory, new BasicPath(nestedArchivePathTwo, PATH_ONE), ASSET_ONE);
       assertAssetInExploded(explodedDirectory, new BasicPath(nestedArchivePathTwo, PATH_TWO), ASSET_TWO);
@@ -275,7 +244,7 @@
       log.info("testExportExplodedOutpuDirIsAFile");
       final File directory = createTempDirectory("testExportExplodedOutpuDirIsAFile");
       // Will cause the creation of Archive directory to fail
-      final File existingFile = new File(directory, NAME_ARCHIVE + this.getArchiveExtension());
+      final File existingFile = new File(directory, NAME_ARCHIVE);
       final boolean created = existingFile.createNewFile();
       
       IOUtil.copyWithClose(new ByteArrayInputStream("test-test".getBytes()), new FileOutputStream(existingFile));

Modified: shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/exporter/ExportTestBase.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/exporter/ExportTestBase.java	2010-07-18 00:36:30 UTC (rev 4760)
+++ shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/exporter/ExportTestBase.java	2010-07-18 00:52:38 UTC (rev 4761)
@@ -26,7 +26,6 @@
 import org.jboss.shrinkwrap.api.ArchivePaths;
 import org.jboss.shrinkwrap.api.ShrinkWrap;
 import org.jboss.shrinkwrap.api.asset.Asset;
-import org.jboss.shrinkwrap.api.exporter.StreamExporter;
 import org.jboss.shrinkwrap.api.spec.JavaArchive;
 import org.jboss.shrinkwrap.impl.base.TestIOUtil;
 import org.jboss.shrinkwrap.impl.base.asset.ClassLoaderAsset;
@@ -57,7 +56,7 @@
    /**
     * Name of an Archive
     */
-   protected static final String NAME_ARCHIVE = "testArchive";
+   protected static final String NAME_ARCHIVE = "testArchive.jar";
 
    /**
     * Name of a properties file upon the test CP
@@ -77,12 +76,12 @@
    /**
     * Name of a nested archive
     */
-   protected static final String NAME_NESTED_ARCHIVE = "nestedArchive";
+   protected static final String NAME_NESTED_ARCHIVE = "nestedArchive.jar";
 
    /**
     * Name of another nested archive
     */
-   protected static final String NAME_NESTED_ARCHIVE_2 = "nestedArchive2";
+   protected static final String NAME_NESTED_ARCHIVE_2 = "nestedArchive2.jar";
 
    /** 
     * Asset used for testing
@@ -160,24 +159,12 @@
    protected Archive<?> createArchiveWithAssets()
    {
       // Create an archive
-      Archive<?> archive = ShrinkWrap.create(JavaArchive.class, NAME_ARCHIVE + getArchiveExtension());
+      Archive<?> archive = ShrinkWrap.create(JavaArchive.class, NAME_ARCHIVE);
       // Add some content
       addContent(archive);
       // Return archive
       return archive;
    }
-   
-   /**
-    * Obtains the extension for created archives
-    * @return
-    */
-   protected abstract String getArchiveExtension();
-   
-   /**
-    * Returns the exporter type
-    * @return
-    */
-   protected abstract Class<? extends StreamExporter> getStreamExporter();
 
    /**
     * Create an archive instance and add some assets and some nested archives
@@ -188,22 +175,22 @@
       Archive<?> archive = createArchiveWithAssets();
 
       // Create a nested archive
-      Archive<?> nestedArchive = ShrinkWrap.create(JavaArchive.class, NAME_NESTED_ARCHIVE+ getArchiveExtension());
+      Archive<?> nestedArchive = ShrinkWrap.create(JavaArchive.class, NAME_NESTED_ARCHIVE);
 
       // Add some content
       addContent(nestedArchive);
 
       // Add nested archive
-      archive.add(nestedArchive, ArchivePaths.root(), this.getStreamExporter());
+      archive.add(nestedArchive, new BasicPath());
 
       // Add an archive nested in a directory
-      Archive<?> nestedArchiveTwo = ShrinkWrap.create(JavaArchive.class, NAME_NESTED_ARCHIVE_2+ getArchiveExtension());
+      Archive<?> nestedArchiveTwo = ShrinkWrap.create(JavaArchive.class, NAME_NESTED_ARCHIVE_2);
 
       // Add some content
       addContent(nestedArchiveTwo);
 
       // Add the archive under a nested path
-      archive.add(nestedArchiveTwo, NESTED_PATH, this.getStreamExporter());
+      archive.add(nestedArchiveTwo, NESTED_PATH);
       
       // Add empty directories
       archive.addDirectory(PATH_EMPTY_NESTED_DIR);

Deleted: shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/exporter/StreamExporterTestBase.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/exporter/StreamExporterTestBase.java	2010-07-18 00:36:30 UTC (rev 4760)
+++ shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/exporter/StreamExporterTestBase.java	2010-07-18 00:52:38 UTC (rev 4761)
@@ -1,527 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source  
- * Copyright 2010, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * 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.
- */
-package org.jboss.shrinkwrap.impl.base.exporter;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Collection;
-import java.util.List;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import java.util.logging.Logger;
-
-import org.jboss.shrinkwrap.api.Archive;
-import org.jboss.shrinkwrap.api.ArchivePath;
-import org.jboss.shrinkwrap.api.ArchivePaths;
-import org.jboss.shrinkwrap.api.ConfigurationBuilder;
-import org.jboss.shrinkwrap.api.Domain;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.asset.Asset;
-import org.jboss.shrinkwrap.api.exporter.ArchiveExportException;
-import org.jboss.shrinkwrap.api.exporter.FileExistsException;
-import org.jboss.shrinkwrap.api.spec.JavaArchive;
-import org.jboss.shrinkwrap.impl.base.io.IOUtil;
-import org.junit.Assert;
-import org.junit.Test;
-
-/**
- * Base support for testing stream-based exporters
- *
- * @author <a href="mailto:baileyje at gmail.com">John Bailey</a>
- * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-public abstract class StreamExporterTestBase extends ExportTestBase
-{
-   //-------------------------------------------------------------------------------------||
-   // Class Members ----------------------------------------------------------------------||
-   //-------------------------------------------------------------------------------------||
-
-   /**
-    * Logger
-    */
-   private static final Logger log = Logger.getLogger(StreamExporterTestBase.class.getName());
-
-   //-------------------------------------------------------------------------------------||
-   // Contracts --------------------------------------------------------------------------||
-   //-------------------------------------------------------------------------------------||
-
-   /**
-    * Exports the specified archive as an {@link InputStream}
-    * @param archive
-    * @return
-    */
-   protected abstract InputStream exportAsInputStream(Archive<?> archive);
-
-   /**
-    * Exports the specified archive to an {@link OutputStream}
-    * @param archive
-    * @return
-    */
-   protected abstract void exportToOutputStream(Archive<?> archive, OutputStream out);
-
-   /**
-    * Exports the specified archive as a {@link File}
-    * @param archive
-    * @param file
-    * @param overwrite
-    */
-   protected abstract void exportAsFile(Archive<?> archive, File file, boolean overwrite);
-
-   /**
-    * Ensures the contents of the specified {@link File} are
-    * as expected
-    * @param file
-    * @throws IOException If an I/O error occurred
-    */
-   protected abstract void ensureInExpectedForm(File file) throws IOException;
-
-   /**
-    * Obtains the {@link Asset} located at the specified {@link ArchivePath} in the
-    * specified {@link File}, or null if nothing is found at the specified path
-    * @param file
-    * @param path
-    * @return
-    */
-   protected abstract InputStream getContentsFromExportedFile(File file, ArchivePath path) throws IOException;
-
-   //-------------------------------------------------------------------------------------||
-   // Tests ------------------------------------------------------------------------------||
-   //-------------------------------------------------------------------------------------||
-
-   /**
-    * Test to make sue an archive can be exported and all contents are correctly located.
-    * @throws Exception
-    */
-   @Test
-   public void testExport() throws Exception
-   {
-      log.info("testExport");
-
-      // Get an archive instance
-      Archive<?> archive = createArchiveWithAssets();
-
-      // Export as InputStream
-      final InputStream exportStream = this.exportAsInputStream(archive);
-
-      // Validate
-      final File tempDirectory = createTempDirectory("testExport");
-      final File serialized = new File(tempDirectory, archive.getName());
-      final FileOutputStream out = new FileOutputStream(serialized);
-      IOUtil.copyWithClose(exportStream, out);
-      ensureInExpectedForm(serialized);
-   }
-
-   /**
-    * Ensures that the export write task uses the {@link ExecutorService}
-    * that we've configured, and leaves it running (does not shut it down)
-    * @throws Exception
-    */
-   @Test
-   public void exportUsesOurExecutorService() throws Exception
-   {
-      // Make a custom ES
-      final CountingExecutorService service = new CountingExecutorService();
-
-      // Create a custom configuration
-      final Domain domain = ShrinkWrap.createDomain(new ConfigurationBuilder().executorService(service).build());
-
-      // Make an archive using the new configuration
-      final Archive<?> archive = domain.getArchiveFactory().create(JavaArchive.class, "test.jar").addClass(
-            StreamExporterTestBase.class);
-
-      // Fully export by reading all content (export is on-demand)
-      final InputStream content = this.exportAsInputStream(archive);
-      final OutputStream sink = new OutputStream()
-      {
-
-         @Override
-         public void write(int b) throws IOException
-         {
-            //NOOP
-         }
-      };
-      IOUtil.copyWithClose(content, sink);
-
-      // Ensure the ES was used (one job was submitted to it)
-      Assert.assertEquals("Custom " + ExecutorService.class.getSimpleName() + " was not used by export process", 1,
-            service.counter);
-
-      // Ensure the ES was not shut down by the export process
-      Assert.assertFalse("Export should not shut down a user-supplied " + ExecutorService.class.getName(), service
-            .isShutdown());
-
-      // Shut down the ES (clean up)
-      service.shutdown();
-   }
-
-   /**
-    * Test to ensure that the export process accepts an archive
-    * with only directories, no assets.
-    * 
-    * @throws Exception
-    */
-   @Test
-   public void testExportArchiveWithOnlyDirectories() throws IOException
-   {
-      // Create an archive with directories
-      final Archive<?> archive = ShrinkWrap.create(JavaArchive.class, NAME_ARCHIVE).addDirectories("/test/game");
-
-      // Fully export by reading all content (export is on-demand)
-      final InputStream content = this.exportAsInputStream(archive);
-      final OutputStream sink = new OutputStream()
-      {
-
-         @Override
-         public void write(int b) throws IOException
-         {
-            //NOOP
-         }
-      };
-      IOUtil.copyWithClose(content, sink);
-
-      //TODO Why was this test originally written with no assertions? SHRINKWRAP-195
-   }
-
-   /**
-    * Test to make sure an archive can be exported to file and all 
-    * contents are correctly located.
-    * @throws Exception
-    */
-   @Test
-   public void testExportToFile() throws IOException
-   {
-      log.info("testExportToFile");
-
-      // Get a temp directory for the test
-      File tempDirectory = createTempDirectory("testExportToFile");
-
-      // Get an archive instance
-      Archive<?> archive = createArchiveWithAssets();
-
-      // Export as File
-      final File exported = new File(tempDirectory, archive.getName());
-      this.exportAsFile(archive, exported, true);
-
-      // Roundtrip assertion
-      this.ensureInExpectedForm(exported);
-   }
-
-   /**
-    * Test to make sure an archive can be exported to a {@link OutputStream} and all 
-    * contents are correctly located.
-    * @throws Exception
-    */
-   @Test
-   public void testExportToOutStream() throws IOException
-   {
-      log.info("testExportToOutStream");
-
-      // Get a temp directory for the test
-      final File tempDirectory = createTempDirectory("testExportToOutStream");
-
-      // Get an archive instance
-      final Archive<?> archive = createArchiveWithAssets();
-
-      // Export as OutStream and flush to a file manually
-      final File serializedArchive = new File(tempDirectory, archive.getName());
-      final OutputStream out = new FileOutputStream(serializedArchive);
-      this.exportToOutputStream(archive, out);
-
-      // Validate
-      this.ensureInExpectedForm(serializedArchive);
-   }
-
-   /**
-    * Test to make sure an archive can be exported to file and all 
-    * contents are correctly located.
-    * @throws Exception
-    */
-   @Test
-   public void testExportToExistingFileFails() throws IOException
-   {
-      log.info("testExportToExistingFileFails");
-
-      // Get a temp directory for the test
-      final File tempDirectory = createTempDirectory("testExportToExistingFileFails");
-
-      // Get an archive instance
-      final Archive<?> archive = createArchiveWithAssets();
-
-      // Export as File
-      final File alreadyExists = new File(tempDirectory, archive.getName());
-      final OutputStream alreadyExistsOutputStream = new FileOutputStream(alreadyExists);
-      alreadyExistsOutputStream.write(new byte[]
-      {});
-      alreadyExistsOutputStream.close();
-      Assert.assertTrue("The test setup is incorrect; an empty file should exist before writing the archive",
-            alreadyExists.exists());
-
-      // Should fail, as we're not overwriting
-      boolean gotExpectedException = false;
-      try
-      {
-         this.exportAsFile(archive, alreadyExists, false);
-      }
-      catch (final FileExistsException fee)
-      {
-         gotExpectedException = true;
-      }
-      Assert.assertTrue("Should get " + FileExistsException.class.getSimpleName()
-            + " when exporting to an existing file when overwrite is false", gotExpectedException);
-   }
-
-   /**
-    * Test to make sue an archive can be exported and nested archives are also in exported.
-    * @throws Exception
-    */
-   @Test
-   public void testExportNested() throws Exception
-   {
-      log.info("testExportNested");
-
-      // Get a temp directory for the test
-      final File tempDirectory = createTempDirectory("testExportNested");
-
-      // Get an archive instance
-      final Archive<?> archive = createArchiveWithNestedArchives();
-
-      // Export as InputStream
-      final InputStream exportStream = this.exportAsInputStream(archive);
-
-      // Write out and retrieve as exported file
-      final File exported = new File(tempDirectory, NAME_ARCHIVE + this.getArchiveExtension());
-      final OutputStream exportedOut = new FileOutputStream(exported);
-      IOUtil.copyWithClose(exportStream, exportedOut);
-
-      // Validate entries were written out
-      this.ensureAssetInExportedFile(exported, PATH_ONE, ASSET_ONE);
-      this.ensureAssetInExportedFile(exported, PATH_TWO, ASSET_TWO);
-
-      // Validate nested archive entries were written out
-      final ArchivePath nestedArchivePath = ArchivePaths.create(NAME_NESTED_ARCHIVE+this.getArchiveExtension());
-
-      // Get inputstream for entry 
-      final InputStream nestedArchiveStream = this.getContentsFromExportedFile(exported, nestedArchivePath);
-
-      // Write out and retrieve nested contents
-      final File nestedFile = new File(tempDirectory, NAME_NESTED_ARCHIVE + this.getArchiveExtension());
-      final OutputStream nestedOut = new FileOutputStream(nestedFile);
-      IOUtil.copyWithClose(nestedArchiveStream, nestedOut);
-
-      // Ensure contents are in the nested
-      this.ensureAssetInExportedFile(nestedFile, PATH_ONE, ASSET_ONE);
-      this.ensureAssetInExportedFile(nestedFile, PATH_TWO, ASSET_TWO);
-
-      // Validate nested archive entries were written out
-      final ArchivePath nestedArchiveTwoPath = ArchivePaths.create(NESTED_PATH, NAME_NESTED_ARCHIVE_2
-            + this.getArchiveExtension());
-      this.getContentsFromExportedFile(exported, nestedArchiveTwoPath);
-      final InputStream nestedArchiveTwoStream = this.getContentsFromExportedFile(exported, nestedArchiveTwoPath);
-
-      // Write out and retrieve secondnested contents
-      final File nestedTwoFile = new File(tempDirectory, NAME_NESTED_ARCHIVE_2 + this.getArchiveExtension());
-      final OutputStream nestedTwoOut = new FileOutputStream(nestedTwoFile);
-      IOUtil.copyWithClose(nestedArchiveTwoStream, nestedTwoOut);
-
-      // Ensure contents are in the second nested
-      this.ensureAssetInExportedFile(nestedTwoFile, PATH_ONE, ASSET_ONE);
-      this.ensureAssetInExportedFile(nestedTwoFile, PATH_TWO, ASSET_TWO);
-   }
-
-   @Test(expected = ArchiveExportException.class)
-   public void testExportThrowsArchiveExceptionOnAssetWriteFailure() throws IOException
-   {
-      log.info("testExportThrowsArchiveExceptionOnAssetWriteFailure");
-      Archive<?> archive = createArchiveWithAssets();
-
-      archive.add(new Asset()
-      {
-         @Override
-         public InputStream openStream()
-         {
-            throw new RuntimeException("Mock Exception from an Asset write");
-         }
-
-      }, PATH_ONE);
-
-      // Export
-      final InputStream in = this.exportAsInputStream(archive);
-
-      // Read in the full content (to in turn empty the underlying buffer and ensure we complete)
-      final OutputStream sink = new OutputStream()
-      {
-         @Override
-         public void write(int b) throws IOException
-         {
-         }
-      };
-      IOUtil.copyWithClose(in, sink);
-
-   }
-
-   //-------------------------------------------------------------------------------------||
-   // Helper Methods ---------------------------------------------------------------------||
-   //-------------------------------------------------------------------------------------||
-
-   /**
-    * Write a InputStream out to file.
-    * @param outFile
-    * @param inputStream
-    * @throws Exception
-    */
-   protected void writeOutFile(File outFile, InputStream inputStream) throws IOException
-   {
-      OutputStream fileOutputStream = new FileOutputStream(outFile);
-      IOUtil.copyWithClose(inputStream, fileOutputStream);
-   }
-
-   /**
-    * Test implementation of an {@link ExecutorService} which 
-    * counts all jobs submitted.
-    * 
-    * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
-    * @version $Revision: $
-    */
-   private static class CountingExecutorService implements ExecutorService
-   {
-
-      private final ExecutorService delegate;
-
-      int counter = 0;
-
-      public CountingExecutorService()
-      {
-         delegate = Executors.newSingleThreadExecutor();
-      }
-
-      @Override
-      public boolean awaitTermination(final long timeout, final TimeUnit unit) throws InterruptedException
-      {
-         return delegate.awaitTermination(timeout, unit);
-      }
-
-      @Override
-      public <T> List<Future<T>> invokeAll(final Collection<? extends Callable<T>> tasks) throws InterruptedException
-      {
-         return delegate.invokeAll(tasks);
-      }
-
-      @Override
-      public <T> List<Future<T>> invokeAll(final Collection<? extends Callable<T>> tasks, final long timeout,
-            final TimeUnit unit) throws InterruptedException
-      {
-         return delegate.invokeAll(tasks, timeout, unit);
-      }
-
-      @Override
-      public <T> T invokeAny(final Collection<? extends Callable<T>> tasks) throws InterruptedException,
-            ExecutionException
-      {
-         return delegate.invokeAny(tasks);
-      }
-
-      @Override
-      public <T> T invokeAny(final Collection<? extends Callable<T>> tasks, final long timeout, final TimeUnit unit)
-            throws InterruptedException, ExecutionException, TimeoutException
-      {
-         return delegate.invokeAny(tasks, timeout, unit);
-      }
-
-      @Override
-      public boolean isShutdown()
-      {
-         return delegate.isShutdown();
-      }
-
-      @Override
-      public boolean isTerminated()
-      {
-         return delegate.isTerminated();
-      }
-
-      @Override
-      public void shutdown()
-      {
-         delegate.shutdown();
-      }
-
-      @Override
-      public List<Runnable> shutdownNow()
-      {
-         return delegate.shutdownNow();
-      }
-
-      @Override
-      public <T> Future<T> submit(final Callable<T> task)
-      {
-         counter++;
-         return delegate.submit(task);
-      }
-
-      @Override
-      public Future<?> submit(final Runnable task)
-      {
-         counter++;
-         return delegate.submit(task);
-      }
-
-      @Override
-      public <T> Future<T> submit(final Runnable task, final T result)
-      {
-         counter++;
-         return delegate.submit(task, result);
-      }
-
-      @Override
-      public void execute(final Runnable command)
-      {
-         counter++;
-         delegate.execute(command);
-      }
-
-   }
-
-   /**
-    * {@inheritDoc}
-    * @see org.jboss.shrinkwrap.impl.base.exporter.StreamExporterTestBase#ensureAssetInExportedFile(java.io.File, org.jboss.shrinkwrap.api.ArchivePath, org.jboss.shrinkwrap.api.asset.Asset)
-    */
-   protected final void ensureAssetInExportedFile(final File file, final ArchivePath path, final Asset asset)
-         throws IOException
-   {
-      // Precondition checks
-      assert file != null : "file must be specified";
-      assert path != null : "path must be specified";
-      assert asset != null : "asset must be specified";
-
-      // Get as Exported File
-      final InputStream actualStream = this.getContentsFromExportedFile(file, path);
-      assert actualStream != null : "No contents found at path " + path + " in " + file.getAbsolutePath();
-      byte[] actualContents = IOUtil.asByteArray(actualStream);
-      byte[] expectedContents = IOUtil.asByteArray(asset.openStream());
-      Assert.assertArrayEquals(expectedContents, actualContents);
-   }
-}

Modified: shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/exporter/ZipExporterStressTest.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/exporter/ZipExporterStressTest.java	2010-07-18 00:36:30 UTC (rev 4760)
+++ shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/exporter/ZipExporterStressTest.java	2010-07-18 00:52:38 UTC (rev 4761)
@@ -44,7 +44,7 @@
  * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
  * @version $Revision: $
  */
-public class ZipExporterStressTest
+public class ZipExporterStressTest extends ExportTestBase
 {
    //-------------------------------------------------------------------------------------||
    // Class Members ----------------------------------------------------------------------||
@@ -103,7 +103,7 @@
       // Export; at this point we have less than 50% available memory so 
       // we can't carry the whole archive in RAM twice; this
       // should ensure the ZIP impl uses an internal buffer
-      final InputStream in = archive.as(ZipExporter.class).export();
+      final InputStream in = archive.as(ZipExporter.class).exportZip();
       final CountingOutputStream out = new CountingOutputStream();
 
       // Copy, counting the final size of the exported ZIP

Modified: shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/exporter/ZipExporterTestCase.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/exporter/ZipExporterTestCase.java	2010-07-18 00:36:30 UTC (rev 4760)
+++ shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/exporter/ZipExporterTestCase.java	2010-07-18 00:52:38 UTC (rev 4761)
@@ -16,189 +16,353 @@
  */
 package org.jboss.shrinkwrap.impl.base.exporter;
 
-import java.io.ByteArrayInputStream;
 import java.io.File;
+import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.util.Collection;
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.logging.Logger;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipFile;
 
+import junit.framework.TestCase;
+
 import org.jboss.shrinkwrap.api.Archive;
 import org.jboss.shrinkwrap.api.ArchivePath;
+import org.jboss.shrinkwrap.api.ConfigurationBuilder;
+import org.jboss.shrinkwrap.api.Domain;
 import org.jboss.shrinkwrap.api.ShrinkWrap;
 import org.jboss.shrinkwrap.api.asset.Asset;
-import org.jboss.shrinkwrap.api.exporter.StreamExporter;
+import org.jboss.shrinkwrap.api.exporter.ArchiveExportException;
+import org.jboss.shrinkwrap.api.exporter.FileExistsException;
 import org.jboss.shrinkwrap.api.exporter.ZipExporter;
 import org.jboss.shrinkwrap.api.spec.JavaArchive;
 import org.jboss.shrinkwrap.impl.base.io.IOUtil;
+import org.jboss.shrinkwrap.impl.base.path.BasicPath;
 import org.jboss.shrinkwrap.impl.base.path.PathUtil;
 import org.junit.Assert;
 import org.junit.Test;
 
 /**
- * TestCase to ensure that the {@link ZipExporter} correctly exports archives to ZIP format.
+ * TestCase to ensure that the {@link ZipExporter} correctly exports archives to Zip format.
  *
  * @author <a href="mailto:baileyje at gmail.com">John Bailey</a>
  * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
  * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
  * @version $Revision: $
  */
-public final class ZipExporterTestCase extends StreamExporterTestBase
+public class ZipExporterTestCase extends ExportTestBase
 {
    //-------------------------------------------------------------------------------------||
    // Class Members ----------------------------------------------------------------------||
    //-------------------------------------------------------------------------------------||
 
    /**
-    * Extension for archives
+    * Logger
     */
-   private static final String EXTENSION = ".jar";
+   private static final Logger log = Logger.getLogger(ZipExporterTestCase.class.getName());
 
    //-------------------------------------------------------------------------------------||
-   // Required Implementations -----------------------------------------------------------||
+   // Tests ------------------------------------------------------------------------------||
    //-------------------------------------------------------------------------------------||
 
    /**
-    * {@inheritDoc}
-    * @see org.jboss.shrinkwrap.impl.base.exporter.StreamExporterTestBase#exportAsInputStream(org.jboss.shrinkwrap.api.Archive)
+    * Test to make sue an archive can be exported to Zip and all contents are correctly located in the Zip.
+    * @throws Exception
     */
-   @Override
-   protected InputStream exportAsInputStream(final Archive<?> archive)
+   @Test
+   public void testExportZip() throws Exception
    {
-      assert archive != null : "archive must be specified";
-      return archive.as(ZipExporter.class).export();
+      log.info("testExportZip");
+
+      // Get a temp directory for the test
+      File tempDirectory = createTempDirectory("testExportZip");
+
+      // Get an archive instance
+      Archive<?> archive = createArchiveWithAssets();
+
+      // Export as Zip InputStream
+      final InputStream zipStream = archive.as(ZipExporter.class).exportZip();
+
+      // Write zip content to temporary file 
+      ZipFile expectedZip = getExportedZipFile(NAME_ARCHIVE, zipStream, tempDirectory);
+
+      // Validate
+      ensureZipFileInExpectedForm(expectedZip);
    }
 
    /**
-    * {@inheritDoc}
-    * @see org.jboss.shrinkwrap.impl.base.exporter.StreamExporterTestBase#exportAsFile(org.jboss.shrinkwrap.api.Archive, java.io.File, boolean)
+    * Ensures that the ZIP export write task uses the {@link ExecutorService}
+    * that we've configured, and leaves it running (does not shut it down)
+    * @throws Exception
     */
-   @Override
-   protected void exportAsFile(final Archive<?> archive, final File file, final boolean overwrite)
+   @Test
+   public void exportUsesOurExecutorService() throws Exception
    {
-      // Precondition checks
-      assert file != null : "file must be specified";
-      assert archive != null : "archive must be specified";
+      // Make a custom ES
+      final CountingExecutorService service = new CountingExecutorService();
 
-      // Export
-      archive.as(ZipExporter.class).exportZip(file, overwrite);
+      // Create a custom configuration
+      final Domain domain = ShrinkWrap.createDomain(new ConfigurationBuilder().executorService(service).build());
+
+      // Make an archive using the new configuration
+      final Archive<?> archive = domain.getArchiveFactory().create(JavaArchive.class, "test.jar").addClass(
+            ZipExporterTestCase.class);
+
+      // Fully export by reading all content (export is on-demand)
+      final InputStream zip = archive.as(ZipExporter.class).exportZip();
+      while (zip.read() != -1)
+      {
+
+      }
+
+      // Ensure the ES was used (one job was submitted to it)
+      TestCase.assertEquals("Custom " + ExecutorService.class.getSimpleName() + " was not used by ZIP export", 1,
+            service.counter);
+
+      // Ensure the ES was not shut down by the export process
+      TestCase.assertFalse("ZIP Export should not shut down a user-supplied " + ExecutorService.class.getName(),
+            service.isShutdown());
+
+      // Shut down the ES (clean up)
+      service.shutdown();
    }
 
    /**
-    * {@inheritDoc}
-    * @see org.jboss.shrinkwrap.impl.base.exporter.StreamExporterTestBase#exportToOutputStream(org.jboss.shrinkwrap.api.Archive, java.io.OutputStream)
+    * Test to ensure that the {@link JdkZipExporterDelegate} does not accept 
+    * an empty archive as input
+    * 
+    * SHRINKWRAP-93
+    * 
+    * @throws Exception
     */
-   @Override
-   protected void exportToOutputStream(final Archive<?> archive, final OutputStream out)
+   @Test(expected = IllegalArgumentException.class)
+   public void exportEmptyArchiveAsZip() throws Exception
    {
-      assert archive != null : "archive must be specified";
-      assert out != null : "outstream must be specified";
-      archive.as(ZipExporter.class).export(out);
+      // Attempt to export an empty archive, should fail
+      ShrinkWrap.create(JavaArchive.class, NAME_ARCHIVE).as(ZipExporter.class).exportZip();
    }
 
    /**
-    * {@inheritDoc}
-    * @see org.jboss.shrinkwrap.impl.base.exporter.StreamExporterTestBase#ensureInExpectedForm(java.io.File)
+    * Test to ensure that the {@link JdkZipExporterDelegate} accepts an archive
+    * with only directories, no assets.
+    * 
+    * @throws Exception
     */
-   @Override
-   protected void ensureInExpectedForm(final File file) throws IOException
+   @Test
+   public void testExportArchiveWithOnlyDirectories()
    {
-      // Precondition check
-      assert file != null : "file must be specified";
+      // Attempt to export an archive with some directories, should pass
+      ShrinkWrap.create(JavaArchive.class, NAME_ARCHIVE).addDirectories("/test/game").as(ZipExporter.class).exportZip();
+   }
 
+   /**
+    * Test to make sure an archive can be exported to Zip (file) and all 
+    * contents are correctly located in the Zip.
+    * @throws Exception
+    */
+   @Test
+   public void testExportZipToFile() throws IOException
+   {
+      log.info("testExportZipToFile");
+
+      // Get a temp directory for the test
+      File tempDirectory = createTempDirectory("testExportZipToFile");
+
+      // Get an archive instance
+      Archive<?> archive = createArchiveWithAssets();
+
+      // Export as File
+      final File exported = new File(tempDirectory, archive.getName());
+      archive.as(ZipExporter.class).exportZip(exported, true);
+
       // Get as ZipFile
-      final ZipFile zip = new ZipFile(file);
+      final ZipFile expectedZip = new ZipFile(exported);
 
       // Validate
-      this.ensureZipFileInExpectedForm(zip);
+      ensureZipFileInExpectedForm(expectedZip);
    }
 
    /**
-    * {@inheritDoc}
-    * @see org.jboss.shrinkwrap.impl.base.exporter.StreamExporterTestBase#getAssetFromExportedFile(java.io.File, org.jboss.shrinkwrap.api.ArchivePath)
+    * Test to make sure an archive can be exported to Zip (OutStream) and all 
+    * contents are correctly located in the Zip.
+    * @throws Exception
     */
-   @Override
-   protected InputStream getContentsFromExportedFile(final File file, final ArchivePath path) throws IOException
+   @Test
+   public void testExportZipToOutStream() throws IOException
    {
-      // Precondition checks
-      assert file != null : "file must be specified";
-      assert path != null : "path must be specified";
+      log.info("testExportZipToOutStream");
 
-      // Get as Zip File
-      final ZipFile zipFile = new ZipFile(file);
-      final ZipEntry entry = zipFile.getEntry(PathUtil.optionallyRemovePrecedingSlash(path.get()));
-      if (entry == null)
-      {
-         return null;
-      }
-      final byte[] actualContents = IOUtil.asByteArray(zipFile.getInputStream(entry));
-      return new ByteArrayInputStream(actualContents);
+      // Get a temp directory for the test
+      final File tempDirectory = createTempDirectory("testExportZipToOutStream");
+
+      // Get an archive instance
+      Archive<?> archive = createArchiveWithAssets();
+
+      // Export as OutStream and flush to a file manually
+      final File serializedArchive = new File(tempDirectory, archive.getName());
+      final OutputStream out = new FileOutputStream(serializedArchive);
+      archive.as(ZipExporter.class).exportZip(out);
+
+      // Get as ZipFile
+      final ZipFile expectedZip = new ZipFile(serializedArchive);
+
+      // Validate
+      ensureZipFileInExpectedForm(expectedZip);
    }
 
    /**
-    * {@inheritDoc
-    * @see org.jboss.shrinkwrap.impl.base.exporter.ExportTestBase#getArchiveExtension()
+    * Test to make sure an archive can be exported to Zip (file) and all 
+    * contents are correctly located in the Zip.
+    * @throws Exception
     */
-   @Override
-   protected String getArchiveExtension()
+   @Test(expected = FileExistsException.class)
+   public void testExportZipToExistingFileFails() throws IOException
    {
-      return EXTENSION;
+      log.info("testExportZipToExistingFileFails");
+
+      // Get a temp directory for the test
+      File tempDirectory = createTempDirectory("testExportZipToExistingFileFails");
+
+      // Get an archive instance
+      Archive<?> archive = createArchiveWithAssets();
+
+      // Export as File
+      final File alreadyExists = new File(tempDirectory, archive.getName());
+      final OutputStream alreadyExistsOutputStream = new FileOutputStream(alreadyExists);
+      alreadyExistsOutputStream.write(new byte[]
+      {});
+      alreadyExistsOutputStream.close();
+      TestCase.assertTrue("The test setup is incorrect; an empty file should exist before writing the archive",
+            alreadyExists.exists());
+
+      // Try to write to a file that already exists (should fail)
+      archive.as(ZipExporter.class).exportZip(alreadyExists);
    }
 
    /**
-    * {@inheritDoc}
-    * @see org.jboss.shrinkwrap.impl.base.exporter.ExportTestBase#getStreamExporter()
+    * Test to make sue an archive can be exported to Zip and nested archives are also in exported as nested Zip.
+    * @throws Exception
     */
-   @Override
-   protected Class<? extends StreamExporter> getStreamExporter()
+   @Test
+   public void testExportNestedZip() throws Exception
    {
-      return ZipExporter.class;
+      log.info("testExportNestedZip");
+
+      // Get a temp directory for the test
+      File tempDirectory = createTempDirectory("testExportNestedZip");
+
+      // Get an archive instance
+      Archive<?> archive = createArchiveWithNestedArchives();
+
+      // Export as Zip InputStream
+      InputStream zipStream = archive.as(ZipExporter.class).exportZip();
+
+      // Write out and retrieve Zip 
+      ZipFile expectedZip = getExportedZipFile(NAME_ARCHIVE, zipStream, tempDirectory);
+
+      // Validate entries were written out
+      assertAssetInZip(expectedZip, PATH_ONE, ASSET_ONE);
+      assertAssetInZip(expectedZip, PATH_TWO, ASSET_TWO);
+
+      // Validate nested archive entries were written out
+      ArchivePath nestedArchivePath = new BasicPath(NAME_NESTED_ARCHIVE);
+
+      // Get Zip entry path
+      String nestedArchiveZipEntryPath = PathUtil.optionallyRemovePrecedingSlash(nestedArchivePath.get());
+
+      // Get nested archive entry from exported zip
+      ZipEntry nestedArchiveEntry = expectedZip.getEntry(nestedArchiveZipEntryPath);
+
+      // Get inputstream for entry 
+      InputStream nesterArchiveStream = expectedZip.getInputStream(nestedArchiveEntry);
+
+      // Write out and retrieve nested Zip
+      ZipFile nestedZip = getExportedZipFile(NAME_NESTED_ARCHIVE, nesterArchiveStream, tempDirectory);
+
+      assertAssetInZip(nestedZip, PATH_ONE, ASSET_ONE);
+      assertAssetInZip(nestedZip, PATH_TWO, ASSET_TWO);
+
+      // Validate nested archive entries were written out
+      ArchivePath nestedArchiveTwoPath = new BasicPath(NESTED_PATH, NAME_NESTED_ARCHIVE_2);
+
+      // Get Zip entry path
+      String nestedArchiveTwoZipEntryPath = PathUtil.optionallyRemovePrecedingSlash(nestedArchiveTwoPath.get());
+
+      // Get second nested archive entry from exported zip
+      ZipEntry nestedArchiveTwoEntry = expectedZip.getEntry(nestedArchiveTwoZipEntryPath);
+
+      // Get inputstream for entry 
+      InputStream nesterArchiveTwoStream = expectedZip.getInputStream(nestedArchiveTwoEntry);
+
+      // Write out and retrieve second nested Zip
+      ZipFile nestedZipTwo = getExportedZipFile(NAME_NESTED_ARCHIVE_2, nesterArchiveTwoStream, tempDirectory);
+
+      assertAssetInZip(nestedZipTwo, PATH_ONE, ASSET_ONE);
+      assertAssetInZip(nestedZipTwo, PATH_TWO, ASSET_TWO);
+
    }
-   
-   //-------------------------------------------------------------------------------------||
-   // Tests ------------------------------------------------------------------------------||
-   //-------------------------------------------------------------------------------------||
 
-   /**
-    * Test to ensure that the {@link JdkZipExporterDelegate} does not accept 
-    * an empty archive as input
-    * 
-    * SHRINKWRAP-93
-    * 
-    * @throws Exception
-    */
-   @Test(expected = IllegalArgumentException.class)
-   public void exportEmptyArchiveAsZip() throws Exception
+   @Test(expected = ArchiveExportException.class)
+   public void testExportThrowsArchiveExceptionOnAssetWriteFailure() throws IOException
    {
-      // Attempt to export an empty archive, should fail
-      ShrinkWrap.create(JavaArchive.class, NAME_ARCHIVE).as(ZipExporter.class).export();
+      log.info("testExportThrowsArchiveExceptionOnAssetWriteFailure");
+      Archive<?> archive = createArchiveWithAssets();
+
+      archive.add(new Asset()
+      {
+         @Override
+         public InputStream openStream()
+         {
+            throw new RuntimeException("Mock Exception from an Asset write");
+         }
+
+      }, PATH_ONE);
+
+      // Export
+      final InputStream in = archive.as(ZipExporter.class).exportZip();
+
+      // Read in the full content (to in turn empty the underlying buffer and ensure we complete)
+      final OutputStream sink = new OutputStream()
+      {
+         @Override
+         public void write(int b) throws IOException
+         {
+         }
+      };
+      IOUtil.copyWithClose(in, sink);
+
    }
 
    //-------------------------------------------------------------------------------------||
    // Internal Helper Methods ------------------------------------------------------------||
    //-------------------------------------------------------------------------------------||
 
-   /**
-    * Ensures that the specified {@link ZipFile} contains entries
-    * in the expected form
-    * @param expectedZip
-    * @throws IOException
-    */
-   private void ensureZipFileInExpectedForm(final ZipFile expectedZip) throws IOException
+   private ZipFile getExportedZipFile(String archiveName, InputStream zipStream, File tempDirectory) throws Exception
    {
-      // Validate entries were written out
-      assertAssetInZip(expectedZip, PATH_ONE, ASSET_ONE);
-      assertAssetInZip(expectedZip, PATH_TWO, ASSET_TWO);
 
-      // Validate all paths were written
-      // SHRINKWRAP-94
-      getEntryFromZip(expectedZip, NESTED_PATH);
+      // Validate the InputStream was created 
+      Assert.assertNotNull(zipStream);
 
-      // Ensure we don't write the root Path
-      // SHRINKWRAP-96
-      ZipEntry rootEntry = expectedZip.getEntry("/");
-      Assert.assertNull("ZIP should not have explicit root path written (SHRINKWRAP-96)", rootEntry);
+      // Create a temp file
+      File outFile = new File(tempDirectory, archiveName);
+
+      // Write Zip contents to file
+      writeOutFile(outFile, zipStream);
+
+      // Use standard ZipFile library to read in written Zip file
+      ZipFile expectedZip = new ZipFile(outFile);
+
+      return expectedZip;
    }
 
    /**
@@ -210,8 +374,8 @@
          IOException
    {
       final ZipEntry entry = this.getEntryFromZip(expectedZip, path);
-      final byte[] expectedContents = IOUtil.asByteArray(asset.openStream());
-      final byte[] actualContents = IOUtil.asByteArray(expectedZip.getInputStream(entry));
+      byte[] expectedContents = IOUtil.asByteArray(asset.openStream());
+      byte[] actualContents = IOUtil.asByteArray(expectedZip.getInputStream(entry));
       Assert.assertArrayEquals(expectedContents, actualContents);
    }
 
@@ -227,10 +391,149 @@
    private ZipEntry getEntryFromZip(final ZipFile expectedZip, final ArchivePath path) throws IllegalArgumentException,
          IOException
    {
-      final String entryPath = PathUtil.optionallyRemovePrecedingSlash(path.get());
-      final ZipEntry entry = expectedZip.getEntry(entryPath);
+      String entryPath = PathUtil.optionallyRemovePrecedingSlash(path.get());
+      ZipEntry entry = expectedZip.getEntry(entryPath);
       Assert.assertNotNull("Expected path not found in ZIP: " + path, entry);
       return entry;
    }
 
+   /**
+    * Write a InputStream out to file.
+    * @param outFile
+    * @param zipInputStream
+    * @throws Exception
+    */
+   private void writeOutFile(File outFile, InputStream inputStream) throws Exception
+   {
+      OutputStream fileOutputStream = new FileOutputStream(outFile);
+      IOUtil.copyWithClose(inputStream, fileOutputStream);
+   }
+
+   /**
+    * Ensures that the specified {@link ZipFile} contains entries
+    * in the expected form
+    * @param expectedZip
+    * @throws IOException
+    */
+   private void ensureZipFileInExpectedForm(final ZipFile expectedZip) throws IOException
+   {
+      // Validate entries were written out
+      assertAssetInZip(expectedZip, PATH_ONE, ASSET_ONE);
+      assertAssetInZip(expectedZip, PATH_TWO, ASSET_TWO);
+
+      // Validate all paths were written
+      // SHRINKWRAP-94
+      getEntryFromZip(expectedZip, NESTED_PATH);
+
+      // Ensure we don't write the root PAth
+      // SHRINKWRAP-96
+      ZipEntry rootEntry = expectedZip.getEntry("/");
+      Assert.assertNull("ZIP should not have explicit root path written (SHRINKWRAP-96)", rootEntry);
+   }
+
+   /**
+    * Test implementation of an {@link ExecutorService} which 
+    * counts all jobs submitted.
+    * 
+    * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+    * @version $Revision: $
+    */
+   private static class CountingExecutorService implements ExecutorService
+   {
+
+      private final ExecutorService delegate;
+
+      int counter = 0;
+
+      public CountingExecutorService()
+      {
+         delegate = Executors.newSingleThreadExecutor();
+      }
+
+      @Override
+      public boolean awaitTermination(final long timeout, final TimeUnit unit) throws InterruptedException
+      {
+         return delegate.awaitTermination(timeout, unit);
+      }
+
+      @Override
+      public <T> List<Future<T>> invokeAll(final Collection<? extends Callable<T>> tasks) throws InterruptedException
+      {
+         return delegate.invokeAll(tasks);
+      }
+
+      @Override
+      public <T> List<Future<T>> invokeAll(final Collection<? extends Callable<T>> tasks, final long timeout,
+            final TimeUnit unit) throws InterruptedException
+      {
+         return delegate.invokeAll(tasks, timeout, unit);
+      }
+
+      @Override
+      public <T> T invokeAny(final Collection<? extends Callable<T>> tasks) throws InterruptedException,
+            ExecutionException
+      {
+         return delegate.invokeAny(tasks);
+      }
+
+      @Override
+      public <T> T invokeAny(final Collection<? extends Callable<T>> tasks, final long timeout, final TimeUnit unit)
+            throws InterruptedException, ExecutionException, TimeoutException
+      {
+         return delegate.invokeAny(tasks, timeout, unit);
+      }
+
+      @Override
+      public boolean isShutdown()
+      {
+         return delegate.isShutdown();
+      }
+
+      @Override
+      public boolean isTerminated()
+      {
+         return delegate.isTerminated();
+      }
+
+      @Override
+      public void shutdown()
+      {
+         delegate.shutdown();
+      }
+
+      @Override
+      public List<Runnable> shutdownNow()
+      {
+         return delegate.shutdownNow();
+      }
+
+      @Override
+      public <T> Future<T> submit(final Callable<T> task)
+      {
+         counter++;
+         return delegate.submit(task);
+      }
+
+      @Override
+      public Future<?> submit(final Runnable task)
+      {
+         counter++;
+         return delegate.submit(task);
+      }
+
+      @Override
+      public <T> Future<T> submit(final Runnable task, final T result)
+      {
+         counter++;
+         return delegate.submit(task, result);
+      }
+
+      @Override
+      public void execute(final Runnable command)
+      {
+         counter++;
+         delegate.execute(command);
+      }
+
+   }
 }

Modified: shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/importer/ZipImporterImplTestCase.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/importer/ZipImporterImplTestCase.java	2010-07-18 00:36:30 UTC (rev 4760)
+++ shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/importer/ZipImporterImplTestCase.java	2010-07-18 00:52:38 UTC (rev 4761)
@@ -104,7 +104,7 @@
 
       File tempFile = new File("target/test.zip");
       tempFile.deleteOnExit();
-      final InputStream zipStream = archive.as(ZipExporter.class).export();
+      InputStream zipStream = archive.as(ZipExporter.class).exportZip();
       IOUtil.copyWithClose(zipStream, new FileOutputStream(tempFile));
 
       delegate.assertContent(archive, tempFile);

Modified: shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/serialization/ZipSerializableOriginalImpl.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/serialization/ZipSerializableOriginalImpl.java	2010-07-18 00:36:30 UTC (rev 4760)
+++ shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/serialization/ZipSerializableOriginalImpl.java	2010-07-18 00:52:38 UTC (rev 4761)
@@ -124,7 +124,7 @@
       out.defaultWriteObject();
 
       // Write as ZIP 
-      final InputStream in = archive.as(ZipExporter.class).export();
+      final InputStream in = archive.as(ZipExporter.class).exportZip();
       try
       {
          IOUtil.copy(in, out); // Don't close the outstream

Modified: shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/test/ArchiveTestBase.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/test/ArchiveTestBase.java	2010-07-18 00:36:30 UTC (rev 4760)
+++ shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/test/ArchiveTestBase.java	2010-07-18 00:52:38 UTC (rev 4761)
@@ -31,7 +31,6 @@
 import org.jboss.shrinkwrap.api.ShrinkWrap;
 import org.jboss.shrinkwrap.api.asset.Asset;
 import org.jboss.shrinkwrap.api.asset.EmptyAsset;
-import org.jboss.shrinkwrap.api.exporter.ZipExporter;
 import org.jboss.shrinkwrap.api.spec.JavaArchive;
 import org.jboss.shrinkwrap.impl.base.Validate;
 import org.jboss.shrinkwrap.impl.base.asset.ArchiveAsset;
@@ -561,7 +560,7 @@
       Archive<T> archive = getArchive();
       try
       {
-         archive.add(ShrinkWrap.create(JavaArchive.class), (ArchivePath) null, ZipExporter.class);
+         archive.add(ShrinkWrap.create(JavaArchive.class), (ArchivePath) null);
          Assert.fail("Should have throw an IllegalArgumentException");
       }
       catch (IllegalArgumentException expectedException)
@@ -577,7 +576,7 @@
    public void testAddArchiveToPathRequireStringPath() throws Exception
    {
       Archive<T> archive = getArchive();
-      archive.add(ShrinkWrap.create(JavaArchive.class), (String) null, ZipExporter.class);
+      archive.add(ShrinkWrap.create(JavaArchive.class), (String) null);
    }
 
    /**
@@ -590,7 +589,7 @@
       Archive<T> archive = getArchive();
       try
       {
-         archive.add((Archive<?>) null, ArchivePaths.root(), ZipExporter.class);
+         archive.add((Archive<?>) null, new BasicPath("/"));
          Assert.fail("Should have throw an IllegalArgumentException");
       }
       catch (IllegalArgumentException expectedException)
@@ -868,7 +867,7 @@
 
       ArchivePath baseLocation = new BasicPath("somewhere");
 
-      archive.add(sourceArchive, baseLocation, ZipExporter.class);
+      archive.add(sourceArchive, baseLocation);
 
       ArchivePath expectedPath = new BasicPath(baseLocation, sourceArchive.getName());
 
@@ -902,7 +901,7 @@
 
       ArchivePath baseLocation = new BasicPath("somewhere");
 
-      archive.add(sourceArchive, baseLocation, ZipExporter.class);
+      archive.add(sourceArchive, baseLocation);
 
       ArchivePath archivePath = new BasicPath(baseLocation, sourceArchive.getName());
 
@@ -925,11 +924,11 @@
 
       ArchivePath baseLocation = new BasicPath("somewhere");
 
-      archive.add(nestedArchive, baseLocation, ZipExporter.class);
+      archive.add(nestedArchive, baseLocation);
 
       Archive<T> nestedNestedArchive = createNewArchive();
 
-      nestedArchive.add(nestedNestedArchive, ArchivePaths.root(), ZipExporter.class);
+      nestedArchive.add(nestedNestedArchive, new BasicPath("/"));
       
       Asset asset = new ClassLoaderAsset(NAME_TEST_PROPERTIES);
 

Modified: shrinkwrap/trunk/pom.xml
===================================================================
--- shrinkwrap/trunk/pom.xml	2010-07-18 00:36:30 UTC (rev 4760)
+++ shrinkwrap/trunk/pom.xml	2010-07-18 00:52:38 UTC (rev 4761)
@@ -74,7 +74,6 @@
     <module>extension-jetty-6</module>
     <module>extension-jetty-7</module>
     <module>extension-openejb</module>
-    <module>extension-tar</module>
     <module>extension-vfs3</module>
     <module>extension-vdf</module>
     <module>extension-classloader</module>



More information about the jboss-svn-commits mailing list