Move activation trigger to BundleClassLoader from BundleWiringImpl
and make it volatile instead of using a lock for it. (FELIX-2950)
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1153639 13f79535-47bb-0310-9956-ffa450edef68
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 a941a84..a0683f4 100644
--- a/framework/src/main/java/org/apache/felix/framework/BundleWiringImpl.java
+++ b/framework/src/main/java/org/apache/felix/framework/BundleWiringImpl.java
@@ -95,7 +95,6 @@
private volatile List<BundleRequirement> m_wovenReqs = null;
private BundleClassLoader m_classLoader;
- private boolean m_isActivationTriggered = false;
// Bundle-specific class loader for boot delegation.
private final ClassLoader m_bootClassLoader;
@@ -1717,11 +1716,6 @@
return true;
}
- synchronized boolean isActivationTriggered()
- {
- return m_isActivationTriggered;
- }
-
static class ToLocalUrlEnumeration implements Enumeration
{
final Enumeration m_enumeration;
@@ -1769,6 +1763,10 @@
public class BundleClassLoader extends SecureClassLoader implements BundleReference
{
+ // Flag used to determine if a class has been loaded from this class
+ // loader or not.
+ private volatile boolean m_isActivationTriggered = false;
+
private final Map m_jarContentToDexFile;
private Object[][] m_cachedLibs = new Object[0][];
private static final int LIBNAME_IDX = 0;
@@ -1787,6 +1785,11 @@
}
}
+ public boolean isActivationTriggered()
+ {
+ return m_isActivationTriggered;
+ }
+
public Bundle getBundle()
{
return BundleWiringImpl.this.getBundle();
@@ -2108,7 +2111,6 @@
// activation trigger has tripped.
if (!m_isActivationTriggered && isTriggerClass && (clazz != null))
{
-// TODO: OSGi R4.3 - This isn't protected by the correct lock.
m_isActivationTriggered = true;
}
}
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 82dee87..d430584 100644
--- a/framework/src/main/java/org/apache/felix/framework/Felix.java
+++ b/framework/src/main/java/org/apache/felix/framework/Felix.java
@@ -23,6 +23,7 @@
import java.net.*;
import java.security.*;
import java.util.*;
+import org.apache.felix.framework.BundleWiringImpl.BundleClassLoader;
import org.apache.felix.framework.ServiceRegistry.ServiceRegistryCallbacks;
import org.apache.felix.framework.cache.BundleArchive;
import org.apache.felix.framework.cache.BundleCache;
@@ -1905,7 +1906,7 @@
if (!bundle.isDeclaredActivationPolicyUsed()
|| (((BundleRevisionImpl) bundle.adapt(BundleRevision.class))
.getDeclaredActivationPolicy() != BundleRevisionImpl.LAZY_ACTIVATION)
- || ((BundleWiringImpl) bundle.adapt(BundleRevision.class).getWiring())
+ || ((BundleClassLoader) bundle.adapt(BundleWiring.class).getClassLoader())
.isActivationTriggered())
{
// Record the event type for the final event and activate.