Lazy activation was being handled in two places; related metadata
should be held in BundleRevisionImpl and class-loading tracking
should be handled in BundleWiringImpl. (FELIX-2950)
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1124294 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/BundleRevisionImpl.java b/framework/src/main/java/org/apache/felix/framework/BundleRevisionImpl.java
index a390407..40e33ee 100644
--- a/framework/src/main/java/org/apache/felix/framework/BundleRevisionImpl.java
+++ b/framework/src/main/java/org/apache/felix/framework/BundleRevisionImpl.java
@@ -163,14 +163,33 @@
return m_declaredActivationPolicy;
}
- List<String> getActivationExcludes()
+ boolean isActivationTrigger(String pkgName)
{
- return m_activationExcludes;
- }
+ if ((m_activationIncludes == null) && (m_activationExcludes == null))
+ {
+ return true;
+ }
- List<String> getActivationIncludes()
- {
- return m_activationIncludes;
+ // If there are no include filters then all classes are included
+ // by default, otherwise try to find one match.
+ boolean included = (m_activationIncludes == null);
+ for (int i = 0;
+ (!included) && (m_activationIncludes != null) && (i < m_activationIncludes.size());
+ i++)
+ {
+ included = m_activationIncludes.get(i).equals(pkgName);
+ }
+
+ // If there are no exclude filters then no classes are excluded
+ // by default, otherwise try to find one match.
+ boolean excluded = false;
+ for (int i = 0;
+ (!excluded) && (m_activationExcludes != null) && (i < m_activationExcludes.size());
+ i++)
+ {
+ excluded = m_activationExcludes.get(i).equals(pkgName);
+ }
+ return included && !excluded;
}
URLStreamHandler getURLStreamHandler()
@@ -285,40 +304,6 @@
return m_declaredNativeLibs;
}
- synchronized boolean isActivationTriggered()
- {
- return m_isActivationTriggered;
- }
-
- boolean isActivationTrigger(String pkgName)
- {
- if ((m_activationIncludes == null) && (m_activationExcludes == null))
- {
- return true;
- }
-
- // If there are no include filters then all classes are included
- // by default, otherwise try to find one match.
- boolean included = (m_activationIncludes == null);
- for (int i = 0;
- (!included) && (m_activationIncludes != null) && (i < m_activationIncludes.size());
- i++)
- {
- included = m_activationIncludes.get(i).equals(pkgName);
- }
-
- // If there are no exclude filters then no classes are excluded
- // by default, otherwise try to find one match.
- boolean excluded = false;
- for (int i = 0;
- (!excluded) && (m_activationExcludes != null) && (i < m_activationExcludes.size());
- i++)
- {
- excluded = m_activationExcludes.get(i).equals(pkgName);
- }
- return included && !excluded;
- }
-
public String getId()
{
return m_id;
diff --git a/framework/src/main/java/org/apache/felix/framework/BundleWiringImpl.java b/framework/src/main/java/org/apache/felix/framework/BundleWiringImpl.java
index 00e1fd7..dd263db 100644
--- a/framework/src/main/java/org/apache/felix/framework/BundleWiringImpl.java
+++ b/framework/src/main/java/org/apache/felix/framework/BundleWiringImpl.java
@@ -1188,38 +1188,6 @@
return m_isActivationTriggered;
}
- boolean isActivationTrigger(String pkgName)
- {
- List<String> activationIncludes = m_revision.getActivationIncludes();
- List<String> activationExcludes = m_revision.getActivationExcludes();
-
- if ((activationIncludes == null) && (activationExcludes == null))
- {
- return true;
- }
-
- // If there are no include filters then all classes are included
- // by default, otherwise try to find one match.
- boolean included = (activationIncludes == null);
- for (int i = 0;
- (!included) && (activationIncludes != null) && (i < activationIncludes.size());
- i++)
- {
- included = activationIncludes.get(i).equals(pkgName);
- }
-
- // If there are no exclude filters then no classes are excluded
- // by default, otherwise try to find one match.
- boolean excluded = false;
- for (int i = 0;
- (!excluded) && (activationExcludes != null) && (i < activationExcludes.size());
- i++)
- {
- excluded = activationExcludes.get(i).equals(pkgName);
- }
- return included && !excluded;
- }
-
static class ToLocalUrlEnumeration implements Enumeration
{
final Enumeration m_enumeration;
@@ -1385,7 +1353,7 @@
// circuit the trigger matching if the trigger is already
// tripped.
boolean isTriggerClass = m_isActivationTriggered
- ? false : isActivationTrigger(pkgName);
+ ? false : m_revision.isActivationTrigger(pkgName);
if (!m_isActivationTriggered
&& isTriggerClass
&& (activationPolicy == BundleRevisionImpl.LAZY_ACTIVATION)
diff --git a/framework/src/main/java/org/apache/felix/framework/Felix.java b/framework/src/main/java/org/apache/felix/framework/Felix.java
index 397b0ed..a9d65f0 100644
--- a/framework/src/main/java/org/apache/felix/framework/Felix.java
+++ b/framework/src/main/java/org/apache/felix/framework/Felix.java
@@ -1850,7 +1850,8 @@
if (!bundle.isDeclaredActivationPolicyUsed()
|| (((BundleRevisionImpl) bundle.getCurrentRevision())
.getDeclaredActivationPolicy() != BundleRevisionImpl.LAZY_ACTIVATION)
- || ((BundleRevisionImpl) bundle.getCurrentRevision()).isActivationTriggered())
+ || ((BundleWiringImpl) bundle.getCurrentRevision().getWiring())
+ .isActivationTriggered())
{
// Record the event type for the final event and activate.
eventType = BundleEvent.STARTED;