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 2011/01/28 22:00:36 UTC

svn commit: r1064876 - in /felix/branches/org.apache.felix.framework-3.0.8-RC/src/main/java/org/apache/felix/framework: BundleImpl.java Felix.java

Author: rickhall
Date: Fri Jan 28 21:00:35 2011
New Revision: 1064876

URL: http://svn.apache.org/viewvc?rev=1064876&view=rev
Log:
Port FELIX-2802 from trunk to 3.0.8 branch.

Modified:
    felix/branches/org.apache.felix.framework-3.0.8-RC/src/main/java/org/apache/felix/framework/BundleImpl.java
    felix/branches/org.apache.felix.framework-3.0.8-RC/src/main/java/org/apache/felix/framework/Felix.java

Modified: felix/branches/org.apache.felix.framework-3.0.8-RC/src/main/java/org/apache/felix/framework/BundleImpl.java
URL: http://svn.apache.org/viewvc/felix/branches/org.apache.felix.framework-3.0.8-RC/src/main/java/org/apache/felix/framework/BundleImpl.java?rev=1064876&r1=1064875&r2=1064876&view=diff
==============================================================================
--- felix/branches/org.apache.felix.framework-3.0.8-RC/src/main/java/org/apache/felix/framework/BundleImpl.java (original)
+++ felix/branches/org.apache.felix.framework-3.0.8-RC/src/main/java/org/apache/felix/framework/BundleImpl.java Fri Jan 28 21:00:35 2011
@@ -1090,6 +1090,14 @@ class BundleImpl implements Bundle
 
     synchronized boolean rollbackRevise() throws Exception
     {
+        boolean isExtension = isExtension();
+        Module m = m_modules.remove(m_modules.size() - 1);
+        if (!isExtension)
+        {
+            // Since revising a module adds the module to the global
+            // state, we must remove it from the global state on rollback.
+            getFramework().getResolverState().removeModule(m);
+        }
         return m_archive.rollbackRevise();
     }
 

Modified: felix/branches/org.apache.felix.framework-3.0.8-RC/src/main/java/org/apache/felix/framework/Felix.java
URL: http://svn.apache.org/viewvc/felix/branches/org.apache.felix.framework-3.0.8-RC/src/main/java/org/apache/felix/framework/Felix.java?rev=1064876&r1=1064875&r2=1064876&view=diff
==============================================================================
--- felix/branches/org.apache.felix.framework-3.0.8-RC/src/main/java/org/apache/felix/framework/Felix.java (original)
+++ felix/branches/org.apache.felix.framework-3.0.8-RC/src/main/java/org/apache/felix/framework/Felix.java Fri Jan 28 21:00:35 2011
@@ -1959,58 +1959,57 @@ public class Felix extends BundleImpl im
                     throw new BundleException(
                         "Cannot acquire global lock to update the bundle.");
                 }
-                boolean wasExtension = bundle.isExtension();
                 try
                 {
-// TODO: REFACTOR - This adds the module to the resolver state, but should we do the
-//            security check first?
+                    // Try to revise.
+                    boolean wasExtension = bundle.isExtension();
                     bundle.revise(updateLocation, is);
-                }
-                finally
-                {
-                    // Always release the global lock.
-                    releaseGlobalLock();
-                }
 
-                // Verify updated bundle.
-                try
-                {
-                    Object sm = System.getSecurityManager();
-
-                    if (sm != null)
+                    // Verify bundle revision.
+                    try
                     {
-                        ((SecurityManager) sm).checkPermission(
-                            new AdminPermission(bundle, AdminPermission.LIFECYCLE));
-                    }
+                        Object sm = System.getSecurityManager();
 
-                    // If this is an update from a normal to an extension bundle
-                    // then attach the extension
-                    if (!wasExtension && bundle.isExtension())
-                    {
-                        m_extensionManager.addExtensionBundle(this, bundle);
+                        if (sm != null)
+                        {
+                            ((SecurityManager) sm).checkPermission(
+                                new AdminPermission(bundle, AdminPermission.LIFECYCLE));
+                        }
+
+                        // If this is an update from a normal to an extension bundle
+                        // then attach the extension
+                        if (!wasExtension && bundle.isExtension())
+                        {
+                            m_extensionManager.addExtensionBundle(this, bundle);
 // TODO: REFACTOR - Perhaps we could move this into extension manager.
-                        m_resolverState.refreshSystemBundleModule(m_extensionManager.getModule());
+                            m_resolverState.refreshSystemBundleModule(m_extensionManager.getModule());
 // TODO: REFACTOR - Not clear why this is here. We should look at all of these steps more closely.
-                        setBundleStateAndNotify(bundle, Bundle.RESOLVED);
+                            setBundleStateAndNotify(bundle, Bundle.RESOLVED);
+                        }
+                        else if (wasExtension)
+                        {
+                            setBundleStateAndNotify(bundle, Bundle.INSTALLED);
+                        }
                     }
-                    else if (wasExtension)
+                    catch (Throwable ex)
                     {
-                        setBundleStateAndNotify(bundle, Bundle.INSTALLED);
+                        try
+                        {
+                            bundle.rollbackRevise();
+                        }
+                        catch (Exception busted)
+                        {
+                            m_logger.log(
+                                bundle, Logger.LOG_ERROR, "Unable to rollback.", busted);
+                        }
+
+                        throw ex;
                     }
                 }
-                catch (Throwable ex)
+                finally
                 {
-                    try
-                    {
-                        bundle.rollbackRevise();
-                    }
-                    catch (Exception busted)
-                    {
-                        m_logger.log(
-                            bundle, Logger.LOG_ERROR, "Unable to rollback.", busted);
-                    }
-
-                    throw ex;
+                    // Always release the global lock.
+                    releaseGlobalLock();
                 }
             }
             catch (Throwable ex)