You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ri...@apache.org on 2010/02/24 06:21:48 UTC

svn commit: r915676 - in /felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework: BundleImpl.java Felix.java FelixResolverState.java

Author: rickhall
Date: Wed Feb 24 05:21:47 2010
New Revision: 915676

URL: http://svn.apache.org/viewvc?rev=915676&view=rev
Log:
Another fix ported from trunk.

Modified:
    felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/BundleImpl.java
    felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/Felix.java
    felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/FelixResolverState.java

Modified: felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/BundleImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/BundleImpl.java?rev=915676&r1=915675&r2=915676&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/BundleImpl.java (original)
+++ felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/BundleImpl.java Wed Feb 24 05:21:47 2010
@@ -134,6 +134,21 @@
         }
     }
 
+    /**
+     * This is sort of a hacky method called after uninstalling a bundle.
+     * If the bundle is a fragment, this will unmerge it from any unresolved
+     * hosts. This is necessary since fragments are pre-merged into unresolved
+     * hosts. If uninstalled fragments are not unmerged from unresolved hosts,
+     * any attempts to subsequently resolve the host will result in an exception.
+     */
+    synchronized void cleanAfterUninstall()
+    {
+        for (int i = 0; i < m_modules.size(); i++)
+        {
+            getFramework().getResolverState().unmergeFragment(m_modules.get(i));
+        }
+    }
+
     synchronized void refresh() throws Exception
     {
         if (isExtension() && (getFramework().getState() != Bundle.STOPPING))

Modified: felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/Felix.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/Felix.java?rev=915676&r1=915675&r2=915676&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/Felix.java (original)
+++ felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/Felix.java Wed Feb 24 05:21:47 2010
@@ -2301,6 +2301,10 @@
             // Set state to uninstalled.
             setBundleStateAndNotify(bundle, Bundle.UNINSTALLED);
             bundle.setLastModified(System.currentTimeMillis());
+
+            // If this bundle is a fragment, unmerge it from any
+            // unresolved hosts.
+            bundle.cleanAfterUninstall();
         }
         finally
         {

Modified: felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/FelixResolverState.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/FelixResolverState.java?rev=915676&r1=915675&r2=915676&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/FelixResolverState.java (original)
+++ felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/FelixResolverState.java Wed Feb 24 05:21:47 2010
@@ -401,6 +401,16 @@
         }
     }
 
+    public void unmergeFragment(Module fragment)
+    {
+        if (!Util.isFragment(fragment))
+        {
+            return;
+        }
+
+        removeFragment(fragment);
+    }
+
     private List getMatchingHosts(Module fragment)
     {
         // Find the fragment's host requirement.