Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0B01C9552 for ; Sun, 25 Sep 2011 05:01:04 +0000 (UTC) Received: (qmail 88377 invoked by uid 500); 25 Sep 2011 05:01:03 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 88185 invoked by uid 500); 25 Sep 2011 05:01:03 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 88155 invoked by uid 99); 25 Sep 2011 05:01:02 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 25 Sep 2011 05:01:02 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 25 Sep 2011 05:00:59 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 276322388A02 for ; Sun, 25 Sep 2011 05:00:38 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1175296 - in /commons/proper/vfs/trunk: core/src/main/java/org/apache/commons/vfs2/provider/zip/ZipFileSystem.java src/changes/changes.xml Date: Sun, 25 Sep 2011 05:00:38 -0000 To: commits@commons.apache.org From: rgoers@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20110925050038.276322388A02@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: rgoers Date: Sun Sep 25 05:00:37 2011 New Revision: 1175296 URL: http://svn.apache.org/viewvc?rev=1175296&view=rev Log: ZipFileSystem now uses an internal HashMap to cache FileObjects that are in the zip archive Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/zip/ZipFileSystem.java commons/proper/vfs/trunk/src/changes/changes.xml Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/zip/ZipFileSystem.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/zip/ZipFileSystem.java?rev=1175296&r1=1175295&r2=1175296&view=diff ============================================================================== --- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/zip/ZipFileSystem.java (original) +++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/zip/ZipFileSystem.java Sun Sep 25 05:00:37 2011 @@ -21,13 +21,16 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.Enumeration; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.commons.vfs2.Capability; +import org.apache.commons.vfs2.FileName; import org.apache.commons.vfs2.FileObject; import org.apache.commons.vfs2.FileSystem; import org.apache.commons.vfs2.FileSystemException; @@ -50,6 +53,11 @@ public class ZipFileSystem extends Abstr private final File file; private ZipFile zipFile; + /** + * Cache doesn't need to be synchronized since it is read-only. + */ + private Map cache = new HashMap(); + public ZipFileSystem(final AbstractFileName rootName, final FileObject parentLayer, final FileSystemOptions fileSystemOptions) @@ -198,6 +206,30 @@ public class ZipFileSystem extends Abstr } /** + * Adds a file object to the cache. + */ + protected void putFileToCache(final FileObject file) + { + cache.put(file.getName(), file); + } + + /** + * Returns a cached file. + */ + protected FileObject getFileFromCache(final FileName name) + { + return cache.get(name); + } + + /** + * remove a cached file. + */ + protected void removeFileFromCache(final FileName name) + { + cache.remove(name); + } + + /** * will be called after all file-objects closed their streams. protected void notifyAllStreamsClosed() { Modified: commons/proper/vfs/trunk/src/changes/changes.xml URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/src/changes/changes.xml?rev=1175296&r1=1175295&r2=1175296&view=diff ============================================================================== --- commons/proper/vfs/trunk/src/changes/changes.xml (original) +++ commons/proper/vfs/trunk/src/changes/changes.xml Sun Sep 25 05:00:37 2011 @@ -23,6 +23,9 @@ + + ZipFileSystem now uses an internal Map as a cache for all the files in the zip archive. + Chain the SftpException in the FileSystemException.