You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by dj...@apache.org on 2009/10/05 20:54:56 UTC

svn commit: r821961 [5/30] - in /geronimo/sandbox/djencks/osgi/framework: ./ buildsupport/ buildsupport/car-maven-plugin/ buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/ buildsupport/geronimo-maven-plugin/src/main/java...

Added: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ArchiveEntry.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ArchiveEntry.java?rev=821961&view=auto
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ArchiveEntry.java (added)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ArchiveEntry.java Mon Oct  5 18:54:50 2009
@@ -0,0 +1,231 @@
+package org.apache.geronimo.system.plugin.plexus.archiver;
+
+/**
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ *  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.
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.geronimo.system.plugin.plexus.io.attributes.PlexusIoResourceAttributeUtils;
+import org.apache.geronimo.system.plugin.plexus.io.attributes.PlexusIoResourceAttributes;
+import org.apache.geronimo.system.plugin.plexus.io.resources.PlexusIoFileResource;
+import org.apache.geronimo.system.plugin.plexus.io.resources.PlexusIoResource;
+import org.apache.geronimo.system.plugin.plexus.io.resources.PlexusIoResourceWithAttributes;
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class ArchiveEntry
+{
+    public static final String ROLE = ArchiveEntry.class.getName();
+
+    public static final int FILE = 1;
+
+    public static final int DIRECTORY = 2;
+
+    private PlexusIoResource resource;
+
+    private String name;
+
+    private int type;
+
+    private int mode;
+
+    private PlexusIoResourceAttributes attributes;
+
+    /**
+     * @param name     the filename as it will appear in the archive
+     * @param original original filename
+     * @param type     FILE or DIRECTORY
+     * @param mode     octal unix style permissions
+     */
+    private ArchiveEntry( String name, PlexusIoResource resource, int type, int mode )
+    {
+        this.name = name;
+        this.resource = resource;
+        this.attributes =
+            ( resource instanceof PlexusIoResourceWithAttributes ) ? ( (PlexusIoResourceWithAttributes) resource ).getAttributes()
+                            : null;
+        this.type = type;
+        int permissions = mode;
+        
+        if ( mode == -1 && this.attributes == null )
+        {
+            permissions = resource.isFile() ? Archiver.DEFAULT_FILE_MODE : Archiver.DEFAULT_DIR_MODE;
+        }
+        
+        this.mode = permissions == -1 ? permissions : ( permissions & UnixStat.PERM_MASK ) |
+                    ( type == FILE ? UnixStat.FILE_FLAG : UnixStat.DIR_FLAG );
+    }
+
+    /**
+     * @return the filename of this entry in the archive.
+     */
+    public String getName()
+    {
+        return name;
+    }
+
+    /**
+     * @return The original file that will be stored in the archive.
+     * @deprecated As of 1.0-alpha-10, file entries are no longer backed
+     *   by files, but by instances of {@link PlexusIoResource}.
+     *   Consequently, you should use {@link #getInputStream()}-
+     */
+    public File getFile()
+    {
+        if ( resource instanceof PlexusIoFileResource )
+        {
+            return ((PlexusIoFileResource) resource).getFile();
+        }
+        return null;
+    }
+
+    /**
+     * @return The resource contents.
+     */
+    public InputStream getInputStream() throws IOException
+    {
+        return resource.getContents();
+    }
+    
+    /**
+     * TODO: support for SYMLINK?
+     *
+     * @return FILE or DIRECTORY
+     */
+    public int getType()
+    {
+        return type;
+    }
+
+    /**
+     * @return octal user/group/other unix like permissions.
+     */
+    public int getMode()
+    {
+        if ( mode != -1 )
+        {
+            return mode;
+        }
+        
+        if ( attributes != null && attributes.getOctalMode() > -1 )
+        {
+            return attributes.getOctalMode();
+        }
+        
+        return ( ( type == FILE ? Archiver.DEFAULT_FILE_MODE : Archiver.DEFAULT_DIR_MODE ) & UnixStat.PERM_MASK ) |
+                ( type == FILE ? UnixStat.FILE_FLAG : UnixStat.DIR_FLAG );
+    }
+
+    public static ArchiveEntry createFileEntry( String target, PlexusIoResource resource, int permissions )
+        throws ArchiverException
+    {
+        if ( resource.isDirectory() )
+        {
+            throw new ArchiverException( "Not a file: " + resource.getName() );
+        }
+        return new ArchiveEntry( target, resource, FILE, permissions );
+    }
+
+    public static ArchiveEntry createFileEntry( String target, File file, int permissions )
+        throws ArchiverException
+    {
+        if ( ! file.isFile() )
+        {
+            throw new ArchiverException( "Not a file: " + file );
+        }
+        
+        PlexusIoResourceAttributes attrs;
+        try
+        {
+            attrs = PlexusIoResourceAttributeUtils.getFileAttributes( file );
+        }
+        catch ( IOException e )
+        {
+            throw new ArchiverException( "Failed to read filesystem attributes for: " + file );
+        }
+        
+        final PlexusIoFileResource res =  new PlexusIoFileResource( file, attrs );
+        return new ArchiveEntry( target, res, FILE, permissions );
+    }
+
+    public static ArchiveEntry createDirectoryEntry( String target, PlexusIoResource resource, int permissions )
+        throws ArchiverException
+    {
+        if ( ! resource.isDirectory() )
+        {
+            throw new ArchiverException( "Not a directory: " + resource.getName() );
+        }
+        return new ArchiveEntry( target, resource, DIRECTORY, permissions );
+    }
+
+    public static ArchiveEntry createDirectoryEntry( String target, final File file, int permissions )
+        throws ArchiverException
+    {
+        if ( ! file.isDirectory() )
+        {
+            throw new ArchiverException( "Not a directory: " + file );
+        }
+        
+        PlexusIoResourceAttributes attrs;
+        try
+        {
+            attrs = PlexusIoResourceAttributeUtils.getFileAttributes( file );
+        }
+        catch ( IOException e )
+        {
+            throw new ArchiverException( "Failed to read filesystem attributes for: " + file );
+        }
+        
+        final PlexusIoFileResource res = new PlexusIoFileResource( file, attrs );
+        return new ArchiveEntry( target, res, DIRECTORY, permissions );
+    }
+
+    public static ArchiveEntry createEntry( String target, File file, int filePerm, int dirPerm )
+        throws ArchiverException
+    {
+        if ( file.isDirectory() )
+        {
+            return createDirectoryEntry( target, file, dirPerm );
+        }
+        else if ( file.isFile() )
+        {
+            return createFileEntry( target, file, filePerm );
+        }
+        else // FIXME: handle symlinks?
+        {
+            throw new ArchiverException( "Neither a file nor a directory: " + file );
+        }
+    }
+    
+    public PlexusIoResourceAttributes getResourceAttributes()
+    {
+        return attributes;
+    }
+    
+    public void setResourceAttributes( PlexusIoResourceAttributes attributes )
+    {
+        this.attributes = attributes;
+    }
+
+    public PlexusIoResource getResource()
+    {
+        return resource;
+    }
+}

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ArchiveEntry.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ArchiveEntry.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ArchiveEntry.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ArchiveFile.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ArchiveFile.java?rev=821961&view=auto
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ArchiveFile.java (added)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ArchiveFile.java Mon Oct  5 18:54:50 2009
@@ -0,0 +1,53 @@
+package org.apache.geronimo.system.plugin.plexus.archiver;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Enumeration;
+
+
+/**
+ * Interface of a zip, or tar file.
+ */
+public interface ArchiveFile
+{
+    /**
+     * Interfave of a archive file entry. An entry may be a file,
+     * or directory.
+     */
+    public interface Entry
+    {
+        /**
+         * Returns the entries name.
+         */
+        String getName();
+
+        /**
+         * Returns, whether the entry is a directory.
+         */
+        boolean isDirectory();
+
+        /**
+         * Returns the time of the entries last modification.
+         * @return Modification time, or -1, if unknown.
+         */
+        long getLastModificationTime();
+
+        /**
+         * Returns the entries size.
+         * @return File size; undefined for directories.
+         */
+        long getSize();
+    }
+
+    /**
+     * Returns an enumeration with the archive files entries.
+     * Any element returned by the enumeration is an instance
+     * of {@link Entry}.
+     */
+    public Enumeration getEntries() throws IOException;
+
+    /**
+     * Returns an {@link InputStream} with the given entries contents.
+     */
+    InputStream getInputStream(Entry entry) throws IOException;
+}

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ArchiveFile.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ArchiveFile.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ArchiveFile.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ArchiveFileFilter.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ArchiveFileFilter.java?rev=821961&view=auto
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ArchiveFileFilter.java (added)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ArchiveFileFilter.java Mon Oct  5 18:54:50 2009
@@ -0,0 +1,14 @@
+package org.apache.geronimo.system.plugin.plexus.archiver;
+
+import java.io.InputStream;
+
+/**
+ * @deprecated Use {@link FileSelector}
+ */
+public interface ArchiveFileFilter
+{
+    
+    boolean include( InputStream dataStream, String entryName )
+        throws ArchiveFilterException;
+
+}

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ArchiveFileFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ArchiveFileFilter.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ArchiveFileFilter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ArchiveFilterException.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ArchiveFilterException.java?rev=821961&view=auto
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ArchiveFilterException.java (added)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ArchiveFilterException.java Mon Oct  5 18:54:50 2009
@@ -0,0 +1,17 @@
+package org.apache.geronimo.system.plugin.plexus.archiver;
+
+public class ArchiveFilterException
+    extends Exception
+{
+
+    public ArchiveFilterException( String message, Throwable cause )
+    {
+        super( message, cause );
+    }
+
+    public ArchiveFilterException( String message )
+    {
+        super( message );
+    }
+
+}

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ArchiveFilterException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ArchiveFilterException.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ArchiveFilterException.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ArchiveFinalizer.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ArchiveFinalizer.java?rev=821961&view=auto
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ArchiveFinalizer.java (added)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ArchiveFinalizer.java Mon Oct  5 18:54:50 2009
@@ -0,0 +1,16 @@
+package org.apache.geronimo.system.plugin.plexus.archiver;
+
+import java.util.List;
+
+public interface ArchiveFinalizer
+{
+    
+    void finalizeArchiveCreation( Archiver archiver )
+        throws ArchiverException;
+    
+    void finalizeArchiveExtraction( UnArchiver unarchiver )
+        throws ArchiverException;
+    
+    List getVirtualFiles();
+
+}

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ArchiveFinalizer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ArchiveFinalizer.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ArchiveFinalizer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ArchivedFileSet.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ArchivedFileSet.java?rev=821961&view=auto
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ArchivedFileSet.java (added)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ArchivedFileSet.java Mon Oct  5 18:54:50 2009
@@ -0,0 +1,17 @@
+package org.apache.geronimo.system.plugin.plexus.archiver;
+
+import java.io.File;
+
+
+/**
+ * A file set, which consists of the files and directories in
+ * an archive.
+ * @since 1.0-alpha-9
+ */
+public interface ArchivedFileSet extends BaseFileSet
+{
+    /**
+     * Returns the archive file.
+     */
+    File getArchive();
+}

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ArchivedFileSet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ArchivedFileSet.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ArchivedFileSet.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/Archiver.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/Archiver.java?rev=821961&view=auto
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/Archiver.java (added)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/Archiver.java Mon Oct  5 18:54:50 2009
@@ -0,0 +1,262 @@
+package org.apache.geronimo.system.plugin.plexus.archiver;
+
+/**
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ *  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.
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.geronimo.system.plugin.plexus.io.resources.PlexusIoResource;
+import org.apache.geronimo.system.plugin.plexus.io.resources.PlexusIoResourceCollection;
+
+/**
+ * @version $Revision$ $Date$
+ */
+public interface Archiver
+{
+    /**
+     * Default value for the dirmode attribute.
+     */
+    int DEFAULT_DIR_MODE = UnixStat.DIR_FLAG | UnixStat.DEFAULT_DIR_PERM;
+
+    /**
+     * Default value for the filemode attribute.
+     */
+    int DEFAULT_FILE_MODE = UnixStat.FILE_FLAG | UnixStat.DEFAULT_FILE_PERM;
+    
+    String ROLE = Archiver.class.getName();
+
+    public static final String DUPLICATES_ADD = "add";
+
+    public static final String DUPLICATES_PRESERVE = "preserve";
+
+    public static final String DUPLICATES_SKIP = "skip";
+
+    public static final String DUPLICATES_FAIL = "fail";
+    
+    public static final Set DUPLICATES_VALID_BEHAVIORS = new HashSet()
+    {
+        private static final long serialVersionUID = 1L;
+
+        {
+            add( DUPLICATES_ADD );
+            add( DUPLICATES_PRESERVE );
+            add( DUPLICATES_SKIP );
+            add( DUPLICATES_FAIL );
+        }
+    };
+    
+    void createArchive()
+        throws ArchiverException, IOException;
+
+    /**
+     * Obsolete, use {@link #addFileSet(FileSet)}.
+     */
+    void addDirectory( File directory )
+        throws ArchiverException;
+
+    /**
+     * Obsolete, use {@link #addFileSet(FileSet)}.
+     */
+    void addDirectory( File directory, String prefix )
+        throws ArchiverException;
+
+    /**
+     * Obsolete, use {@link #addFileSet(FileSet)}.
+     */
+    void addDirectory( File directory, String[] includes, String[] excludes )
+        throws ArchiverException;
+
+    /**
+     * Obsolete, use {@link #addFileSet(FileSet)}.
+     */
+    void addDirectory( File directory, String prefix, String[] includes, String[] excludes )
+        throws ArchiverException;
+
+    /**
+     * Adds the given file set to the archive.
+     * This method is basically obsoleting {@link #addDirectory(File)},
+     * {@link #addDirectory(File, String)}, {@link #addDirectory(File, String[], String[])},
+     * and {@link #addDirectory(File, String, String[], String[])}. However, as these
+     * methods are in widespread use, they cannot easily be made deprecated.
+     * @throws ArchiverException Adding the file set failed.
+     * @since 1.0-alpha-9
+     */
+    void addFileSet( FileSet fileSet ) throws ArchiverException;
+
+    void addFile( File inputFile, String destFileName )
+        throws ArchiverException;
+
+    void addFile( File inputFile, String destFileName, int permissions )
+        throws ArchiverException;
+
+    void addArchivedFileSet( File archiveFile )
+        throws ArchiverException;
+
+    void addArchivedFileSet( File archiveFile, String prefix )
+        throws ArchiverException;
+
+    void addArchivedFileSet( File archiveFile, String[] includes, String[] excludes )
+        throws ArchiverException;
+
+    void addArchivedFileSet( File archiveFile, String prefix, String[] includes, String[] excludes )
+        throws ArchiverException;
+
+    /**
+     * Adds the given archive file set to the archive.
+     * This method is basically obsoleting {@link #addArchivedFileSet(File)},
+     * {@link #addArchivedFileSet(File, String[], String[])}, and
+     * {@link #addArchivedFileSet(File, String, String[], String[])}.
+     * However, as these methods are in widespread use, they cannot easily
+     * be made deprecated.
+     * @since 1.0-alpha-9
+     */
+    void addArchivedFileSet( ArchivedFileSet fileSet )
+        throws ArchiverException;
+
+    /**
+     * Adds the given resource collection to the archive.
+     * @since 1.0-alpha-10
+     */
+    void addResource( PlexusIoResource resource, String destFileName, int permissions )
+        throws ArchiverException;
+
+    /**
+     * Adds the given resource collection to the archive.
+     * @since 1.0-alpha-10
+     */
+    void addResources( PlexusIoResourceCollection resources )
+        throws ArchiverException;
+
+    File getDestFile();
+
+    void setDestFile( File destFile );
+    
+    void setFileMode( int mode );
+    
+    int getFileMode();
+    
+    int getOverrideFileMode();
+
+    void setDefaultFileMode( int mode );
+
+    int getDefaultFileMode();
+    
+    void setDirectoryMode( int mode );
+    
+    int getDirectoryMode();
+    
+    int getOverrideDirectoryMode();
+
+    void setDefaultDirectoryMode( int mode );
+
+    int getDefaultDirectoryMode();
+
+    boolean getIncludeEmptyDirs();
+
+    void setIncludeEmptyDirs( boolean includeEmptyDirs );
+
+    void setDotFileDirectory( File dotFileDirectory );
+
+    /**
+     * Returns an iterator over instances of {@link ArchiveEntry},
+     * which have previously been added by calls to
+     * {@link #addResources(PlexusIoResourceCollection)},
+     *  {@link #addResource(PlexusIoResource, String, int)},
+     *  {@link #addFileSet(FileSet)}, etc.
+     * @since 1.0-alpha-10
+     */
+    ResourceIterator getResources() throws ArchiverException;
+    
+    /**
+     * @deprecated Use {@link #getResources()}
+     */
+    Map getFiles();
+
+    /**
+     * <p>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.</p>
+     * <p>An archiver doesn't necessarily support checks for uptodate. If
+     * so, setting this option to true will simply be ignored. The method
+     * {@link #isSupportingForced()} may be called to check whether an
+     * archiver does support uptodate checks.</p>
+     * @return True, if the target archive should always be created; false
+     *   otherwise
+     * @see #setForced(boolean)
+     * @see #isSupportingForced()
+     */
+    boolean isForced();
+
+    /**
+     * <p>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.</p>
+     * <p>An archiver doesn't necessarily support checks for uptodate. If
+     * so, setting this option to true will simply be ignored. The method
+     * {@link #isSupportingForced()} may be called to check whether an
+     * archiver does support uptodate checks.</p>
+     * @param forced True, if the target archive should always be created; false
+     *   otherwise
+     * @see #isForced()
+     * @see #isSupportingForced()
+     */
+    void setForced( boolean forced );
+
+    /**
+     * Returns, whether the archive supports uptodate checks. If so, you
+     * may set {@link #setForced(boolean)} to true.
+     * @return True, if the archiver does support uptodate checks, false
+     *   otherwise
+     * @see #setForced(boolean)
+     * @see #isForced()
+     */
+    boolean isSupportingForced();
+
+    /**
+     * Returns the behavior of this archiver when duplicate files are detected.
+     */
+    String getDuplicateBehavior();
+
+    /**
+     * Set the behavior of this archiver when duplicate files are detected. One of: <br/>
+     * <ul>
+     * <li>add - Add the duplicates to the archive as duplicate entries</li>
+     * <li>skip/preserve - Leave the first entry encountered in the archive, skip the new one</li>
+     * <li>fail - throw an {@link ArchiverException}</li>
+     * </ul>
+     * <br/>
+     * See {@link Archiver#DUPLICATES_ADD}, {@link Archiver#DUPLICATES_SKIP}, {@link Archiver#DUPLICATES_PRESERVE},
+     * {@link Archiver#DUPLICATES_FAIL}.
+     */
+    void setDuplicateBehavior( String duplicate );
+}

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/Archiver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/Archiver.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/Archiver.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ArchiverException.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ArchiverException.java?rev=821961&view=auto
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ArchiverException.java (added)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ArchiverException.java Mon Oct  5 18:54:50 2009
@@ -0,0 +1,31 @@
+package org.apache.geronimo.system.plugin.plexus.archiver;
+
+/**
+ * Copyright 2004 The Apache Software Foundation
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ */
+
+public class ArchiverException
+    extends Exception
+{
+    public ArchiverException( String message )
+    {
+        super( message );
+    }
+
+    public ArchiverException( String message, Throwable cause )
+    {
+        super( message, cause );
+    }
+}

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ArchiverException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ArchiverException.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ArchiverException.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/BaseFileSet.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/BaseFileSet.java?rev=821961&view=auto
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/BaseFileSet.java (added)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/BaseFileSet.java Mon Oct  5 18:54:50 2009
@@ -0,0 +1,53 @@
+package org.apache.geronimo.system.plugin.plexus.archiver;
+
+import org.apache.geronimo.system.plugin.plexus.io.fileselectors.FileSelector;
+
+
+/**
+ * A file set is a set of files, which may be added to an
+ * archive.
+ * @since 1.0-alpha-9
+ */
+public interface BaseFileSet
+{
+    /**
+     * Returns the prefix, which the file sets contents shall
+     * have.
+     */
+    String getPrefix();
+
+    /**
+     * Returns a string of patterns, which included files
+     * should match.
+     */
+    String[] getIncludes();
+
+    /**
+     * Returns a string of patterns, which excluded files
+     * should match.
+     */
+    String[] getExcludes();
+
+    /**
+     * Returns, whether the include/exclude patterns are
+     * case sensitive.
+     */
+    boolean isCaseSensitive();
+
+    /**
+     * Returns, whether the default excludes are being
+     * applied.
+     */
+    boolean isUsingDefaultExcludes();
+
+    /**
+     * Returns, whether empty directories are being included.
+     */
+    boolean isIncludingEmptyDirectories();
+
+    /**
+     * Returns a set of file selectors, which should be used
+     * to select the included files.
+     */
+    FileSelector[] getFileSelectors();
+}

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/BaseFileSet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/BaseFileSet.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/BaseFileSet.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/DotDirectiveArchiveFinalizer.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/DotDirectiveArchiveFinalizer.java?rev=821961&view=auto
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/DotDirectiveArchiveFinalizer.java (added)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/DotDirectiveArchiveFinalizer.java Mon Oct  5 18:54:50 2009
@@ -0,0 +1,103 @@
+package org.apache.geronimo.system.plugin.plexus.archiver;
+
+import org.apache.geronimo.system.plugin.plexus.util.FileUtils;
+import org.apache.geronimo.system.plugin.plexus.util.StringUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+
+/**
+ * An @{link ArchiveFinalizer} that process dot files with archiver directives
+ * contained within. This basically means you can communicate archive creation
+ * instructions between processes using dot files.
+ *
+ * @author Jason van Zyl
+ */
+public class DotDirectiveArchiveFinalizer
+    extends AbstractArchiveFinalizer
+{
+    private static String DEFAULT_DOT_FILE_PREFIX = ".plxarc";
+
+    private File dotFileDirectory;
+
+    private String dotFilePrefix;
+
+    public DotDirectiveArchiveFinalizer( File dotFileDirectory )
+    {
+        this( dotFileDirectory, DEFAULT_DOT_FILE_PREFIX );
+    }
+
+    public DotDirectiveArchiveFinalizer( File dotFileDirectory,
+                                         String dotFilePrefix )
+    {
+        this.dotFileDirectory = dotFileDirectory;
+
+        this.dotFilePrefix = dotFilePrefix;
+    }
+
+    public void finalizeArchiveCreation( Archiver archiver )
+        throws ArchiverException
+    {
+        try
+        {
+            List dotFiles = FileUtils.getFiles( dotFileDirectory, dotFilePrefix + "*", null );
+
+            for ( Iterator i = dotFiles.iterator(); i.hasNext(); )
+            {
+                File dotFile = (File) i.next();
+
+                BufferedReader in = new BufferedReader( new FileReader( dotFile ) );
+
+                String line;
+
+                while ( ( line = in.readLine() ) != null )
+                {
+                    String[] s = StringUtils.split( line, ":" );
+
+                    if ( s.length == 1 )
+                    {
+                        File directory = new File( dotFileDirectory, s[0] );
+
+                        System.out.println( "adding directory = " + directory );
+
+                        archiver.addDirectory( directory );
+                    }
+                    else
+                    {
+                        File directory = new File( dotFileDirectory, s[0] );
+
+                        System.out.println( "adding directory = " + directory + " to: " + s[1] );
+
+                        if ( s[1].endsWith( "/" ) )
+                        {
+                            archiver.addDirectory( directory, s[1] );
+                        }
+                        else
+                        {
+                            archiver.addDirectory( directory, s[1] + "/" );
+                        }
+                    }
+                }
+
+                in.close();
+            }
+
+        }
+        catch ( IOException e )
+        {
+            throw new ArchiverException( "Error processing dot files.", e );
+        }
+    }
+
+    public List getVirtualFiles()
+    {
+        return Collections.EMPTY_LIST;
+
+    }
+}

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/DotDirectiveArchiveFinalizer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/DotDirectiveArchiveFinalizer.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/DotDirectiveArchiveFinalizer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/FileSet.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/FileSet.java?rev=821961&view=auto
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/FileSet.java (added)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/FileSet.java Mon Oct  5 18:54:50 2009
@@ -0,0 +1,17 @@
+package org.apache.geronimo.system.plugin.plexus.archiver;
+
+import java.io.File;
+
+
+/**
+ * A file set, which consists of the files and directories in
+ * a common base directory.
+ * @since 1.0-alpha-9
+ */
+public interface FileSet extends BaseFileSet
+{
+    /**
+     * Returns the file sets base directory.
+     */
+    File getDirectory();
+}

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/FileSet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/FileSet.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/FileSet.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/FilterEnabled.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/FilterEnabled.java?rev=821961&view=auto
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/FilterEnabled.java (added)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/FilterEnabled.java Mon Oct  5 18:54:50 2009
@@ -0,0 +1,14 @@
+package org.apache.geronimo.system.plugin.plexus.archiver;
+
+import java.util.List;
+
+
+/**
+ * @deprecated Use {@link FileSelector file selectors}.
+ */
+public interface FilterEnabled
+{
+    
+    void setArchiveFilters( List filters );
+
+}

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/FilterEnabled.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/FilterEnabled.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/FilterEnabled.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/FinalizerEnabled.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/FinalizerEnabled.java?rev=821961&view=auto
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/FinalizerEnabled.java (added)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/FinalizerEnabled.java Mon Oct  5 18:54:50 2009
@@ -0,0 +1,10 @@
+package org.apache.geronimo.system.plugin.plexus.archiver;
+
+import java.util.List;
+
+public interface FinalizerEnabled
+{
+    void addArchiveFinalizer( ArchiveFinalizer finalizer );
+
+    void setArchiveFinalizers( List archiveFinalizers );
+}

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/FinalizerEnabled.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/FinalizerEnabled.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/FinalizerEnabled.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ResourceIterator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ResourceIterator.java?rev=821961&view=auto
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ResourceIterator.java (added)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ResourceIterator.java Mon Oct  5 18:54:50 2009
@@ -0,0 +1,11 @@
+/**
+ * 
+ */
+package org.apache.geronimo.system.plugin.plexus.archiver;
+
+public interface ResourceIterator
+{
+    boolean hasNext() throws ArchiverException;
+
+    ArchiveEntry next() throws ArchiverException;
+}
\ No newline at end of file

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ResourceIterator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ResourceIterator.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/ResourceIterator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/UnArchiver.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/UnArchiver.java?rev=821961&view=auto
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/UnArchiver.java (added)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/UnArchiver.java Mon Oct  5 18:54:50 2009
@@ -0,0 +1,84 @@
+package org.apache.geronimo.system.plugin.plexus.archiver;
+
+/**
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ *  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.
+ */
+
+import java.io.File;
+
+import org.apache.geronimo.system.plugin.plexus.io.fileselectors.FileSelector;
+
+/**
+ * @version $Revision$ $Date$
+ */
+public interface UnArchiver
+{
+    String ROLE = UnArchiver.class.getName();
+
+    /**
+     * Extract the archive.
+     *
+     * @throws ArchiverException
+     */
+    void extract()
+        throws ArchiverException;
+
+    /**
+     * Take a patch into the archive and extract it to the specified directory.
+     *
+     * @param path Path inside the archive to be extracted.
+     * @param outputDirectory Directory to extract to.
+     * @throws ArchiverException
+     */
+    void extract( String path, File outputDirectory )
+        throws ArchiverException;
+
+    File getDestDirectory();
+
+    void setDestDirectory( File destDirectory );
+
+    //todo What is this? If you're extracting isn't it always to a directory. I think it would be cool to extract an
+    // archive to another archive but I don't think we support this right now.
+    File getDestFile();
+
+    void setDestFile( File destFile );
+
+    File getSourceFile();
+
+    void setSourceFile( File sourceFile );
+
+    /**
+     * Should we overwrite files in dest, even if they are newer than
+     * the corresponding entries in the archive?
+     */
+    void setOverwrite( boolean b );
+
+    /**
+     * Sets a set of {@link FileSelector} instances, which may be used to
+     * select the files to extract from the archive. If file selectors
+     * are present, then a file is only extracted, if it is confirmed
+     * by all file selectors.
+     */
+    void setFileSelectors( FileSelector[] selectors );
+
+    /**
+     * Returns a set of {@link FileSelector} instances, which may be used to
+     * select the files to extract from the archive. If file selectors
+     * are present, then a file is only extracted, if it is confirmed
+     * by all file selectors.
+     */
+    FileSelector[] getFileSelectors( );
+}

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/UnArchiver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/UnArchiver.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/UnArchiver.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/UnArchiverException.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/UnArchiverException.java?rev=821961&view=auto
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/UnArchiverException.java (added)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/UnArchiverException.java Mon Oct  5 18:54:50 2009
@@ -0,0 +1,24 @@
+package org.apache.geronimo.system.plugin.plexus.archiver;
+
+/**
+ * @author Jason van Zyl
+ */
+public class UnArchiverException
+    extends Exception
+{
+public UnArchiverException( String string )
+    {
+        super( string );
+    }
+
+    public UnArchiverException( String string,
+                                Throwable throwable )
+    {
+        super( string, throwable );
+    }
+
+    public UnArchiverException( Throwable throwable )
+    {
+        super( throwable );
+    }
+}

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/UnArchiverException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/UnArchiverException.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/UnArchiverException.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/UnixStat.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/UnixStat.java?rev=821961&view=auto
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/UnixStat.java (added)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/UnixStat.java Mon Oct  5 18:54:50 2009
@@ -0,0 +1,82 @@
+package org.apache.geronimo.system.plugin.plexus.archiver;
+
+/*
+ * Copyright  2001,2004 The Apache Software Foundation
+ *
+ *  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.
+ *
+ */
+
+/**
+ * Constants from stat.h on Unix systems.
+ *
+ * @version $Revision$ $Date$
+ *          from org.apache.ant.tools.zip.UnixStat v1.9
+ */
+public interface UnixStat
+{
+
+    /**
+     * Bits used for permissions (and sticky bit)
+     *
+     * @since 1.1
+     */
+    int PERM_MASK = 07777;
+
+    /**
+     * Indicates symbolic links.
+     *
+     * @since 1.1
+     */
+    int LINK_FLAG = 0120000;
+
+    /**
+     * Indicates plain files.
+     *
+     * @since 1.1
+     */
+    int FILE_FLAG = 0100000;
+
+    /**
+     * Indicates directories.
+     *
+     * @since 1.1
+     */
+    int DIR_FLAG = 040000;
+
+    // ----------------------------------------------------------
+    // somewhat arbitrary choices that are quite common for shared
+    // installations
+    // -----------------------------------------------------------
+
+    /**
+     * Default permissions for symbolic links.
+     *
+     * @since 1.1
+     */
+    int DEFAULT_LINK_PERM = 0777;
+
+    /**
+     * Default permissions for directories.
+     *
+     * @since 1.1
+     */
+    int DEFAULT_DIR_PERM = 0755;
+
+    /**
+     * Default permissions for plain files.
+     *
+     * @since 1.1
+     */
+    int DEFAULT_FILE_PERM = 0644;
+}

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/UnixStat.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/UnixStat.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/UnixStat.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/bzip2/BZip2Archiver.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/bzip2/BZip2Archiver.java?rev=821961&view=auto
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/bzip2/BZip2Archiver.java (added)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/bzip2/BZip2Archiver.java Mon Oct  5 18:54:50 2009
@@ -0,0 +1,67 @@
+package org.apache.geronimo.system.plugin.plexus.archiver.bzip2;
+
+/**
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ *  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.
+ */
+
+import java.io.IOException;
+
+import org.apache.geronimo.system.plugin.plexus.archiver.AbstractArchiver;
+import org.apache.geronimo.system.plugin.plexus.archiver.ArchiveEntry;
+import org.apache.geronimo.system.plugin.plexus.archiver.ArchiverException;
+import org.apache.geronimo.system.plugin.plexus.archiver.ResourceIterator;
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class BZip2Archiver
+    extends AbstractArchiver
+{
+    private BZip2Compressor compressor = new BZip2Compressor();
+    
+    public void execute()
+        throws ArchiverException, IOException
+    {
+    	if ( ! checkForced() )
+    	{
+    		return;
+    	}
+
+    	ResourceIterator iter = getResources();
+    	ArchiveEntry entry = iter.next();
+    	if ( iter.hasNext() )
+    	{
+            throw new ArchiverException( "There is more than one file in input." );
+        }
+        compressor.setSource( entry.getResource() );
+        compressor.setDestFile( getDestFile() );
+        compressor.compress();
+    }
+
+	public boolean isSupportingForced() {
+		return true;
+	}
+
+    protected void close()
+    {
+        compressor.close();
+    }
+
+    protected String getArchiveType()
+    {
+        return "bzip2";
+    }
+}

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/bzip2/BZip2Archiver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/bzip2/BZip2Archiver.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/bzip2/BZip2Archiver.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/bzip2/BZip2Compressor.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/bzip2/BZip2Compressor.java?rev=821961&view=auto
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/bzip2/BZip2Compressor.java (added)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/bzip2/BZip2Compressor.java Mon Oct  5 18:54:50 2009
@@ -0,0 +1,74 @@
+package org.apache.geronimo.system.plugin.plexus.archiver.bzip2;
+
+/**
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ *  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.
+ */
+
+import org.apache.geronimo.system.plugin.plexus.archiver.ArchiverException;
+import org.apache.geronimo.system.plugin.plexus.archiver.util.Compressor;
+
+import java.io.BufferedOutputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class BZip2Compressor
+    extends Compressor
+{
+    private CBZip2OutputStream zOut;
+    
+    /**
+     * perform the GZip compression operation.
+     */
+    public void compress()
+        throws ArchiverException
+    {
+        try
+        {
+            BufferedOutputStream bos =
+                new BufferedOutputStream( new FileOutputStream( getDestFile() ) );
+            bos.write( 'B' );
+            bos.write( 'Z' );
+            zOut = new CBZip2OutputStream( bos );
+            compress( getSource(), zOut );
+        }
+        catch ( IOException ioe )
+        {
+            String msg = "Problem creating bzip2 " + ioe.getMessage();
+            throw new ArchiverException( msg, ioe );
+        }
+    }
+
+    public void close()
+    {
+        if ( zOut != null )
+        {
+            try
+            {
+                // close up
+                zOut.close();
+            }
+            catch ( IOException e )
+            {
+                //ignore
+            }
+            
+            zOut = null;
+        }
+    }
+}

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/bzip2/BZip2Compressor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/bzip2/BZip2Compressor.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/bzip2/BZip2Compressor.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/bzip2/BZip2Constants.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/bzip2/BZip2Constants.java?rev=821961&view=auto
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/bzip2/BZip2Constants.java (added)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/bzip2/BZip2Constants.java Mon Oct  5 18:54:50 2009
@@ -0,0 +1,110 @@
+package org.apache.geronimo.system.plugin.plexus.archiver.bzip2;
+
+/*
+ * Copyright  2001,2004 The Apache Software Foundation
+ *
+ *  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.
+ *
+ */
+
+/*
+ * This package is based on the work done by Keiron Liddle, Aftex Software
+ * <ke...@aftexsw.com> to whom the Ant project is very grateful for his
+ * great code.
+ */
+
+/**
+ * Base class for both the compress and decompress classes.
+ * Holds common arrays, and static data.
+ *
+ * @version $Revision$ $Date$
+ *          from org.apache.ant.tools.bzip2.BZip2Constants v1.8
+ */
+public interface BZip2Constants
+{
+
+    int baseBlockSize = 100000;
+
+    int MAX_ALPHA_SIZE = 258;
+
+    int MAX_CODE_LEN = 23;
+
+    int RUNA = 0;
+
+    int RUNB = 1;
+
+    int N_GROUPS = 6;
+
+    int G_SIZE = 50;
+
+    int N_ITERS = 4;
+
+    int MAX_SELECTORS = ( 2 + ( 900000 / G_SIZE ) );
+
+    int NUM_OVERSHOOT_BYTES = 20;
+
+    int[] rNums = {
+        619, 720, 127, 481, 931, 816, 813, 233, 566, 247,
+        985, 724, 205, 454, 863, 491, 741, 242, 949, 214,
+        733, 859, 335, 708, 621, 574, 73, 654, 730, 472,
+        419, 436, 278, 496, 867, 210, 399, 680, 480, 51,
+        878, 465, 811, 169, 869, 675, 611, 697, 867, 561,
+        862, 687, 507, 283, 482, 129, 807, 591, 733, 623,
+        150, 238, 59, 379, 684, 877, 625, 169, 643, 105,
+        170, 607, 520, 932, 727, 476, 693, 425, 174, 647,
+        73, 122, 335, 530, 442, 853, 695, 249, 445, 515,
+        909, 545, 703, 919, 874, 474, 882, 500, 594, 612,
+        641, 801, 220, 162, 819, 984, 589, 513, 495, 799,
+        161, 604, 958, 533, 221, 400, 386, 867, 600, 782,
+        382, 596, 414, 171, 516, 375, 682, 485, 911, 276,
+        98, 553, 163, 354, 666, 933, 424, 341, 533, 870,
+        227, 730, 475, 186, 263, 647, 537, 686, 600, 224,
+        469, 68, 770, 919, 190, 373, 294, 822, 808, 206,
+        184, 943, 795, 384, 383, 461, 404, 758, 839, 887,
+        715, 67, 618, 276, 204, 918, 873, 777, 604, 560,
+        951, 160, 578, 722, 79, 804, 96, 409, 713, 940,
+        652, 934, 970, 447, 318, 353, 859, 672, 112, 785,
+        645, 863, 803, 350, 139, 93, 354, 99, 820, 908,
+        609, 772, 154, 274, 580, 184, 79, 626, 630, 742,
+        653, 282, 762, 623, 680, 81, 927, 626, 789, 125,
+        411, 521, 938, 300, 821, 78, 343, 175, 128, 250,
+        170, 774, 972, 275, 999, 639, 495, 78, 352, 126,
+        857, 956, 358, 619, 580, 124, 737, 594, 701, 612,
+        669, 112, 134, 694, 363, 992, 809, 743, 168, 974,
+        944, 375, 748, 52, 600, 747, 642, 182, 862, 81,
+        344, 805, 988, 739, 511, 655, 814, 334, 249, 515,
+        897, 955, 664, 981, 649, 113, 974, 459, 893, 228,
+        433, 837, 553, 268, 926, 240, 102, 654, 459, 51,
+        686, 754, 806, 760, 493, 403, 415, 394, 687, 700,
+        946, 670, 656, 610, 738, 392, 760, 799, 887, 653,
+        978, 321, 576, 617, 626, 502, 894, 679, 243, 440,
+        680, 879, 194, 572, 640, 724, 926, 56, 204, 700,
+        707, 151, 457, 449, 797, 195, 791, 558, 945, 679,
+        297, 59, 87, 824, 713, 663, 412, 693, 342, 606,
+        134, 108, 571, 364, 631, 212, 174, 643, 304, 329,
+        343, 97, 430, 751, 497, 314, 983, 374, 822, 928,
+        140, 206, 73, 263, 980, 736, 876, 478, 430, 305,
+        170, 514, 364, 692, 829, 82, 855, 953, 676, 246,
+        369, 970, 294, 750, 807, 827, 150, 790, 288, 923,
+        804, 378, 215, 828, 592, 281, 565, 555, 710, 82,
+        896, 831, 547, 261, 524, 462, 293, 465, 502, 56,
+        661, 821, 976, 991, 658, 869, 905, 758, 745, 193,
+        768, 550, 608, 933, 378, 286, 215, 979, 792, 961,
+        61, 688, 793, 644, 986, 403, 106, 366, 905, 644,
+        372, 567, 466, 434, 645, 210, 389, 550, 919, 135,
+        780, 773, 635, 389, 707, 100, 626, 958, 165, 504,
+        920, 176, 193, 713, 857, 265, 203, 50, 668, 108,
+        645, 990, 626, 197, 510, 357, 358, 850, 858, 364,
+        936, 638
+    };
+}

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/bzip2/BZip2Constants.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/bzip2/BZip2Constants.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/bzip2/BZip2Constants.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/bzip2/BZip2UnArchiver.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/bzip2/BZip2UnArchiver.java?rev=821961&view=auto
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/bzip2/BZip2UnArchiver.java (added)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/bzip2/BZip2UnArchiver.java Mon Oct  5 18:54:50 2009
@@ -0,0 +1,152 @@
+package org.apache.geronimo.system.plugin.plexus.archiver.bzip2;
+
+/**
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ *  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.
+ */
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.geronimo.system.plugin.plexus.archiver.AbstractUnArchiver;
+import org.apache.geronimo.system.plugin.plexus.archiver.ArchiverException;
+
+/**
+ * @author <a href="mailto:evenisse@codehaus.org">Emmanuel Venisse</a>
+ * @version $Revision$ $Date$
+ */
+public class BZip2UnArchiver
+    extends AbstractUnArchiver
+{
+    public BZip2UnArchiver()
+    {
+    }
+
+    public BZip2UnArchiver( File sourceFile )
+    {
+        super( sourceFile );
+    }
+
+    protected void execute()
+        throws ArchiverException
+    {
+        if ( getSourceFile().lastModified() > getDestFile().lastModified() )
+        {
+            getLogger().info( "Expanding " + getSourceFile().getAbsolutePath() + " to "
+                              + getDestFile().getAbsolutePath() );
+
+            FileOutputStream out = null;
+            CBZip2InputStream zIn = null;
+            FileInputStream fis = null;
+            BufferedInputStream bis = null;
+            try
+            {
+                out = new FileOutputStream( getDestFile() );
+                fis = new FileInputStream( getSourceFile() );
+                bis = new BufferedInputStream( fis );
+                zIn = getBZip2InputStream( bis );
+                if ( zIn == null )
+                {
+                    throw new ArchiverException( getSourceFile().getAbsolutePath() + " is an invalid bz2 file." );
+                }
+                byte[] buffer = new byte[8 * 1024];
+                int count = 0;
+                do
+                {
+                    out.write( buffer, 0, count );
+                    count = zIn.read( buffer, 0, buffer.length );
+                }
+                while ( count != -1 );
+            }
+            catch ( IOException ioe )
+            {
+                String msg = "Problem expanding bzip2 " + ioe.getMessage();
+                throw new ArchiverException( msg, ioe );
+            }
+            finally
+            {
+                if ( bis != null )
+                {
+                    try
+                    {
+                        bis.close();
+                    }
+                    catch ( IOException ioex )
+                    {
+                        // ignore
+                    }
+                }
+                if ( fis != null )
+                {
+                    try
+                    {
+                        fis.close();
+                    }
+                    catch ( IOException ioex )
+                    {
+                        // ignore
+                    }
+                }
+                if ( out != null )
+                {
+                    try
+                    {
+                        out.close();
+                    }
+                    catch ( IOException ioex )
+                    {
+                        // ignore
+                    }
+                }
+                if ( zIn != null )
+                {
+                    try
+                    {
+                        zIn.close();
+                    }
+                    catch ( IOException ioex )
+                    {
+                        // ignore
+                    }
+                }
+            }
+        }
+    }
+
+    public static CBZip2InputStream getBZip2InputStream( InputStream bis )
+        throws IOException
+    {
+        int b = bis.read();
+        if ( b != 'B' )
+        {
+            return null;
+        }
+        b = bis.read();
+        if ( b != 'Z' )
+        {
+            return null;
+        }
+        return new CBZip2InputStream( bis );
+    }
+
+    protected void execute( String path, File outputDirectory )
+    {
+        throw new UnsupportedOperationException( "Targeted extraction not supported in BZIP2 format." );
+    }
+}

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/bzip2/BZip2UnArchiver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/bzip2/BZip2UnArchiver.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/bzip2/BZip2UnArchiver.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain