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: AbstractArchiver.java 4896 2006-11-29 03:35:19Z jvanzyl $

Field Summary
static int DEFAULT_DIR_MODE
          Default value for the dirmode attribute.
static int DEFAULT_FILE_MODE
          Default value for the filemode attribute.
 
Fields inherited from interface org.codehaus.plexus.archiver.Archiver
ROLE
 
Constructor Summary
AbstractArchiver()
           
 
Method Summary
 void addArchivedFileSet(java.io.File archiveFile)
           
 void addArchivedFileSet(java.io.File archiveFile, java.lang.String prefix)
           
 void addArchivedFileSet(java.io.File archiveFile, java.lang.String[] includes, java.lang.String[] excludes)
           
 void addArchivedFileSet(java.io.File archiveFile, java.lang.String prefix, java.lang.String[] includes, java.lang.String[] excludes)
           
 void addArchiveFinalizer(ArchiveFinalizer finalizer)
           
 void addDirectory(java.io.File directory)
           
 void addDirectory(java.io.File directory, java.lang.String prefix)
           
 void addDirectory(java.io.File directory, java.lang.String[] includes, java.lang.String[] excludes)
           
 void addDirectory(java.io.File directory, java.lang.String prefix, java.lang.String[] includes, java.lang.String[] excludes)
           
 void addFile(java.io.File inputFile, java.lang.String destFileName)
           
 void addFile(java.io.File inputFile, java.lang.String destFileName, int permissions)
           
protected  boolean checkForced()
           
protected abstract  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  java.util.List getArchiveFinalizers()
           
protected abstract  java.lang.String getArchiveType()
           
 int getDefaultDirectoryMode()
           
 int getDefaultFileMode()
           
 java.io.File getDestFile()
           
 java.util.Map getDirs()
           
 java.util.Map getFiles()
           
 boolean getIncludeEmptyDirs()
           
protected  org.codehaus.plexus.logging.Logger getLogger()
           
protected  boolean hasVirtualFiles()
           
 boolean isForced()
          Returns, whether recreating the archive is forced (default).
 boolean isSupportingForced()
          Returns, whether the archive supports uptodate checks.
protected  boolean isUptodate()
           
protected  boolean revert(java.lang.StringBuffer messageBuffer)
           
protected  void runArchiveFinalizers()
           
 void setArchiveFilters(java.util.List filters)
           
 void setArchiveFinalizers(java.util.List archiveFinalizers)
           
 void setDefaultDirectoryMode(int mode)
           
 void setDefaultFileMode(int mode)
           
 void setDestFile(java.io.File destFile)
           
 void setDotFileDirectory(java.io.File dotFileDirectory)
           
 void setForced(boolean forced)
          Sets, whether recreating the archive is forced (default).
 void setIncludeEmptyDirs(boolean includeEmptyDirs)
           
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
 

Field Detail

DEFAULT_DIR_MODE

public static final int DEFAULT_DIR_MODE
Default value for the dirmode attribute.

See Also:
Constant Field Values

DEFAULT_FILE_MODE

public static final int DEFAULT_FILE_MODE
Default value for the filemode attribute.

See Also:
Constant Field Values
Constructor Detail

AbstractArchiver

public AbstractArchiver()
Method Detail

setDefaultFileMode

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

getDefaultFileMode

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

setDefaultDirectoryMode

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

getDefaultDirectoryMode

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

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(java.io.File directory)
                  throws ArchiverException
Specified by:
addDirectory in interface Archiver
Throws:
ArchiverException

addDirectory

public void addDirectory(java.io.File directory,
                         java.lang.String prefix)
                  throws ArchiverException
Specified by:
addDirectory in interface Archiver
Throws:
ArchiverException

addDirectory

public void addDirectory(java.io.File directory,
                         java.lang.String[] includes,
                         java.lang.String[] excludes)
                  throws ArchiverException
Specified by:
addDirectory in interface Archiver
Throws:
ArchiverException

addDirectory

public void addDirectory(java.io.File directory,
                         java.lang.String prefix,
                         java.lang.String[] includes,
                         java.lang.String[] excludes)
                  throws ArchiverException
Specified by:
addDirectory in interface Archiver
Throws:
ArchiverException

addFile

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

addFile

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

getFiles

public java.util.Map getFiles()
Specified by:
getFiles in interface Archiver

getDestFile

public java.io.File getDestFile()
Specified by:
getDestFile in interface Archiver

setDestFile

public void setDestFile(java.io.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 java.util.Map getDirs()

addArchivedFileSet

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

addArchivedFileSet

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

addArchivedFileSet

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

addArchivedFileSet

public void addArchivedFileSet(java.io.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(java.util.List filters)
Specified by:
setArchiveFilters in interface FilterEnabled

addArchiveFinalizer

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

setArchiveFinalizers

public void setArchiveFinalizers(java.util.List archiveFinalizers)
Specified by:
setArchiveFinalizers in interface FinalizerEnabled

setDotFileDirectory

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

isUptodate

protected boolean isUptodate()

checkForced

protected boolean checkForced()

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 java.util.List getArchiveFinalizers()

runArchiveFinalizers

protected void runArchiveFinalizers()
                             throws ArchiverException
Throws:
ArchiverException

createArchive

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

hasVirtualFiles

protected boolean hasVirtualFiles()

revert

protected boolean revert(java.lang.StringBuffer messageBuffer)

validate

protected void validate()
                 throws ArchiverException,
                        java.io.IOException
Throws:
ArchiverException
java.io.IOException

getArchiveType

protected abstract java.lang.String getArchiveType()

close

protected abstract void close()
                       throws java.io.IOException
Throws:
java.io.IOException

cleanUp

protected abstract void cleanUp()

execute

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


Copyright © 2001-2006 Codehaus. All Rights Reserved.