FELIX-3126 Don't try to enable to activate components while the owning bundle's controller is being stopped.

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1181999 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scr/src/main/java/org/apache/felix/scr/impl/BundleComponentActivator.java b/scr/src/main/java/org/apache/felix/scr/impl/BundleComponentActivator.java
index 7dd4b53..86b9d9d 100644
--- a/scr/src/main/java/org/apache/felix/scr/impl/BundleComponentActivator.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/BundleComponentActivator.java
@@ -333,12 +333,13 @@
 
 
     /**
-     * Returns <true> if this instance is active, that is if components may be
-     * activated for this component. As soon as the {@link #dispose()} is called
-     * which means this instance is being shutdown. After the call to <code>dispose</code>
-     * this method always returns <code>false</code>.
+     * Returns <true> if this instance is active, that is if components
+     * may be activated for this component. The active flag is set early
+     * in the constructor indicating the activator is basically active
+     * (not fully setup, though) and reset early in the process of
+     * {@link #dispose(int) disposing} this instance.
      */
-    boolean isActive()
+    public boolean isActive()
     {
         return m_active;
     }
diff --git a/scr/src/main/java/org/apache/felix/scr/impl/manager/AbstractComponentManager.java b/scr/src/main/java/org/apache/felix/scr/impl/manager/AbstractComponentManager.java
index a2eb6c2..b53660e 100644
--- a/scr/src/main/java/org/apache/felix/scr/impl/manager/AbstractComponentManager.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/manager/AbstractComponentManager.java
@@ -479,6 +479,14 @@
         return m_activator;
     }
 
+
+    boolean isActivatorActive()
+    {
+        BundleComponentActivator activator = getActivator();
+        return activator != null && activator.isActive();
+    }
+
+
     final ServiceRegistration getServiceRegistration()
     {
         return m_serviceRegistration;
@@ -919,6 +927,13 @@
 
         void enable( AbstractComponentManager acm )
         {
+            if ( !acm.isActivatorActive() )
+            {
+                acm.log( LogService.LOG_DEBUG, "Bundle's component activator is not active; not enabling component",
+                    null );
+                return;
+            }
+
             acm.changeState( Enabling.getInstance() );
             acm.registerComponentId();
             try
@@ -985,6 +1000,13 @@
 
         void activate( AbstractComponentManager acm )
         {
+            if ( !acm.isActivatorActive() )
+            {
+                acm.log( LogService.LOG_DEBUG, "Bundle's component activator is not active; not activating component",
+                    null );
+                return;
+            }
+
             acm.changeState( Activating.getInstance() );
 
             acm.log( LogService.LOG_DEBUG, "Activating component", null );