commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ima...@apache.org
Subject cvs commit: jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/zip ZipFileObject.java ZipFileSystem.java
Date Sun, 04 Jul 2004 18:45:56 GMT
imario      2004/07/04 11:45:56

  Modified:    vfs/src/java/org/apache/commons/vfs/provider
                        AbstractFileObject.java AbstractFileProvider.java
                        AbstractFileSystem.java
               vfs/src/java/org/apache/commons/vfs/impl
                        DefaultFileSystemManager.java
               vfs/src/java/org/apache/commons/vfs/provider/ftp
                        FtpFileSystem.java
               vfs/src/java/org/apache/commons/vfs/provider/http
                        HttpFileSystem.java
               vfs/src/java/org/apache/commons/vfs/provider/jar
                        JarFileObject.java JarFileSystem.java
               vfs/src/java/org/apache/commons/vfs/provider/sftp
                        SftpFileObject.java SftpFileProvider.java
                        SftpFileSystem.java
               vfs/src/java/org/apache/commons/vfs/provider/zip
                        ZipFileObject.java ZipFileSystem.java
  Log:
  DefaultFileSystemManager.releaseUnusedResources()
  
  e.g. to release the underlaying communication link
  
  Revision  Changes    Path
  1.49      +37 -27    jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/AbstractFileObject.java
  
  Index: AbstractFileObject.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/AbstractFileObject.java,v
  retrieving revision 1.48
  retrieving revision 1.49
  diff -u -r1.48 -r1.49
  --- AbstractFileObject.java	30 Jun 2004 19:06:38 -0000	1.48
  +++ AbstractFileObject.java	4 Jul 2004 18:45:55 -0000	1.49
  @@ -1083,19 +1083,24 @@
        */
       private void detach() throws Exception
       {
  -        if (attached)
  +        synchronized (this)
           {
  -            try
  -            {
  -                doDetach();
  -            }
  -            finally
  +            if (attached)
               {
  -                attached = false;
  -                type = null;
  +                try
  +                {
  +                    doDetach();
  +                }
  +                finally
  +                {
  +                    attached = false;
  +                    type = null;
   
  -                removeChildrenCache();
  -                // children = null;
  +                    fs.fileDetached(this);
  +
  +                    removeChildrenCache();
  +                    // children = null;
  +                }
               }
           }
       }
  @@ -1121,29 +1126,34 @@
        */
       private void attach() throws FileSystemException
       {
  -        if (attached)
  +        synchronized (this)
           {
  -            return;
  -        }
  +            if (attached)
  +            {
  +                return;
  +            }
   
  -        try
  -        {
  -            // Attach and determine the file type
  -            doAttach();
  -            attached = true;
  -            // now the type could already be injected by doAttach (e.g from parent to child)
  -            if (type == null)
  +            try
               {
  -                type = doGetType();
  +                // Attach and determine the file type
  +                doAttach();
  +                attached = true;
  +                // now the type could already be injected by doAttach (e.g from parent
to child)
  +                if (type == null)
  +                {
  +                    type = doGetType();
  +                }
  +                if (type == null)
  +                {
  +                    type = FileType.IMAGINARY;
  +                }
               }
  -            if (type == null)
  +            catch (Exception exc)
               {
  -                type = FileType.IMAGINARY;
  +                throw new FileSystemException("vfs.provider/get-type.error", new Object[]{name},
exc);
               }
  -        }
  -        catch (Exception exc)
  -        {
  -            throw new FileSystemException("vfs.provider/get-type.error", new Object[]{name},
exc);
  +
  +            fs.fileAttached(this);
           }
       }
   
  
  
  
  1.13      +14 -0     jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/AbstractFileProvider.java
  
  Index: AbstractFileProvider.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/AbstractFileProvider.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- AbstractFileProvider.java	19 May 2004 19:34:06 -0000	1.12
  +++ AbstractFileProvider.java	4 Jul 2004 18:45:55 -0000	1.13
  @@ -21,6 +21,7 @@
   import org.apache.commons.vfs.FileSystemException;
   import org.apache.commons.vfs.FileSystemOptions;
   
  +import java.util.Iterator;
   import java.util.Map;
   import java.util.TreeMap;
   
  @@ -94,5 +95,18 @@
       public FileSystemConfigBuilder getConfigBuilder()
       {
           return null;
  +    }
  +
  +    public void freeUnusedResources()
  +    {
  +        Iterator iterFileSystems = fileSystems.values().iterator();
  +        while (iterFileSystems.hasNext())
  +        {
  +            AbstractFileSystem fs = (AbstractFileSystem) iterFileSystems.next();
  +            if (fs.isReleaseable())
  +            {
  +                fs.closeCommunicationLink();
  +            }
  +        }
       }
   }
  
  
  
  1.28      +60 -3     jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/AbstractFileSystem.java
  
  Index: AbstractFileSystem.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/AbstractFileSystem.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- AbstractFileSystem.java	30 Jun 2004 19:06:38 -0000	1.27
  +++ AbstractFileSystem.java	4 Jul 2004 18:45:55 -0000	1.28
  @@ -70,6 +70,11 @@
        */
       private final FileSystemOptions fileSystemOptions;
   
  +    /**
  +     * How many files are activley using the filesystem
  +     */
  +    private long useCount;
  +
       protected AbstractFileSystem(final FileName rootName,
                                    final FileObject parentLayer,
                                    final FileSystemOptions fileSystemOptions)
  @@ -94,8 +99,33 @@
        */
       public void close()
       {
  -        // Clean-up
  -        files.clear(this);
  +        try
  +        {
  +            closeCommunicationLink();
  +        }
  +        finally
  +        {
  +            // Clean-up
  +            files.clear(this);
  +        }
  +    }
  +
  +    /**
  +     * Close the underlaying link used to access the files
  +     */
  +    protected void closeCommunicationLink()
  +    {
  +        synchronized (this)
  +        {
  +            doCloseCommunicationLink();
  +        }
  +    }
  +
  +    /**
  +     * Close the underlaying link used to access the files
  +     */
  +    protected void doCloseCommunicationLink()
  +    {
       }
   
       /**
  @@ -232,7 +262,10 @@
           {
               try
               {
  -                file = createFile(name);
  +                synchronized (this)
  +                {
  +                    file = createFile(name);
  +                }
               }
               catch (Exception e)
               {
  @@ -368,6 +401,19 @@
       }
   
       /**
  +     * returns true if no file is using this filesystem
  +     */
  +    public boolean isReleaseable()
  +    {
  +        return useCount < 1;
  +    }
  +
  +    void freeResources()
  +    {
  +
  +    }
  +
  +    /**
        * Fires an event.
        */
       private void fireEvent(final ChangeEvent event)
  @@ -392,6 +438,17 @@
                   }
               }
           }
  +    }
  +
  +    void fileDetached(FileObject fileObject)
  +    {
  +        useCount--;
  +    }
  +
  +    void fileAttached(FileObject fileObject)
  +    {
  +        useCount++;
  +
       }
   
       /**
  
  
  
  1.33      +19 -0     jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/impl/DefaultFileSystemManager.java
  
  Index: DefaultFileSystemManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/impl/DefaultFileSystemManager.java,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- DefaultFileSystemManager.java	28 Jun 2004 19:44:57 -0000	1.32
  +++ DefaultFileSystemManager.java	4 Jul 2004 18:45:56 -0000	1.33
  @@ -24,6 +24,7 @@
   import org.apache.commons.vfs.FileSystemOptions;
   import org.apache.commons.vfs.FilesCache;
   import org.apache.commons.vfs.cache.DefaultFilesCache;
  +import org.apache.commons.vfs.provider.AbstractFileProvider;
   import org.apache.commons.vfs.provider.DefaultURLStreamHandler;
   import org.apache.commons.vfs.provider.FileProvider;
   import org.apache.commons.vfs.provider.FileReplicator;
  @@ -393,6 +394,24 @@
           fileReplicator = null;
           tempFileStore = null;
           init = false;
  +    }
  +
  +    /**
  +     * Free all resources used by unused filesystems created by this manager.
  +     */
  +    public void freeUnusedResources()
  +    {
  +        if (!init)
  +        {
  +            return;
  +        }
  +
  +        // Close the providers.
  +        for (Iterator iterator = providers.values().iterator(); iterator.hasNext();)
  +        {
  +            final AbstractFileProvider provider = (AbstractFileProvider) iterator.next();
  +            provider.freeUnusedResources();
  +        }
       }
   
       /**
  
  
  
  1.30      +1 -3      jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/ftp/FtpFileSystem.java
  
  Index: FtpFileSystem.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/ftp/FtpFileSystem.java,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- FtpFileSystem.java	26 May 2004 08:21:18 -0000	1.29
  +++ FtpFileSystem.java	4 Jul 2004 18:45:56 -0000	1.30
  @@ -57,15 +57,13 @@
           idleClient = ftpClient;
       }
   
  -    public void close()
  +    protected void doCloseCommunicationLink()
       {
           // Clean up the connection
           if (idleClient != null)
           {
               closeConnection(idleClient);
           }
  -
  -        super.close();
       }
   
       /**
  
  
  
  1.11      +1 -2      jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/http/HttpFileSystem.java
  
  Index: HttpFileSystem.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/http/HttpFileSystem.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- HttpFileSystem.java	27 May 2004 19:09:37 -0000	1.10
  +++ HttpFileSystem.java	4 Jul 2004 18:45:56 -0000	1.11
  @@ -34,7 +34,6 @@
   public class HttpFileSystem
       extends AbstractFileSystem
       implements FileSystem
  -
   {
       private final HttpClient client;
   
  
  
  
  1.12      +10 -7     jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/jar/JarFileObject.java
  
  Index: JarFileObject.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/jar/JarFileObject.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- JarFileObject.java	10 May 2004 20:09:50 -0000	1.11
  +++ JarFileObject.java	4 Jul 2004 18:45:56 -0000	1.12
  @@ -16,6 +16,7 @@
   package org.apache.commons.vfs.provider.jar;
   
   import org.apache.commons.vfs.FileName;
  +import org.apache.commons.vfs.FileSystemException;
   import org.apache.commons.vfs.provider.zip.ZipFileObject;
   
   import java.io.IOException;
  @@ -28,7 +29,6 @@
   import java.util.jar.JarFile;
   import java.util.jar.Manifest;
   import java.util.zip.ZipEntry;
  -import java.util.zip.ZipFile;
   
   /**
    * A file in a Jar file system.
  @@ -40,12 +40,15 @@
   {
       private Attributes attributes;
   
  +    final JarFileSystem fs;
  +
       public JarFileObject(final FileName name,
                            final ZipEntry entry,
  -                         final ZipFile zipFile,
  -                         final JarFileSystem fs)
  +                         final JarFileSystem fs,
  +                         final boolean zipExists) throws FileSystemException
       {
  -        super(name, entry, zipFile, fs);
  +        super(name, entry, fs, zipExists);
  +        this.fs = fs;
       }
   
       /**
  @@ -53,12 +56,12 @@
        */
       Manifest getManifest() throws IOException
       {
  -        if (file == null)
  +        if (fs.getZipFile() == null)
           {
               return null;
           }
   
  -        return ((JarFile) file).getManifest();
  +        return ((JarFile) fs.getZipFile()).getManifest();
       }
   
       /**
  
  
  
  1.19      +24 -5     jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/jar/JarFileSystem.java
  
  Index: JarFileSystem.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/jar/JarFileSystem.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- JarFileSystem.java	19 May 2004 19:34:06 -0000	1.18
  +++ JarFileSystem.java	4 Jul 2004 18:45:56 -0000	1.19
  @@ -13,6 +13,21 @@
    * See the License for the specific language governing permissions and
    * limitations under the License.
    */
  +/*
  + * Copyright 2002, 2003,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.
  + */
   package org.apache.commons.vfs.provider.jar;
   
   import org.apache.commons.vfs.FileName;
  @@ -63,10 +78,9 @@
       }
   
       protected ZipFileObject createZipFileObject(FileName name,
  -                                                ZipEntry entry,
  -                                                ZipFile file)
  +                                                ZipEntry entry) throws FileSystemException
       {
  -        return new JarFileObject(name, entry, file, this);
  +        return new JarFileObject(name, entry, this, true);
       }
   
       /**
  @@ -82,7 +96,7 @@
       {
           if (attributes == null)
           {
  -            final Manifest man = ((JarFile) zipFile).getManifest();
  +            final Manifest man = ((JarFile) getZipFile()).getManifest();
               if (man == null)
               {
                   attributes = new Attributes(1);
  @@ -199,5 +213,10 @@
       {
           final Name name = lookupName(attrName);
           return getAttribute(name);
  +    }
  +
  +    protected ZipFile getZipFile() throws FileSystemException
  +    {
  +        return super.getZipFile();
       }
   }
  
  
  
  1.10      +33 -1     jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/sftp/SftpFileObject.java
  
  Index: SftpFileObject.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/sftp/SftpFileObject.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- SftpFileObject.java	24 May 2004 20:15:26 -0000	1.9
  +++ SftpFileObject.java	4 Jul 2004 18:45:56 -0000	1.10
  @@ -147,6 +147,38 @@
       }
   
       /**
  +     * Sets the last modified time of this file.  Is only called if
  +     * {@link #doGetType} does not return {@link FileType#IMAGINARY}.
  +     * <p/>
  +     *
  +     * @param modtime is modification time in milliseconds. SFTP protocol can
  +     *                send times with nanosecond precision but at the moment jsch send
them
  +     *                with second precision.
  +     */
  +    /** Wait for jsch release
  +     protected void doSetLastModifiedTime(final long modtime)
  +     throws Exception
  +     {
  +     final ChannelSftp channel = fileSystem.getChannel();
  +     try
  +     {
  +     int newMTime = (int) (modtime / 1000L);
  +
  +     // this was the only way to make the long to int preserving accuracy
  +     // String str = "" + modtime;
  +     // int newMTime = Integer.parseInt(str.substring(0, str.length() - 3));
  +
  +     attrs.setACMODTIME(attrs.getATime(), newMTime);
  +     channel.setStat(getName().getPath(), attrs);
  +     }
  +     finally
  +     {
  +     fileSystem.putChannel(channel);
  +     }
  +     }
  +     */
  +
  +    /**
        * Deletes the file.
        */
       protected void doDelete()
  
  
  
  1.14      +4 -3      jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/sftp/SftpFileProvider.java
  
  Index: SftpFileProvider.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/sftp/SftpFileProvider.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- SftpFileProvider.java	30 Jun 2004 19:06:38 -0000	1.13
  +++ SftpFileProvider.java	4 Jul 2004 18:45:56 -0000	1.14
  @@ -48,8 +48,9 @@
           Capability.READ_CONTENT,
           Capability.URI,
           Capability.WRITE_CONTENT,
  -        Capability.GET_LAST_MODIFIED,
  -        Capability.SET_LAST_MODIFIED_FILE
  +        Capability.GET_LAST_MODIFIED
  +        // wait for jsch release
  +        // Capability.SET_LAST_MODIFIED_FILE
       }));
   
       public final static String ATTR_USER_INFO = "UI";
  
  
  
  1.13      +29 -23    jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/sftp/SftpFileSystem.java
  
  Index: SftpFileSystem.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/sftp/SftpFileSystem.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- SftpFileSystem.java	30 Jun 2004 19:06:38 -0000	1.12
  +++ SftpFileSystem.java	4 Jul 2004 18:45:56 -0000	1.13
  @@ -39,7 +39,7 @@
       extends AbstractFileSystem
       implements FileSystem
   {
  -    private final Session session;
  +    private Session session;
       // private final JSch jSch;
       private ChannelSftp idleChannel;
   
  @@ -51,16 +51,19 @@
           this.session = session;
       }
   
  -    /**
  -     * Closes this file system.
  -     */
  -    public void close()
  +    protected void doCloseCommunicationLink()
       {
  +        if (idleChannel != null)
  +        {
  +            idleChannel.disconnect();
  +            idleChannel = null;
  +        }
  +
           if (session != null)
           {
               session.disconnect();
  +            session = null;
           }
  -        super.close();
       }
   
       /**
  @@ -68,27 +71,30 @@
        */
       protected ChannelSftp getChannel() throws IOException
       {
  -        /*
  -        try
  +        if (this.session == null)
           {
  -            // Create the session
  -            if (session == null)
  +            // channel closed. e.g. by freeUnusedResources, but now we need it again
  +            Session session;
  +            try
               {
                   final GenericFileName rootName = (GenericFileName) getRootName();
  -                session = jSch.getSession(rootName.getUserName(),
  -                    rootName.getHostName(),
  -                    rootName.getPort());
  -                session.setPassword(rootName.getPassword());
  -
  -                UserInfo userInfo = SftpFileSystemConfigBuilder.getInstance().getUserInfo(getFileSystemOptions());
  -                if (userInfo != null)
  -                {
  -                    session.setUserInfo(userInfo);
  -                }
   
  -                session.connect();
  +                session = SftpClientFactory.createConnection(rootName.getHostName(),
  +                    rootName.getPort(),
  +                    rootName.getUserName(),
  +                    rootName.getPassword(),
  +                    getFileSystemOptions());
               }
  -            */
  +            catch (final Exception e)
  +            {
  +                throw new FileSystemException("vfs.provider.sftp/connect.error",
  +                    getRootName(),
  +                    e);
  +            }
  +
  +            this.session = session;
  +        }
  +
           try
           {
               // Use the pooled channel, or create a new one
  
  
  
  1.16      +8 -7      jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/zip/ZipFileObject.java
  
  Index: ZipFileObject.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/zip/ZipFileObject.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- ZipFileObject.java	10 May 2004 20:09:54 -0000	1.15
  +++ ZipFileObject.java	4 Jul 2004 18:45:56 -0000	1.16
  @@ -17,13 +17,13 @@
   
   import org.apache.commons.vfs.FileName;
   import org.apache.commons.vfs.FileObject;
  +import org.apache.commons.vfs.FileSystemException;
   import org.apache.commons.vfs.FileType;
   import org.apache.commons.vfs.provider.AbstractFileObject;
   
   import java.io.InputStream;
   import java.util.HashSet;
   import java.util.zip.ZipEntry;
  -import java.util.zip.ZipFile;
   
   /**
    * A file in a Zip file system.
  @@ -36,19 +36,20 @@
       implements FileObject
   {
       private final HashSet children = new HashSet();
  -    protected final ZipFile file;
  +    private final ZipFileSystem fs;
  +    // protected final ZipFile file;
       protected ZipEntry entry;
       private FileType type;
   
       public ZipFileObject(FileName name,
                            ZipEntry entry,
  -                         ZipFile zipFile,
  -                         ZipFileSystem fs)
  +                         ZipFileSystem fs,
  +                         boolean zipExists) throws FileSystemException
       {
           super(name, fs);
  +        this.fs = fs;
           setZipEntry(entry);
  -        file = zipFile;
  -        if (file == null)
  +        if (!zipExists)
           {
               type = FileType.IMAGINARY;
           }
  @@ -133,6 +134,6 @@
        */
       protected InputStream doGetInputStream() throws Exception
       {
  -        return file.getInputStream(entry);
  +        return fs.getZipFile().getInputStream(entry);
       }
   }
  
  
  
  1.31      +22 -12    jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/zip/ZipFileSystem.java
  
  Index: ZipFileSystem.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/zip/ZipFileSystem.java,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- ZipFileSystem.java	19 May 2004 19:34:07 -0000	1.30
  +++ ZipFileSystem.java	4 Jul 2004 18:45:56 -0000	1.31
  @@ -46,7 +46,7 @@
       private final static Log log = LogFactory.getLog(ZipFileSystem.class);
   
       private final File file;
  -    protected final ZipFile zipFile;
  +    private ZipFile zipFile;
   
       public ZipFileSystem(final FileName rootName,
                            final FileObject parentLayer,
  @@ -74,7 +74,7 @@
           super.init();
   
           // Build the index
  -        Enumeration entries = zipFile.entries();
  +        Enumeration entries = getZipFile().entries();
           while (entries.hasMoreElements())
           {
               ZipEntry entry = (ZipEntry) entries.nextElement();
  @@ -89,7 +89,7 @@
                   continue;
               }
   
  -            fileObj = createZipFileObject(name, entry, zipFile);
  +            fileObj = createZipFileObject(name, entry);
               putFileToCache(fileObj);
   
               // Make sure all ancestors exist
  @@ -103,7 +103,7 @@
                   parent = (ZipFileObject) getFileFromCache(parentName);
                   if (parent == null)
                   {
  -                    parent = createZipFileObject(parentName, null, zipFile);
  +                    parent = createZipFileObject(parentName, null);
                       putFileToCache(parent);
                   }
   
  @@ -113,11 +113,22 @@
           }
       }
   
  +    protected ZipFile getZipFile() throws FileSystemException
  +    {
  +        if (zipFile == null && this.file.exists())
  +        {
  +            ZipFile zipFile = createZipFile(this.file);
  +
  +            this.zipFile = zipFile;
  +        }
  +
  +        return zipFile;
  +    }
  +
       protected ZipFileObject createZipFileObject(final FileName name,
  -                                                final ZipEntry entry,
  -                                                final ZipFile file)
  +                                                final ZipEntry entry) throws FileSystemException
       {
  -        return new ZipFileObject(name, entry, file, this);
  +        return new ZipFileObject(name, entry, this, true);
       }
   
       protected ZipFile createZipFile(final File file) throws FileSystemException
  @@ -132,7 +143,7 @@
           }
       }
   
  -    public void close()
  +    protected void doCloseCommunicationLink()
       {
           // Release the zip file
           try
  @@ -140,6 +151,7 @@
               if (zipFile != null)
               {
                   zipFile.close();
  +                zipFile = null;
               }
           }
           catch (final IOException e)
  @@ -147,8 +159,6 @@
               // getLogger().warn("vfs.provider.zip/close-zip-file.error :" + file, e);
               VfsLog.warn(getLogger(), log, "vfs.provider.zip/close-zip-file.error :" + file,
e);
           }
  -
  -        super.close();
       }
   
       /**
  @@ -162,9 +172,9 @@
       /**
        * Creates a file object.
        */
  -    protected FileObject createFile(final FileName name)
  +    protected FileObject createFile(final FileName name) throws FileSystemException
       {
           // This is only called for files which do not exist in the Zip file
  -        return new ZipFileObject(name, null, null, this);
  +        return new ZipFileObject(name, null, this, false);
       }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message