ShrinkWrap Aggregator and Build Parent 1.0.0-cr-1

org.jboss.shrinkwrap.impl.base.exporter
Class StreamExporterDelegateBase<O extends OutputStream>

java.lang.Object
  extended by org.jboss.shrinkwrap.impl.base.exporter.AbstractExporterDelegate<InputStream>
      extended by org.jboss.shrinkwrap.impl.base.exporter.StreamExporterDelegateBase<O>
Direct Known Subclasses:
JdkZipExporterDelegate, TarExporterDelegateBase

public abstract class StreamExporterDelegateBase<O extends OutputStream>
extends AbstractExporterDelegate<InputStream>

Base for exporters capable of writing to some implementation of OutputStream

Version:
$Revision: $
Author:
ALR

Field Summary
protected  CountDownLatch latch
          Synchronization point where the encoding process will wait until all streams have been set up
protected  O outputStream
          OutputStream used to write the individual entries
 
Constructor Summary
StreamExporterDelegateBase(Archive<?> archive)
          Creates a new exporter delegate for exporting archives
 
Method Summary
protected abstract  void closeEntry(O outputStream)
          Closes the current entry context for the specified OutputStream
protected abstract  O createOutputStream(OutputStream out)
          Creates the real OutputStream to which we'll write, wrapping the provided target.
protected  void doExport()
          Primary method providing a template for exporting the contents of an archive
protected  Set<ArchivePath> getExportedPaths()
          Returns an immutable view of all ArchivePaths currently exported
protected abstract  Callable<Void> getExportTask(Callable<Void> wrappedTask)
          Returns the task used to run the export operation in another Thread.
protected  InputStream getResult()
          Return the results of the export.
protected  void processNode(ArchivePath path, Node node)
          Template method for processing a single node.
protected abstract  void putNextExtry(O outputStream, String context)
          Writes the next entry (demarcates a new file/folder is to be written)
 
Methods inherited from class org.jboss.shrinkwrap.impl.base.exporter.AbstractExporterDelegate
export, getArchive
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

outputStream

protected O extends OutputStream outputStream
OutputStream used to write the individual entries


latch

protected final CountDownLatch latch
Synchronization point where the encoding process will wait until all streams have been set up

Constructor Detail

StreamExporterDelegateBase

public StreamExporterDelegateBase(Archive<?> archive)
                           throws IllegalArgumentException
Creates a new exporter delegate for exporting archives

Throws:
IllegalArgumentException
Method Detail

getExportTask

protected abstract Callable<Void> getExportTask(Callable<Void> wrappedTask)
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.

Parameters:
wrappedTask - The export task to be wrapped in more specific handling logic

doExport

protected void doExport()
Primary method providing a template for exporting the contents of an archive

Overrides:
doExport in class AbstractExporterDelegate<InputStream>
See Also:
AbstractExporterDelegate.doExport()

putNextExtry

protected abstract void putNextExtry(O outputStream,
                                     String context)
                              throws IOException
Writes the next entry (demarcates a new file/folder is to be written)

Parameters:
outputStream -
context -
Throws:
IOException - If an error occurred writing the entry

closeEntry

protected abstract void closeEntry(O outputStream)
                            throws IOException
Closes the current entry context for the specified OutputStream

Parameters:
outputStream -
Throws:
IOException

createOutputStream

protected abstract O createOutputStream(OutputStream out)
                                                      throws IOException
Creates the real OutputStream to which we'll write, wrapping the provided target.

Parameters:
out -
Returns:
Throws:
IOException - If an error occurred in creating the stream

processNode

protected void processNode(ArchivePath path,
                           Node node)
Template method for processing a single node.

Specified by:
processNode in class AbstractExporterDelegate<InputStream>
See Also:
AbstractExporterDelegate.processNode(ArchivePath, Node)

getResult

protected InputStream getResult()
Return the results of the export. Should process any tasks required to finalize the export.

Specified by:
getResult in class AbstractExporterDelegate<InputStream>
Returns:
See Also:
AbstractExporterDelegate.getResult()

getExportedPaths

protected final Set<ArchivePath> getExportedPaths()
Returns an immutable view of all ArchivePaths currently exported

Returns:

ShrinkWrap Aggregator and Build Parent 1.0.0-cr-1

Copyright © 2011 JBoss, a division of Red Hat, Inc.. All Rights Reserved.