Package org.codehaus.plexus.archiver.zip
Class ConcurrentJarCreator
- java.lang.Object
-
- org.codehaus.plexus.archiver.zip.ConcurrentJarCreator
-
public class ConcurrentJarCreator extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classConcurrentJarCreator.DeferredSupplier
-
Field Summary
Fields Modifier and Type Field Description private booleancompressAddedZipsprivate org.apache.commons.compress.archivers.zip.ScatterZipOutputStreamdirectoriesprivate org.apache.commons.compress.archivers.zip.ScatterZipOutputStreammanifestprivate org.apache.commons.compress.archivers.zip.ScatterZipOutputStreammetaInfDirprivate org.apache.commons.compress.archivers.zip.ParallelScatterZipCreatorparallelScatterZipCreatorprivate org.apache.commons.compress.archivers.zip.ScatterZipOutputStreamsynchronousEntriesprivate longzipCloseElapsed
-
Constructor Summary
Constructors Constructor Description ConcurrentJarCreator(boolean compressAddedZips, int nThreads)Creates a newConcurrentJarCreatorinstance.ConcurrentJarCreator(int nThreads)Creates a newConcurrentJarCreatorinstance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddArchiveEntry(org.apache.commons.compress.archivers.zip.ZipArchiveEntry zipArchiveEntry, org.apache.commons.compress.parallel.InputStreamSupplier source, boolean addInParallel)Adds an archive entry to this archive.static org.apache.commons.compress.archivers.zip.ScatterZipOutputStreamcreateDeferred(org.apache.commons.compress.parallel.ScatterGatherBackingStoreSupplier scatterGatherBackingStoreSupplier)private org.apache.commons.compress.archivers.zip.ZipArchiveEntryRequestcreateEntry(org.apache.commons.compress.archivers.zip.ZipArchiveEntry zipArchiveEntry, org.apache.commons.compress.parallel.InputStreamSupplier inputStreamSupplier)private org.apache.commons.compress.archivers.zip.ZipArchiveEntryRequestSuppliercreateEntrySupplier(org.apache.commons.compress.archivers.zip.ZipArchiveEntry zipArchiveEntry, org.apache.commons.compress.parallel.InputStreamSupplier inputStreamSupplier)private org.apache.commons.compress.parallel.InputStreamSuppliercreateInputStreamSupplier(java.io.InputStream payload)java.lang.StringgetStatisticsMessage()Returns a message describing the overall statistics of the compression runprivate booleanisZipHeader(byte[] header)private org.apache.commons.compress.parallel.InputStreamSupplierprependBytesToStream(byte[] bytes, int len, java.io.InputStream stream)voidwriteTo(org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream targetStream)
-
-
-
Field Detail
-
compressAddedZips
private final boolean compressAddedZips
-
directories
private final org.apache.commons.compress.archivers.zip.ScatterZipOutputStream directories
-
metaInfDir
private final org.apache.commons.compress.archivers.zip.ScatterZipOutputStream metaInfDir
-
manifest
private final org.apache.commons.compress.archivers.zip.ScatterZipOutputStream manifest
-
synchronousEntries
private final org.apache.commons.compress.archivers.zip.ScatterZipOutputStream synchronousEntries
-
parallelScatterZipCreator
private final org.apache.commons.compress.archivers.zip.ParallelScatterZipCreator parallelScatterZipCreator
-
zipCloseElapsed
private long zipCloseElapsed
-
-
Constructor Detail
-
ConcurrentJarCreator
public ConcurrentJarCreator(int nThreads) throws java.io.IOExceptionCreates a newConcurrentJarCreatorinstance.ConcurrentJarCreatorcreates zip files using several concurrent threads.This constructor has the same effect as
ConcurrentJarCreator(true, nThreads)- Parameters:
nThreads- The number of concurrent thread used to create the archive- Throws:
java.io.IOException
-
ConcurrentJarCreator
public ConcurrentJarCreator(boolean compressAddedZips, int nThreads) throws java.io.IOExceptionCreates a newConcurrentJarCreatorinstance.ConcurrentJarCreatorcreates zip files using several concurrent threads. Entries that are already zip file could be just stored or compressed again.- Parameters:
compressAddedZips- Indicates if entries that are zip files should be compressed. If set tofalseentries that are zip files will be added usingZipEntry.STOREDmethod. If set totrueentries that are zip files will be added using the compression method indicated by theZipArchiveEntrypassed toaddArchiveEntry(ZipArchiveEntry, InputStreamSupplier, boolean). The compression method for all entries that are not zip files will not be changed regardless of the value of this parameternThreads- The number of concurrent thread used to create the archive- Throws:
java.io.IOException
-
-
Method Detail
-
createDeferred
public static org.apache.commons.compress.archivers.zip.ScatterZipOutputStream createDeferred(org.apache.commons.compress.parallel.ScatterGatherBackingStoreSupplier scatterGatherBackingStoreSupplier) throws java.io.IOException- Throws:
java.io.IOException
-
addArchiveEntry
public void addArchiveEntry(org.apache.commons.compress.archivers.zip.ZipArchiveEntry zipArchiveEntry, org.apache.commons.compress.parallel.InputStreamSupplier source, boolean addInParallel) throws java.io.IOExceptionAdds an archive entry to this archive.This method is expected to be called from a single client thread
- Parameters:
zipArchiveEntry- The entry to add. Compression methodsource- The source input stream supplieraddInParallel- Indicates if the entry should be add in parallel. If set tofalsethe entry is added synchronously.- Throws:
java.io.IOException
-
createInputStreamSupplier
private org.apache.commons.compress.parallel.InputStreamSupplier createInputStreamSupplier(java.io.InputStream payload)
-
writeTo
public void writeTo(org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream targetStream) throws java.io.IOException, java.util.concurrent.ExecutionException, java.lang.InterruptedException- Throws:
java.io.IOExceptionjava.util.concurrent.ExecutionExceptionjava.lang.InterruptedException
-
getStatisticsMessage
public java.lang.String getStatisticsMessage()
Returns a message describing the overall statistics of the compression run- Returns:
- A string
-
createEntrySupplier
private org.apache.commons.compress.archivers.zip.ZipArchiveEntryRequestSupplier createEntrySupplier(org.apache.commons.compress.archivers.zip.ZipArchiveEntry zipArchiveEntry, org.apache.commons.compress.parallel.InputStreamSupplier inputStreamSupplier)
-
createEntry
private org.apache.commons.compress.archivers.zip.ZipArchiveEntryRequest createEntry(org.apache.commons.compress.archivers.zip.ZipArchiveEntry zipArchiveEntry, org.apache.commons.compress.parallel.InputStreamSupplier inputStreamSupplier) throws java.io.IOException- Throws:
java.io.IOException
-
isZipHeader
private boolean isZipHeader(byte[] header)
-
prependBytesToStream
private org.apache.commons.compress.parallel.InputStreamSupplier prependBytesToStream(byte[] bytes, int len, java.io.InputStream stream)
-
-