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/08/25 21:39:01 UTC
svn commit: r1161715 -
/felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java
Author: rickhall
Date: Thu Aug 25 19:39:00 2011
New Revision: 1161715
URL: http://svn.apache.org/viewvc?rev=1161715&view=rev
Log:
Allow bundles to add listeners/services while in STOPPING state. (FELIX-3082)
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=1161715&r1=1161714&r2=1161715&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 Aug 25 19:39:00 2011
@@ -2394,6 +2394,13 @@ public class Felix extends BundleImpl im
// Clean up the bundle activator.
bundle.setActivator(null);
+ // Clean up the bundle context.
+ // We invalidate this first to make sure it cannot be used
+ // after stopping the activator.
+ BundleContextImpl bci = (BundleContextImpl) bundle._getBundleContext();
+ bci.invalidate();
+ bundle.setBundleContext(null);
+
// Unregister any services offered by this bundle.
m_registry.unregisterServices(bundle);
@@ -2402,11 +2409,7 @@ public class Felix extends BundleImpl im
// The spec says that we must remove all event
// listeners for a bundle when it is stopped.
- m_dispatcher.removeListeners(bundle._getBundleContext());
-
- // Clean up the bundle context.
- ((BundleContextImpl) bundle._getBundleContext()).invalidate();
- bundle.setBundleContext(null);
+ m_dispatcher.removeListeners(bci);
setBundleStateAndNotify(bundle, Bundle.RESOLVED);
@@ -3073,7 +3076,7 @@ public class Felix extends BundleImpl im
// Acquire bundle lock.
try
{
- acquireBundleLock(bundle, Bundle.STARTING | Bundle.ACTIVE);
+ acquireBundleLock(bundle, Bundle.STARTING | Bundle.ACTIVE | Bundle.STOPPING);
}
catch (IllegalStateException ex)
{
@@ -3113,7 +3116,7 @@ public class Felix extends BundleImpl im
// Acquire bundle lock.
try
{
- acquireBundleLock(bundle, Bundle.STARTING | Bundle.ACTIVE);
+ acquireBundleLock(bundle, Bundle.STARTING | Bundle.ACTIVE | Bundle.STOPPING);
}
catch (IllegalStateException ex)
{
@@ -3237,7 +3240,7 @@ public class Felix extends BundleImpl im
// Acquire bundle lock.
try
{
- acquireBundleLock(bundle, Bundle.STARTING | Bundle.ACTIVE);
+ acquireBundleLock(bundle, Bundle.STARTING | Bundle.ACTIVE | Bundle.STOPPING);
}
catch (IllegalStateException ex)
{
@@ -3288,7 +3291,7 @@ public class Felix extends BundleImpl im
// Acquire bundle lock.
try
{
- acquireBundleLock(bundle, Bundle.STARTING | Bundle.ACTIVE);
+ acquireBundleLock(bundle, Bundle.STARTING | Bundle.ACTIVE | Bundle.STOPPING);
}
catch (IllegalStateException ex)
{