felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r784846 - /felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java
Date Mon, 15 Jun 2009 16:24:20 GMT
Author: rickhall
Date: Mon Jun 15 16:24:20 2009
New Revision: 784846

URL: http://svn.apache.org/viewvc?rev=784846&view=rev
Log:
Fire STOPPING and STOPPED events if a bundle fails to activate,
as per the spec. (FELIX-1237)

Modified:
    felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java?rev=784846&r1=784845&r2=784846&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java Mon Jun 15 16:24:20
2009
@@ -1434,6 +1434,7 @@
         bundle.setDeclaredActivationPolicyUsed(
             (options & Bundle.START_ACTIVATION_POLICY) != 0);
 
+        BundleException rethrow = null;
         try
         {
             // The spec doesn't say whether it is possible to start an extension
@@ -1523,7 +1524,14 @@
                 // Record the event type for the final event and activate.
                 eventType = BundleEvent.STARTED;
                 // Note that the STARTING event is thrown in the activateBundle() method.
-                activateBundle(bundle, false);
+                try
+                {
+                    activateBundle(bundle, false);
+                }
+                catch (BundleException ex)
+                {
+                    rethrow = ex;
+                }
             }
             // Otherwise, defer bundle activation.
             else
@@ -1542,8 +1550,17 @@
         }
 
         // If there was no exception, then we should fire the STARTED
-        // or LAZY_ACTIVATION event here without holding the lock.
-        fireBundleEvent(eventType, bundle);
+        // or LAZY_ACTIVATION event here without holding the lock. Otherwise,
+        // fire STOPPED and rethrow exception.
+        if (rethrow == null)
+        {
+            fireBundleEvent(eventType, bundle);
+        }
+        else
+        {
+            fireBundleEvent(BundleEvent.STOPPED, bundle);
+            throw rethrow;
+        }
     }
 
     void activateBundle(BundleImpl bundle, boolean fireEvent) throws BundleException
@@ -1598,6 +1615,9 @@
             }
             catch (Throwable th)
             {
+                // Spec says we must fire STOPPING event.
+                fireBundleEvent(BundleEvent.STOPPING, bundle);
+
                 // If there was an error starting the bundle,
                 // then reset its state to RESOLVED.
                 setBundleStateAndNotify(bundle, Bundle.RESOLVED);



Mime
View raw message