felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r783813 - in /felix/trunk/framework/src/main/java/org/apache/felix/framework: Felix.java util/EventDispatcher.java
Date Thu, 11 Jun 2009 15:16:45 GMT
Author: rickhall
Date: Thu Jun 11 15:16:35 2009
New Revision: 783813

URL: http://svn.apache.org/viewvc?rev=783813&view=rev
Log:
More corner cases for activation policy. (FELIX-749)

Modified:
    felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/util/EventDispatcher.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=783813&r1=783812&r2=783813&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 Thu Jun 11 15:16:35
2009
@@ -1411,7 +1411,8 @@
         // Acquire bundle lock.
         try
         {
-            acquireBundleLock(bundle, Bundle.INSTALLED | Bundle.RESOLVED | Bundle.ACTIVE);
+            acquireBundleLock(bundle,
+                Bundle.INSTALLED | Bundle.RESOLVED | Bundle.STARTING | Bundle.ACTIVE);
         }
         catch (IllegalStateException ex)
         {
@@ -1428,6 +1429,8 @@
         }
 
         // Record whether the bundle is using its declared activation policy.
+        boolean wasDeferred = bundle.isDeclaredActivationPolicyUsed()
+            && (bundle.getCurrentModule().getDeclaredActivationPolicy() == IModule.LAZY_ACTIVATION);
         bundle.setDeclaredActivationPolicyUsed(
             (options & Bundle.START_ACTIVATION_POLICY) != 0);
 
@@ -1483,29 +1486,34 @@
                 case Bundle.UNINSTALLED:
                     throw new IllegalStateException("Cannot start an uninstalled bundle.");
                 case Bundle.STARTING:
+                    if (!wasDeferred)
+                    {
+                        throw new BundleException(
+                            "Bundle " + bundle
+                            + " cannot be started, since it is starting.");
+                    }
+                    break;
                 case Bundle.STOPPING:
                     throw new BundleException(
                         "Bundle " + bundle
-                        + " cannot be started, since it is either starting or stopping.");
+                        + " cannot be started, since it is stopping.");
                 case Bundle.ACTIVE:
                     return;
                 case Bundle.INSTALLED:
                     resolveBundle(bundle);
                     // No break.
                 case Bundle.RESOLVED:
+                    // Set the bundle's context.
+                    bundle.setBundleContext(new BundleContextImpl(m_logger, this, bundle));
+                    // At this point, no matter if the bundle's activation policy is
+                    // eager or deferred, we need to set the bundle's state to STARTING.
+                    // We don't fire a BundleEvent here for this state change, since
+                    // STARTING events are only fired if we are invoking the activator,
+                    // which we may not do if activation is deferred.
+                    setBundleStateAndNotify(bundle, Bundle.STARTING);
                     break;
             }
 
-            // Set the bundle's context.
-            bundle.setBundleContext(new BundleContextImpl(m_logger, this, bundle));
-
-            // At this point, no matter if the bundle's activation policy is
-            // eager or deferred, we need to set the bundle's state to STARTING.
-            // We don't fire a BundleEvent here for this state change, since
-            // STARTING events are only fired if we are invoking the activator,
-            // which we may not do if activation is deferred.
-            setBundleStateAndNotify(bundle, Bundle.STARTING);
-
             // If the bundle's activation policy is eager or activation has already
             // been triggered, then activate the bundle immediately.
             if (!bundle.isDeclaredActivationPolicyUsed()
@@ -1550,20 +1558,21 @@
         // Acquire bundle lock.
         try
         {
-            acquireBundleLock(bundle, Bundle.STARTING);
+            acquireBundleLock(bundle, Bundle.STARTING | Bundle.ACTIVE);
         }
         catch (IllegalStateException ex)
         {
             throw new IllegalStateException(
                 "Activation only occurs for bundles in STARTING state.");
         }
+
         try
         {
-            // Check to see if the bundle's start level is greater than the
-            // the framework's active start level.
-            if (bundle.getStartLevel(getInitialBundleStartLevel()) > getActiveStartLevel())
+            // If the bundle is already active or its start level is not met,
+            // simply return.
+            if ((bundle.getState() == Bundle.ACTIVE) ||
+                (bundle.getStartLevel(getInitialBundleStartLevel()) > getActiveStartLevel()))
             {
-                // Ignore persistent starts.
                 return;
             }
 

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/util/EventDispatcher.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/util/EventDispatcher.java?rev=783813&r1=783812&r2=783813&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/util/EventDispatcher.java
(original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/util/EventDispatcher.java
Thu Jun 11 15:16:35 2009
@@ -595,7 +595,6 @@
             syncListeners = m_syncBundleListeners;
         }
 
-System.out.println("+++ FIRING BUNDLE EVENT " + event.getType() + " FROM " + event.getBundle().getSymbolicName());
         // Fire synchronous bundle listeners immediately on the calling thread.
         fireEventImmediately(m_logger, Request.BUNDLE_EVENT, syncListeners, event);
 



Mime
View raw message