[jboss-osgi-commits] JBoss-OSGI SVN: r102534 - in projects/jboss-osgi/projects: spi/trunk/src/main/java/org/jboss/osgi/testing and 2 other directories.

jboss-osgi-commits at lists.jboss.org jboss-osgi-commits at lists.jboss.org
Wed Mar 17 18:22:44 EDT 2010


Author: thomas.diesler at jboss.com
Date: 2010-03-17 18:22:42 -0400 (Wed, 17 Mar 2010)
New Revision: 102534

Modified:
   projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleInfo.java
   projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/OSGiBundle.java
   projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedBundle.java
   projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedRuntime.java
   projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiBundleImpl.java
   projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiRuntimeImpl.java
   projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java
   projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java
   projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VFSAdaptor30.java
   projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VirtualFileAdaptor30.java
Log:
Add close() semantics to BundleInfo

Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleInfo.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleInfo.java	2010-03-17 21:25:33 UTC (rev 102533)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleInfo.java	2010-03-17 22:22:42 UTC (rev 102534)
@@ -243,6 +243,15 @@
       return Version.parseVersion(bundleVersion);
    }
 
+   /**
+    * Closes the accociated resources.
+    */
+   public void close()
+   {
+      if (rootFile != null)
+         rootFile.close();
+   }
+   
    private Manifest getManifest()
    {
       if (manifest == null)
@@ -324,7 +333,7 @@
 
    private String toEqualString()
    {
-      return "[" + symbolicName + "-" + bundleVersion + ",url=" + rootURL + "]";
+      return "[" + symbolicName + ":" + bundleVersion + ",url=" + rootURL + "]";
    }
 
    private static String getManifestHeaderInternal(Manifest manifest, String key)

Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/OSGiBundle.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/OSGiBundle.java	2010-03-17 21:25:33 UTC (rev 102533)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/OSGiBundle.java	2010-03-17 22:22:42 UTC (rev 102534)
@@ -25,7 +25,6 @@
 import java.net.URL;
 import java.util.Dictionary;
 
-import org.jboss.logging.Logger;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleException;
 import org.osgi.framework.Version;
@@ -36,59 +35,57 @@
  * @author Thomas.Diesler at jboss.org
  * @since 25-Sep-2008
  */
-public abstract class OSGiBundle
+public interface OSGiBundle
 {
-   // Provide logging
-   private static final Logger log = Logger.getLogger(OSGiBundle.class);
    /**
     * Get the runtime associated with this bundle.
     */
-   public abstract OSGiRuntime getRuntime();
+   OSGiRuntime getRuntime();
    
    /**
     * Returns this bundle's unique identifier.
     */
-   public abstract long getBundleId();
+   long getBundleId();
    
    /**
     * Returns the symbolic name of this bundle as specified by its Bundle-SymbolicName manifest header.
     */
-   public abstract String getSymbolicName();
+   String getSymbolicName();
 
    /**
     * Returns the version of this bundle.
     */
-   public abstract Version getVersion();
+   Version getVersion();
    
    /**
     * Returns this bundle's location.
     */
-   public abstract String getLocation();
+   String getLocation();
    
    /**
     * Returns this bundle's Manifest headers and values.
     */
-   public abstract Dictionary<String, String> getHeaders();
+   Dictionary<String, String> getHeaders();
    
    /**
     * Returns this bundle's Manifest headers and values localized to the specified locale.
     */
-   public abstract Dictionary<String, String> getHeaders(String locale);
+   Dictionary<String, String> getHeaders(String locale);
    
    /**
     * Returns this bundle's current state.
     */
-   public abstract int getState();
+   int getState();
 
    /**
     * Returns the value of the specified property.
     */
-   public abstract String getProperty(String key);
+   String getProperty(String key);
    
    /**
     * Creates a File object for a file in the persistent storage area provided for the bundle by the Framework.
     */
-   public abstract File getDataFile(String filename);
+   File getDataFile(String filename);
 
    /**
     * Loads the specified class using this bundle's class loader. 
@@ -97,7 +94,7 @@
     * @return The OSGiBundle that is wired to this bundle class loader and contains the class.
     * @throws ClassNotFoundException If no such class can be found or if this bundle is a fragment bundle
     */
-   public abstract OSGiBundle loadClass(String name) throws ClassNotFoundException;
+   OSGiBundle loadClass(String name) throws ClassNotFoundException;
    
    /**
     * Returns a URL to the entry at the specified path in this bundle.
@@ -105,76 +102,27 @@
     * @param path The path name of the entry
     * @return A URL to the entry, or null if no entry could be found
     */
-   public abstract URL getEntry(String path);
+   URL getEntry(String path);
    
    /**
     * Find the specified resource from this bundle's class loader. 
     * @param name The name of the resource.
     * @return A URL to the named resource, or null if the resource could not be found
     */
-   public abstract URL getResource(String name);
+   URL getResource(String name);
    
    /**
     * Starts this bundle.
     */
-   public void start() throws BundleException
-   {
-      log.debug("Start bundle: " + this);
-      startInternal();
-   }
+   void start() throws BundleException;
    
-   protected abstract void startInternal() throws BundleException;
-   
    /**
     * Stops this bundle.
     */
-   public void stop() throws BundleException
-   {
-      log.debug("Stop bundle: " + this);
-      stopInternal();
-   }
+   void stop() throws BundleException;
    
-   protected abstract void stopInternal() throws BundleException;
-   
    /**
     * Uninstalls this bundle.
     */
-   public void uninstall() throws BundleException
-   {
-      log.debug("Uninstall bundle: " + this);
-      uninstallInternal();
-   }
-   
-   protected abstract void uninstallInternal() throws BundleException;
-   
-   /**
-    * Return true if symbolic name and version are equal
-    */
-   public boolean equals(Object obj)
-   {
-      if ((obj instanceof OSGiBundle) == false)
-         return false;
-      
-      OSGiBundle other = (OSGiBundle)obj;
-      
-      boolean isEqual =  getSymbolicName().equals(other.getSymbolicName());
-      isEqual = isEqual && getVersion().equals(other.getVersion());
-      return isEqual;
-   }
-
-   /**
-    * Returns the hash code for this bundle. 
-    */
-   public int hashCode()
-   {
-      return toString().hashCode();
-   }
-
-   /**
-    * Returns the string representation of this bundle 
-    */
-   public String toString()
-   {
-      return "[" + getSymbolicName() + ":" + getVersion() + "]";
-   }
+   void uninstall() throws BundleException;
 }

Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedBundle.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedBundle.java	2010-03-17 21:25:33 UTC (rev 102533)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedBundle.java	2010-03-17 22:22:42 UTC (rev 102534)
@@ -153,11 +153,9 @@
    protected void uninstallInternal() throws BundleException
    {
       assertNotUninstalled();
-      
       bundle.uninstall();
-      
       OSGiRuntimeImpl runtimeImpl = (OSGiRuntimeImpl)getRuntime();
-      runtimeImpl.unregisterBundle(this);
+      runtimeImpl.uninstallBundle(this);
    }
 
    private PackageAdmin getPackageAdmin()

Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedRuntime.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedRuntime.java	2010-03-17 21:25:33 UTC (rev 102533)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedRuntime.java	2010-03-17 22:22:42 UTC (rev 102534)
@@ -74,9 +74,8 @@
          VirtualFile rootFile = info.getRoot();
          BundleContext context = getSystemContext();
          Bundle auxBundle = context.installBundle(info.getLocation(), rootFile.openStream());
-         OSGiBundle bundle = new EmbeddedBundle(this, auxBundle);
-         return registerBundle(bundle.getLocation(), bundle);
-      }
+         return new EmbeddedBundle(this, auxBundle);
+     }
       catch (IOException ex)
       {
          throw new BundleException("Cannot install bundle: " + info, ex);

Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiBundleImpl.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiBundleImpl.java	2010-03-17 21:25:33 UTC (rev 102533)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiBundleImpl.java	2010-03-17 22:22:42 UTC (rev 102534)
@@ -23,9 +23,11 @@
 
 // $Id$
 
+import org.jboss.logging.Logger;
 import org.jboss.osgi.testing.OSGiBundle;
 import org.jboss.osgi.testing.OSGiRuntime;
 import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
 
 /**
  * An abstract implementation of a {@link OSGiBundle}
@@ -33,8 +35,11 @@
  * @author Thomas.Diesler at jboss.org
  * @since 25-Sep-2008
  */
-public abstract class OSGiBundleImpl extends OSGiBundle
+public abstract class OSGiBundleImpl implements OSGiBundle
 {
+   // Provide logging
+   private static final Logger log = Logger.getLogger(OSGiBundleImpl.class);
+
    private OSGiRuntime runtime;
    
    OSGiBundleImpl(OSGiRuntime runtime)
@@ -47,6 +52,70 @@
       return runtime;
    }
 
+   /**
+    * Starts this bundle.
+    */
+   public void start() throws BundleException
+   {
+      log.debug("Start bundle: " + this);
+      startInternal();
+   }
+   
+   protected abstract void startInternal() throws BundleException;
+   
+   /**
+    * Stops this bundle.
+    */
+   public void stop() throws BundleException
+   {
+      log.debug("Stop bundle: " + this);
+      stopInternal();
+   }
+   
+   protected abstract void stopInternal() throws BundleException;
+   
+   /**
+    * Uninstalls this bundle.
+    */
+   public void uninstall() throws BundleException
+   {
+      log.debug("Uninstall bundle: " + this);
+      uninstallInternal();
+   }
+   
+   protected abstract void uninstallInternal() throws BundleException;
+   
+   /**
+    * Return true if symbolic name and version are equal
+    */
+   public boolean equals(Object obj)
+   {
+      if ((obj instanceof OSGiBundle) == false)
+         return false;
+      
+      OSGiBundle other = (OSGiBundle)obj;
+      
+      boolean isEqual =  getSymbolicName().equals(other.getSymbolicName());
+      isEqual = isEqual && getVersion().equals(other.getVersion());
+      return isEqual;
+   }
+
+   /**
+    * Returns the hash code for this bundle. 
+    */
+   public int hashCode()
+   {
+      return toString().hashCode();
+   }
+
+   /**
+    * Returns the string representation of this bundle 
+    */
+   public String toString()
+   {
+      return "[" + getSymbolicName() + ":" + getVersion() + "]";
+   }
+   
    void assertNotUninstalled()
    {
       if (getState() == Bundle.UNINSTALLED)

Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiRuntimeImpl.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiRuntimeImpl.java	2010-03-17 21:25:33 UTC (rev 102533)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiRuntimeImpl.java	2010-03-17 22:22:42 UTC (rev 102534)
@@ -30,8 +30,6 @@
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
-import java.util.Map.Entry;
 
 import javax.management.MBeanServerConnection;
 import javax.management.ObjectName;
@@ -74,7 +72,7 @@
    private static final Logger log = Logger.getLogger(OSGiRuntimeImpl.class);
 
    private OSGiRuntimeHelper helper;
-   private Map<String, OSGiBundle> bundles = new LinkedHashMap<String, OSGiBundle>();
+   private Map<String, BundleTuple> bundles = new LinkedHashMap<String, BundleTuple>();
    private List<Capability> capabilities = new ArrayList<Capability>();
    
    private FrameworkMBean frameworkState;
@@ -167,7 +165,9 @@
    private OSGiBundle installBundle(BundleInfo info) throws BundleException
    {
       log.debug("Install bundle: " + info);
-      return installBundleInternal(info);
+      OSGiBundle bundle = installBundleInternal(info);
+      bundles.put(info.getLocation(), new BundleTuple(info, bundle));
+      return bundle;
    }
    
    abstract OSGiBundle installBundleInternal(BundleInfo info) throws BundleException;
@@ -183,8 +183,8 @@
       while (locations.size() > 0)
       {
          String location = locations.remove(0);
-         OSGiBundle bundle = bundles.remove(location);
-         OSGiRuntimeHelper.failsafeUninstall(bundle);
+         BundleTuple tuple = bundles.remove(location);
+         tuple.uninstall();
       }
 
       // Uninstall the capabilities
@@ -332,33 +332,14 @@
       return bundle;
    }
 
-   OSGiBundle registerBundle(String location, OSGiBundle bundle)
+   void uninstallBundle(OSGiBundle bundle)
    {
       if (bundle == null)
-         throw new IllegalArgumentException("Cannot register null bundle for: " + location);
-
-      bundles.put(location, bundle);
-      return bundle;
-   }
-
-   void unregisterBundle(OSGiBundle bundle)
-   {
-      if (bundle == null)
          throw new IllegalArgumentException("Cannot unregister null bundle");
 
-      if (bundles.containsValue(bundle))
-      {
-         Set<Entry<String, OSGiBundle>> entrySet = bundles.entrySet();
-         for (Entry<String, OSGiBundle> entry : entrySet)
-         {
-            if (bundle.equals(entry.getValue()))
-            {
-               String key = entry.getKey();
-               bundles.remove(key);
-               break;
-            }
-         }
-      }
+      String location = bundle.getLocation();
+      BundleTuple tuple = bundles.get(location);
+      tuple.uninstall();
    }
 
    private VirtualFile toVirtualFile(Archive<?> archive) throws IOException, MalformedURLException
@@ -370,4 +351,22 @@
       
       return AbstractVFS.getRoot(target.toURI().toURL());
    }
+   
+   class BundleTuple
+   {
+      BundleInfo info;
+      OSGiBundle bundle;
+      
+      BundleTuple(BundleInfo info, OSGiBundle bundle)
+      {
+         this.info = info;
+         this.bundle = bundle;
+      }
+
+      public void uninstall()
+      {
+         OSGiRuntimeHelper.failsafeUninstall(bundle);
+         info.close();
+      }
+   }
 }

Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java	2010-03-17 21:25:33 UTC (rev 102533)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java	2010-03-17 22:22:42 UTC (rev 102534)
@@ -307,7 +307,7 @@
       {
          OSGiRuntimeImpl runtimeImpl = (OSGiRuntimeImpl)getRuntime();
          runtimeImpl.getFrameworkMBean().uninstallBundle(bundleId);
-         runtimeImpl.unregisterBundle(this);
+         runtimeImpl.uninstallBundle(this);
          uninstalled = true;
       }
       catch (RuntimeException rte)

Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java	2010-03-17 21:25:33 UTC (rev 102533)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java	2010-03-17 22:22:42 UTC (rev 102534)
@@ -77,8 +77,7 @@
          String location = info.getLocation();
          String streamURL = info.getRoot().getStreamURL().toExternalForm();
          long bundleId = getFrameworkMBean().installBundle(location, streamURL);
-         RemoteBundle bundle = new RemoteBundle(this, bundleId);
-         return registerBundle(bundle.getLocation(), bundle);
+         return new RemoteBundle(this, bundleId);
       }
       catch (RuntimeException rte)
       {

Modified: projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VFSAdaptor30.java
===================================================================
--- projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VFSAdaptor30.java	2010-03-17 21:25:33 UTC (rev 102533)
+++ projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VFSAdaptor30.java	2010-03-17 22:22:42 UTC (rev 102534)
@@ -71,10 +71,10 @@
       if (other instanceof org.jboss.vfs.VirtualFile == false)
          throw new IllegalArgumentException("Not a org.jboss.vfs.VirtualFile: " + other);
 
-      org.jboss.vfs.VirtualFile nativeFile = (org.jboss.vfs.VirtualFile)other;
-      VirtualFile abstractFile = registry.get(other);
-      if (abstractFile != null)
-         return abstractFile;
+      org.jboss.vfs.VirtualFile vfsFile = (org.jboss.vfs.VirtualFile)other;
+      VirtualFile absFile = registry.get(other);
+      if (absFile != null)
+         return absFile;
 
       // Accept the file for mounting
       Closeable closeable = null;
@@ -83,7 +83,7 @@
          try
          {
             TempFileProvider tmp = TempFileProvider.create("osgimount-", null);
-            closeable = VFS.mountZip(nativeFile, nativeFile, tmp);
+            closeable = VFS.mountZip(vfsFile, vfsFile, tmp);
          }
          catch (IOException ex)
          {
@@ -92,17 +92,17 @@
       }
 
       // Register the VirtualFile abstraction
-      abstractFile = new VirtualFileAdaptor30(nativeFile, closeable);
-      registry.put(nativeFile, abstractFile);
-      return abstractFile;
+      absFile = new VirtualFileAdaptor30(vfsFile, closeable);
+      registry.put(vfsFile, absFile);
+      return absFile;
    }
 
-   private boolean acceptForMount(org.jboss.vfs.VirtualFile nativeFile)
+   private boolean acceptForMount(org.jboss.vfs.VirtualFile vfsFile)
    {
       boolean accept = false;
-      if (nativeFile.isFile() == true)
+      if (vfsFile.isFile() == true)
       {
-         String rootName = nativeFile.getName();
+         String rootName = vfsFile.getName();
          for (String suffix : suffixes)
          {
             if (rootName.endsWith(suffix))
@@ -115,17 +115,17 @@
       return accept;
    }
 
-   public Object adapt(VirtualFile virtualFile)
+   public Object adapt(VirtualFile absFile)
    {
-      if (virtualFile == null)
+      if (absFile == null)
          return null;
 
-      VirtualFileAdaptor30 adaptor = (VirtualFileAdaptor30)virtualFile;
+      VirtualFileAdaptor30 adaptor = (VirtualFileAdaptor30)absFile;
       return adaptor.getDelegate();
    }
 
-   static void safeClose(VirtualFileAdaptor30 virtualFile)
+   static void safeClose(VirtualFileAdaptor30 absFile)
    {
-      registry.remove(virtualFile.getDelegate());
+      registry.remove(absFile.getDelegate());
    }
 }
\ No newline at end of file

Modified: projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VirtualFileAdaptor30.java
===================================================================
--- projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VirtualFileAdaptor30.java	2010-03-17 21:25:33 UTC (rev 102533)
+++ projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VirtualFileAdaptor30.java	2010-03-17 22:22:42 UTC (rev 102534)
@@ -50,7 +50,8 @@
 {
    private org.jboss.vfs.VirtualFile delegate;
    private Closeable closeable;
-   private URL streamURL;
+   private TempDir streamDir;
+   private File streamFile;
 
    VirtualFileAdaptor30(org.jboss.vfs.VirtualFile root, Closeable closeable)
    {
@@ -100,33 +101,28 @@
    @Override
    public URL getStreamURL() throws IOException
    {
-      if (streamURL == null)
+      if (delegate.isFile() == true)
+         return delegate.toURL();
+
+      if (streamFile == null)
       {
-         if (delegate.isFile() == true)
+         TempFileProvider tmpProvider = TempFileProvider.create("osgiurl-", null);
+         streamDir = tmpProvider.createTempDir(getName());
+         streamFile = streamDir.getFile(getName());
+         JarOutputStream jarOut = new JarOutputStream(new FileOutputStream(streamFile));
+
+         VirtualJarInputStream jarIn = (VirtualJarInputStream)delegate.openStream();
+         ZipEntry nextEntry = jarIn.getNextEntry();
+         while (nextEntry != null)
          {
-            streamURL = delegate.toURL();
+            jarOut.putNextEntry(nextEntry);
+            VFSUtils.copyStream(jarIn, jarOut);
+            nextEntry = jarIn.getNextEntry();
          }
-         else
-         {
-            TempFileProvider tmpProvider = TempFileProvider.create("osgiurl-", null);
-            TempDir tmpDir = tmpProvider.createTempDir(getName());
-            File file = tmpDir.getFile(getName());
-            JarOutputStream jarOut = new JarOutputStream(new FileOutputStream(file));
-            
-            VirtualJarInputStream jarIn = (VirtualJarInputStream)delegate.openStream();
-            ZipEntry nextEntry = jarIn.getNextEntry();
-            while(nextEntry != null)
-            {
-               jarOut.putNextEntry(nextEntry);
-               VFSUtils.copyStream(jarIn, jarOut);
-               nextEntry = jarIn.getNextEntry();
-            }
-            jarOut.close();
-            jarIn.close();
-            streamURL = file.toURI().toURL();
-         }
+         jarOut.close();
+         jarIn.close();
       }
-      return streamURL;
+      return streamFile.toURI().toURL();
    }
 
    @Override
@@ -196,7 +192,7 @@
    {
       if (closeable != null)
          return getStreamURL().openStream();
-      
+
       return delegate.openStream();
    }
 
@@ -205,6 +201,23 @@
    {
       VFSUtils.safeClose(closeable);
       VFSAdaptor30.safeClose(this);
+      if (streamFile != null)
+      {
+         streamFile.delete();
+         streamFile = null;
+      }
+      try
+      {
+         if (streamDir != null)
+         {
+            streamDir.close();
+            streamDir = null;
+         }
+      }
+      catch (IOException ex)
+      {
+         // ignore
+      }
    }
 
    @Override



More information about the jboss-osgi-commits mailing list