felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r824884 - in /felix/trunk/scr/src/main/java/org/apache/felix/scr/impl: Activator.java ComponentActivatorTask.java ComponentRegistry.java ScrCommand.java
Date Tue, 13 Oct 2009 19:00:27 GMT
Author: fmeschbe
Date: Tue Oct 13 19:00:27 2009
New Revision: 824884

URL: http://svn.apache.org/viewvc?rev=824884&view=rev
Log:
FELIX-1666 add helper method for deciding whether a bundle is considered
active or not. Currently we allow ACTIVE and STARTING states. For the
STARTING state though, we should actually be checking whether the
bundle is really a lazily activated one or not ...

Modified:
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/Activator.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ComponentActivatorTask.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ComponentRegistry.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ScrCommand.java

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/Activator.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/Activator.java?rev=824884&r1=824883&r2=824884&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/Activator.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/Activator.java Tue Oct 13 19:00:27
2009
@@ -194,7 +194,7 @@
         for ( int i = 0; i < bundles.length; i++ )
         {
             Bundle bundle = bundles[i];
-            if ( bundle.getState() == Bundle.ACTIVE )
+            if ( ComponentRegistry.isBundleActive( bundle ) )
             {
                 loadComponents( bundle );
             }
@@ -225,7 +225,7 @@
         if ( m_componentBundles.containsKey( new Long( bundle.getBundleId() ) ) )
         {
             log( LogService.LOG_DEBUG, m_context.getBundle(), "Components for bundle  " +
bundle.getSymbolicName()
-                + "/" + bundle.getBundleId() + " already loaded. Nothing to do", null );
+                + "/" + bundle.getBundleId() + " already loaded. Nothing to do.", null );
             return;
         }
 

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ComponentActivatorTask.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ComponentActivatorTask.java?rev=824884&r1=824883&r2=824884&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ComponentActivatorTask.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ComponentActivatorTask.java Tue
Oct 13 19:00:27 2009
@@ -21,7 +21,6 @@
 
 import org.apache.felix.scr.Component;
 import org.apache.felix.scr.impl.manager.AbstractComponentManager;
-import org.osgi.framework.Bundle;
 import org.osgi.service.log.LogService;
 
 
@@ -58,7 +57,7 @@
             Activator.log( LogService.LOG_WARNING, null, "Cannot run task '" + this
                 + "': Component has already been destroyed", null );
         }
-        else if ( component.getBundle().getState() != Bundle.ACTIVE )
+        else if ( !ComponentRegistry.isBundleActive( component.getBundle() ) )
         {
             Activator.log( LogService.LOG_WARNING, component.getBundle(), "Cannot run task
'" + this
                 + "': Declaring bundle is not active", null );

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ComponentRegistry.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ComponentRegistry.java?rev=824884&r1=824883&r2=824884&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ComponentRegistry.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ComponentRegistry.java Tue Oct
13 19:00:27 2009
@@ -324,4 +324,24 @@
         return new UnconfiguredComponentHolder( activator, metadata );
     }
 
+
+    //---------- Helper method
+
+    static boolean isBundleActive( Bundle bundle )
+    {
+        if ( bundle.getState() == Bundle.ACTIVE )
+        {
+            return true;
+        }
+
+        if ( bundle.getState() == Bundle.STARTING )
+        {
+            // might want to check lazy start setting
+
+            return true;
+        }
+
+        // fall back: bundle is not considered active
+        return false;
+    }
 }

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ScrCommand.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ScrCommand.java?rev=824884&r1=824883&r2=824884&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ScrCommand.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ScrCommand.java Tue Oct 13 19:00:27
2009
@@ -136,7 +136,7 @@
                     err.println( "Missing bundle with ID " + bundleId );
                     return;
                 }
-                if ( bundle.getState() == Bundle.ACTIVE || bundle.getState() == Bundle.STARTING
)
+                if ( ComponentRegistry.isBundleActive( bundle ) )
                 {
                     components = scrService.getComponents( bundle );
                     if ( components == null )



Mime
View raw message