org.codehaus.plexus.archiver
Class AbstractArchiver

java.lang.Object
  extended by org.codehaus.plexus.logging.AbstractLogEnabled
      extended by org.codehaus.plexus.archiver.AbstractArchiver
All Implemented Interfaces:
Archiver, FilterEnabled, FinalizerEnabled, org.codehaus.plexus.logging.LogEnabled, org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable
Direct Known Subclasses:
AbstractZipArchiver, BZip2Archiver, DirectoryArchiver, GZipArchiver, TarArchiver

public abstract class AbstractArchiver
extends org.codehaus.plexus.logging.AbstractLogEnabled
implements Archiver, org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable, FilterEnabled, FinalizerEnabled

Version:
$Id$

Field Summary
 
Fields inherited from interface org.codehaus.plexus.archiver.Archiver
DEFAULT_DIR_MODE, DEFAULT_FILE_MODE, DUPLICATES_ADD, DUPLICATES_FAIL, DUPLICATES_PRESERVE, DUPLICATES_SKIP, DUPLICATES_VALID_BEHAVIORS, ROLE
 
Constructor Summary
AbstractArchiver()
           
 
Method Summary
 void addArchivedFileSet(ArchivedFileSet fileSet)
          Adds the given archive file set to the archive.
 void addArchivedFileSet(File archiveFile)
           
 void addArchivedFileSet(File archiveFile, String prefix)
           
 void addArchivedFileSet(File archiveFile, String[] includes, String[] excludes)
           
 void addArchivedFileSet(File archiveFile, String prefix, String[] includes, String[] excludes)
           
 void addArchiveFinalizer(ArchiveFinalizer finalizer)
           
 void addDirectory(File directory)
          Obsolete, use Archiver.addFileSet(FileSet).
 void addDirectory(File directory, String prefix)
          Obsolete, use Archiver.addFileSet(FileSet).
 void addDirectory(File directory, String[] includes, String[] excludes)
          Obsolete, use Archiver.addFileSet(FileSet).
 void addDirectory(File directory, String prefix, String[] includes, String[] excludes)
          Obsolete, use Archiver.addFileSet(FileSet).
 void addFile(File inputFile, String destFileName)
           
 void addFile(File inputFile, String destFileName, int permissions)
           
 void addFileSet(FileSet fileSet)
          Adds the given file set to the archive.
 void addResource(org.codehaus.plexus.components.io.resources.PlexusIoResource resource, String destFileName, int permissions)
          Adds the given resource collection to the archive.
 void addResources(org.codehaus.plexus.components.io.resources.PlexusIoResourceCollection collection)
          Adds a resource collection to the archive.
protected  ArchiveEntry asArchiveEntry(org.codehaus.plexus.components.io.resources.PlexusIoResourceCollection collection, org.codehaus.plexus.components.io.resources.PlexusIoResource resource)
           
protected  ArchiveEntry asArchiveEntry(org.codehaus.plexus.components.io.resources.PlexusIoResource resource, String destFileName, int permissions)
           
protected  org.codehaus.plexus.components.io.resources.PlexusIoResourceCollection asResourceCollection(ArchivedFileSet fileSet)
           
protected  boolean checkForced()
           
protected  void cleanUp()
           
protected abstract  void close()
           
 void contextualize(org.codehaus.plexus.context.Context context)
          Allows us to pull the ArchiverManager instance out of the container without causing a chicken-and-egg instantiation/composition problem.
 void createArchive()
           
protected abstract  void execute()
           
protected  List getArchiveFinalizers()
           
protected abstract  String getArchiveType()
           
 int getDefaultDirectoryMode()
           
 int getDefaultFileMode()
           
 File getDestFile()
           
 int getDirectoryMode()
           
 Map getDirs()
           
 String getDuplicateBehavior()
          Returns the behavior of this archiver when duplicate files are detected.
 int getFileMode()
           
 Map getFiles()
           
 boolean getIncludeEmptyDirs()
           
protected  org.codehaus.plexus.logging.Logger getLogger()
           
 int getOverrideDirectoryMode()
           
 int getOverrideFileMode()
           
 int getRawDefaultDirectoryMode()
          Deprecated. Use Archiver.getDefaultDirectoryMode().
 int getRawDefaultFileMode()
          Deprecated. Use Archiver.getDefaultFileMode().
 ResourceIterator getResources()
          Returns an iterator over instances of ArchiveEntry, which have previously been added by calls to Archiver.addResources(PlexusIoResourceCollection), Archiver.addResource(PlexusIoResource, String, int), Archiver.addFileSet(FileSet), etc.
protected  boolean hasVirtualFiles()
           
 boolean isForced()
           Returns, whether recreating the archive is forced (default).
 boolean isIgnorePermissions()
           
 boolean isSupportingForced()
          Returns, whether the archive supports uptodate checks.
protected  boolean isUptodate()
           
 boolean isUseJvmChmod()
           
protected  boolean revert(StringBuffer messageBuffer)
           
protected  void runArchiveFinalizers()
           
 void setArchiveFilters(List filters)
           
 void setArchiveFinalizers(List<ArchiveFinalizer> archiveFinalizers)
           
 void setDefaultDirectoryMode(int mode)
           
 void setDefaultFileMode(int mode)
           
 void setDestFile(File destFile)
           
 void setDirectoryMode(int mode)
           
 void setDotFileDirectory(File dotFileDirectory)
           
 void setDuplicateBehavior(String duplicate)
          Set the behavior of this archiver when duplicate files are detected.
 void setFileMode(int mode)
           
 void setForced(boolean forced)
           Sets, whether recreating the archive is forced (default).
 void setIgnorePermissions(boolean ignorePermissions)
           
 void setIncludeEmptyDirs(boolean includeEmptyDirs)
           
 void setUseJvmChmod(boolean useJvmChmod)
          to use or not the jvm method for file permissions : user all not active for group permissions
protected  void validate()
           
 
Methods inherited from class org.codehaus.plexus.logging.AbstractLogEnabled
enableLogging, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractArchiver

public AbstractArchiver()
Method Detail

getDuplicateBehavior

public String getDuplicateBehavior()
Description copied from interface: Archiver
Returns the behavior of this archiver when duplicate files are detected.

Specified by:
getDuplicateBehavior in interface Archiver

setDuplicateBehavior

public void setDuplicateBehavior(String duplicate)
Description copied from interface: Archiver
Set the behavior of this archiver when duplicate files are detected. One of:

See Archiver.DUPLICATES_ADD, Archiver.DUPLICATES_SKIP, Archiver.DUPLICATES_PRESERVE, Archiver.DUPLICATES_FAIL.

Specified by:
setDuplicateBehavior in interface Archiver

setFileMode

public final void setFileMode(int mode)
Specified by:
setFileMode in interface Archiver

setDefaultFileMode

public final void setDefaultFileMode(int mode)
Specified by:
setDefaultFileMode in interface Archiver

getOverrideFileMode

public final int getOverrideFileMode()
Specified by:
getOverrideFileMode in interface Archiver

getFileMode

public final int getFileMode()
Specified by:
getFileMode in interface Archiver

getDefaultFileMode

public final int getDefaultFileMode()
Specified by:
getDefaultFileMode in interface Archiver

getRawDefaultFileMode

public final int getRawDefaultFileMode()
Deprecated. Use Archiver.getDefaultFileMode().


setDirectoryMode

public final void setDirectoryMode(int mode)
Specified by:
setDirectoryMode in interface Archiver

setDefaultDirectoryMode

public final void setDefaultDirectoryMode(int mode)
Specified by:
setDefaultDirectoryMode in interface Archiver

getOverrideDirectoryMode

public final int getOverrideDirectoryMode()
Specified by:
getOverrideDirectoryMode in interface Archiver

getDirectoryMode

public final int getDirectoryMode()
Specified by:
getDirectoryMode in interface Archiver

getDefaultDirectoryMode

public final int getDefaultDirectoryMode()
Specified by:
getDefaultDirectoryMode in interface Archiver

getRawDefaultDirectoryMode

public final int getRawDefaultDirectoryMode()
Deprecated. Use Archiver.getDefaultDirectoryMode().


getIncludeEmptyDirs

public boolean getIncludeEmptyDirs()
Specified by:
getIncludeEmptyDirs in interface Archiver

setIncludeEmptyDirs

public void setIncludeEmptyDirs(boolean includeEmptyDirs)
Specified by:
setIncludeEmptyDirs in interface Archiver

addDirectory

public void addDirectory(File directory)
                  throws ArchiverException
Description copied from interface: Archiver
Obsolete, use Archiver.addFileSet(FileSet).

Specified by:
addDirectory in interface Archiver
Throws:
ArchiverException

addDirectory

public void addDirectory(File directory,
                         String prefix)
                  throws ArchiverException
Description copied from interface: Archiver
Obsolete, use Archiver.addFileSet(FileSet).

Specified by:
addDirectory in interface Archiver
Throws:
ArchiverException

addDirectory

public void addDirectory(File directory,
                         String[] includes,
                         String[] excludes)
                  throws ArchiverException
Description copied from interface: Archiver
Obsolete, use Archiver.addFileSet(FileSet).

Specified by:
addDirectory in interface Archiver
Throws:
ArchiverException

addDirectory

public void addDirectory(File directory,
                         String prefix,
                         String[] includes,
                         String[] excludes)
                  throws ArchiverException
Description copied from interface: Archiver
Obsolete, use Archiver.addFileSet(FileSet).

Specified by:
addDirectory in interface Archiver
Throws:
ArchiverException

addFileSet

public void addFileSet(FileSet fileSet)
                throws ArchiverException
Description copied from interface: Archiver
Adds the given file set to the archive. This method is basically obsoleting Archiver.addDirectory(File), Archiver.addDirectory(File, String), Archiver.addDirectory(File, String[], String[]), and Archiver.addDirectory(File, String, String[], String[]). However, as these methods are in widespread use, they cannot easily be made deprecated.

Specified by:
addFileSet in interface Archiver
Throws:
ArchiverException - Adding the file set failed.

addFile

public void addFile(File inputFile,
                    String destFileName)
             throws ArchiverException
Specified by:
addFile in interface Archiver
Throws:
ArchiverException

asArchiveEntry

protected ArchiveEntry asArchiveEntry(org.codehaus.plexus.components.io.resources.PlexusIoResource resource,
                                      String destFileName,
                                      int permissions)
                               throws ArchiverException
Throws:
ArchiverException

asArchiveEntry

protected ArchiveEntry asArchiveEntry(org.codehaus.plexus.components.io.resources.PlexusIoResourceCollection collection,
                                      org.codehaus.plexus.components.io.resources.PlexusIoResource resource)
                               throws ArchiverException
Throws:
ArchiverException

addResource

public void addResource(org.codehaus.plexus.components.io.resources.PlexusIoResource resource,
                        String destFileName,
                        int permissions)
                 throws ArchiverException
Description copied from interface: Archiver
Adds the given resource collection to the archive.

Specified by:
addResource in interface Archiver
Throws:
ArchiverException

addFile

public void addFile(File inputFile,
                    String destFileName,
                    int permissions)
             throws ArchiverException
Specified by:
addFile in interface Archiver
Throws:
ArchiverException

getResources

public ResourceIterator getResources()
                              throws ArchiverException
Description copied from interface: Archiver
Returns an iterator over instances of ArchiveEntry, which have previously been added by calls to Archiver.addResources(PlexusIoResourceCollection), Archiver.addResource(PlexusIoResource, String, int), Archiver.addFileSet(FileSet), etc.

Specified by:
getResources in interface Archiver
Throws:
ArchiverException

getFiles

public Map getFiles()
Specified by:
getFiles in interface Archiver

getDestFile

public File getDestFile()
Specified by:
getDestFile in interface Archiver

setDestFile

public void setDestFile(File destFile)
Specified by:
setDestFile in interface Archiver

getLogger

protected org.codehaus.plexus.logging.Logger getLogger()
Overrides:
getLogger in class org.codehaus.plexus.logging.AbstractLogEnabled

getDirs

public Map getDirs()

asResourceCollection

protected org.codehaus.plexus.components.io.resources.PlexusIoResourceCollection asResourceCollection(ArchivedFileSet fileSet)
                                                                                               throws ArchiverException
Throws:
ArchiverException

addResources

public void addResources(org.codehaus.plexus.components.io.resources.PlexusIoResourceCollection collection)
                  throws ArchiverException
Adds a resource collection to the archive.

Specified by:
addResources in interface Archiver
Throws:
ArchiverException

addArchivedFileSet

public void addArchivedFileSet(ArchivedFileSet fileSet)
                        throws ArchiverException
Description copied from interface: Archiver
Adds the given archive file set to the archive. This method is basically obsoleting Archiver.addArchivedFileSet(File), Archiver.addArchivedFileSet(File, String[], String[]), and Archiver.addArchivedFileSet(File, String, String[], String[]). However, as these methods are in widespread use, they cannot easily be made deprecated.

Specified by:
addArchivedFileSet in interface Archiver
Throws:
ArchiverException

addArchivedFileSet

public void addArchivedFileSet(File archiveFile,
                               String prefix,
                               String[] includes,
                               String[] excludes)
                        throws ArchiverException
Specified by:
addArchivedFileSet in interface Archiver
Throws:
ArchiverException
Since:
1.0-alpha-7

addArchivedFileSet

public void addArchivedFileSet(File archiveFile,
                               String prefix)
                        throws ArchiverException
Specified by:
addArchivedFileSet in interface Archiver
Throws:
ArchiverException
Since:
1.0-alpha-7

addArchivedFileSet

public void addArchivedFileSet(File archiveFile,
                               String[] includes,
                               String[] excludes)
                        throws ArchiverException
Specified by:
addArchivedFileSet in interface Archiver
Throws:
ArchiverException
Since:
1.0-alpha-7

addArchivedFileSet

public void addArchivedFileSet(File archiveFile)
                        throws ArchiverException
Specified by:
addArchivedFileSet in interface Archiver
Throws:
ArchiverException
Since:
1.0-alpha-7

contextualize

public void contextualize(org.codehaus.plexus.context.Context context)
                   throws org.codehaus.plexus.context.ContextException
Allows us to pull the ArchiverManager instance out of the container without causing a chicken-and-egg instantiation/composition problem.

Specified by:
contextualize in interface org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable
Throws:
org.codehaus.plexus.context.ContextException

isForced

public boolean isForced()
Description copied from interface: Archiver

Returns, whether recreating the archive is forced (default). Setting this option to false means, that the archiver should compare the timestamps of included files with the timestamp of the target archive and rebuild the archive only, if the latter timestamp precedes the former timestamps. Checking for timestamps will typically offer a performance gain (in particular, if the following steps in a build can be suppressed, if an archive isn't recrated) on the cost that you get inaccurate results from time to time. In particular, removal of source files won't be detected.

An archiver doesn't necessarily support checks for uptodate. If so, setting this option to true will simply be ignored. The method Archiver.isSupportingForced() may be called to check whether an archiver does support uptodate checks.

Specified by:
isForced in interface Archiver
Returns:
True, if the target archive should always be created; false otherwise
See Also:
Archiver.setForced(boolean), Archiver.isSupportingForced()

setForced

public void setForced(boolean forced)
Description copied from interface: Archiver

Sets, whether recreating the archive is forced (default). Setting this option to false means, that the archiver should compare the timestamps of included files with the timestamp of the target archive and rebuild the archive only, if the latter timestamp precedes the former timestamps. Checking for timestamps will typically offer a performance gain (in particular, if the following steps in a build can be suppressed, if an archive isn't recrated) on the cost that you get inaccurate results from time to time. In particular, removal of source files won't be detected.

An archiver doesn't necessarily support checks for uptodate. If so, setting this option to true will simply be ignored. The method Archiver.isSupportingForced() may be called to check whether an archiver does support uptodate checks.

Specified by:
setForced in interface Archiver
Parameters:
forced - True, if the target archive should always be created; false otherwise
See Also:
Archiver.isForced(), Archiver.isSupportingForced()

setArchiveFilters

public void setArchiveFilters(List filters)
Specified by:
setArchiveFilters in interface FilterEnabled

addArchiveFinalizer

public void addArchiveFinalizer(ArchiveFinalizer finalizer)
Specified by:
addArchiveFinalizer in interface FinalizerEnabled

setArchiveFinalizers

public void setArchiveFinalizers(List<ArchiveFinalizer> archiveFinalizers)
Specified by:
setArchiveFinalizers in interface FinalizerEnabled

setDotFileDirectory

public void setDotFileDirectory(File dotFileDirectory)
Specified by:
setDotFileDirectory in interface Archiver

isUptodate

protected boolean isUptodate()
                      throws ArchiverException
Throws:
ArchiverException

checkForced

protected boolean checkForced()
                       throws ArchiverException
Throws:
ArchiverException

isSupportingForced

public boolean isSupportingForced()
Description copied from interface: Archiver
Returns, whether the archive supports uptodate checks. If so, you may set Archiver.setForced(boolean) to true.

Specified by:
isSupportingForced in interface Archiver
Returns:
True, if the archiver does support uptodate checks, false otherwise
See Also:
Archiver.setForced(boolean), Archiver.isForced()

getArchiveFinalizers

protected List getArchiveFinalizers()

runArchiveFinalizers

protected void runArchiveFinalizers()
                             throws ArchiverException
Throws:
ArchiverException

createArchive

public final void createArchive()
                         throws ArchiverException,
                                IOException
Specified by:
createArchive in interface Archiver
Throws:
ArchiverException
IOException

hasVirtualFiles

protected boolean hasVirtualFiles()

revert

protected boolean revert(StringBuffer messageBuffer)

validate

protected void validate()
                 throws ArchiverException,
                        IOException
Throws:
ArchiverException
IOException

getArchiveType

protected abstract String getArchiveType()

close

protected abstract void close()
                       throws IOException
Throws:
IOException

cleanUp

protected void cleanUp()

execute

protected abstract void execute()
                         throws ArchiverException,
                                IOException
Throws:
ArchiverException
IOException

isUseJvmChmod

public boolean isUseJvmChmod()
Specified by:
isUseJvmChmod in interface Archiver
Returns:
Since:
1.1

setUseJvmChmod

public void setUseJvmChmod(boolean useJvmChmod)
Description copied from interface: Archiver
to use or not the jvm method for file permissions : user all not active for group permissions

Specified by:
setUseJvmChmod in interface Archiver
Since:
1.1

isIgnorePermissions

public boolean isIgnorePermissions()
Specified by:
isIgnorePermissions in interface Archiver
Since:
1.1

setIgnorePermissions

public void setIgnorePermissions(boolean ignorePermissions)
Specified by:
setIgnorePermissions in interface Archiver
Since:
1.1


Copyright © 2008-2012 Sonatype, Inc.. All Rights Reserved.