FELIX-1666 JavaDoc for the helper method and accept STARTING bundles
only if they have the lazy activation policy header set.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@825016 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scr/src/main/java/org/apache/felix/scr/impl/ComponentRegistry.java b/scr/src/main/java/org/apache/felix/scr/impl/ComponentRegistry.java
index 8a84071..15e8c08 100644
--- a/scr/src/main/java/org/apache/felix/scr/impl/ComponentRegistry.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/ComponentRegistry.java
@@ -327,7 +327,22 @@
//---------- Helper method
- static boolean isBundleActive( Bundle bundle )
+ /**
+ * Returns <code>true</code> if the <code>bundle</code> is to be considered
+ * active from the perspective of declarative services.
+ * <p>
+ * As of R4.1 a bundle may have lazy activation policy which means a bundle
+ * remains in the STARTING state until a class is loaded from that bundle
+ * (unless that class is declared to not cause the bundle to start). And
+ * thus for DS 1.1 this means components are to be loaded for lazily started
+ * bundles being in the STARTING state (after the LAZY_ACTIVATION event) has
+ * been sent. Hence DS must consider a bundle active when it is really
+ * active and when it is a lazily activated bundle in the STARTING state.
+ *
+ * @throws NullPointerException if bundle is <code>null</code>.
+ * @see <a href="https://issues.apache.org/jira/browse/FELIX-1666">FELIX-1666</a>
+ */
+ static boolean isBundleActive( final Bundle bundle )
{
if ( bundle.getState() == Bundle.ACTIVE )
{
@@ -336,9 +351,11 @@
if ( bundle.getState() == Bundle.STARTING )
{
- // might want to check lazy start setting
-
- return true;
+ // according to the spec the activationPolicy header is only
+ // set to request a bundle to be lazily activated. So in this
+ // simple check we just verify the header is set to assume
+ // the bundle is considered a lazily activated bundle
+ return bundle.getHeaders().get( Constants.BUNDLE_ACTIVATIONPOLICY ) != null;
}
// fall back: bundle is not considered active