Start laying some groundwork for lazy activation. (FELIX-749)
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@774807 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/searchpolicy/ModuleImpl.java b/framework/src/main/java/org/apache/felix/framework/searchpolicy/ModuleImpl.java
index 5dee8b9..c5824ce 100644
--- a/framework/src/main/java/org/apache/felix/framework/searchpolicy/ModuleImpl.java
+++ b/framework/src/main/java/org/apache/felix/framework/searchpolicy/ModuleImpl.java
@@ -75,6 +75,7 @@
private final IRequirement[] m_requirements;
private final IRequirement[] m_dynamicRequirements;
private final R4Library[] m_nativeLibraries;
+ private final int m_activationPolicy;
private final Bundle m_bundle;
private IModule[] m_fragments = null;
@@ -132,6 +133,7 @@
m_requirements = null;
m_dynamicRequirements = null;
m_nativeLibraries = null;
+ m_activationPolicy = EAGER_ACTIVATION;
}
public ModuleImpl(
@@ -163,6 +165,7 @@
m_requirements = mp.getRequirements();
m_dynamicRequirements = mp.getDynamicRequirements();
m_nativeLibraries = mp.getLibraries();
+ m_activationPolicy = mp.getActivationPolicy();
m_symbolicName = mp.getSymbolicName();
m_isExtension = mp.isExtension();
@@ -297,6 +300,11 @@
return m_nativeLibraries;
}
+ public int getActivationPolicy()
+ {
+ return m_activationPolicy;
+ }
+
//
// Run-time data access.
//
diff --git a/framework/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java b/framework/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java
index 64b1a29..e5e8eb2 100644
--- a/framework/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java
+++ b/framework/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java
@@ -24,6 +24,7 @@
import org.apache.felix.framework.util.FelixConstants;
import org.apache.felix.framework.util.VersionRange;
import org.apache.felix.moduleloader.ICapability;
+import org.apache.felix.moduleloader.IModule;
import org.apache.felix.moduleloader.IRequirement;
import org.osgi.framework.*;
@@ -32,6 +33,7 @@
private final Logger m_logger;
private final Map m_configMap;
private final Map m_headerMap;
+ private volatile int m_activationPolicy = IModule.EAGER_ACTIVATION;
private volatile boolean m_isExtension = false;
private volatile String m_bundleSymbolicName;
private volatile Version m_bundleVersion;
@@ -249,6 +251,12 @@
m_libraryHeaders = tmp;
}
+ //
+ // Parse activation policy.
+ //
+
+ m_activationPolicy = parseActivationPolicy(headerMap);
+
// Do final checks and normalization of manifest.
if (getManifestVersion().equals("2"))
{
@@ -298,6 +306,11 @@
return (manifestVersion == null) ? "1" : manifestVersion.trim();
}
+ public int getActivationPolicy()
+ {
+ return m_activationPolicy;
+ }
+
public boolean isExtension()
{
return m_isExtension;
@@ -1175,6 +1188,32 @@
return result;
}
+ private static int parseActivationPolicy(Map headerMap)
+ {
+ int policy = IModule.EAGER_ACTIVATION;
+
+ Object[][][] clauses = parseStandardHeader(
+ (String) headerMap.get(Constants.BUNDLE_ACTIVATIONPOLICY));
+
+ if (clauses.length > 0)
+ {
+ // Just look for a "path" matching the lazy policy, ignore
+ // everything else.
+ for (int i = 0;
+ i < clauses[0][CLAUSE_PATHS_INDEX].length;
+ i++)
+ {
+ if (clauses[0][CLAUSE_PATHS_INDEX][i].equals(Constants.ACTIVATION_LAZY))
+ {
+ policy = IModule.LAZY_ACTIVATION;
+ break;
+ }
+ }
+ }
+
+ return policy;
+ }
+
public static final int CLAUSE_PATHS_INDEX = 0;
public static final int CLAUSE_DIRECTIVES_INDEX = 1;
public static final int CLAUSE_ATTRIBUTES_INDEX = 2;
diff --git a/framework/src/main/java/org/apache/felix/moduleloader/IModule.java b/framework/src/main/java/org/apache/felix/moduleloader/IModule.java
index 37994de..833ca54 100644
--- a/framework/src/main/java/org/apache/felix/moduleloader/IModule.java
+++ b/framework/src/main/java/org/apache/felix/moduleloader/IModule.java
@@ -29,6 +29,9 @@
public interface IModule
{
+ final static int EAGER_ACTIVATION = 0;
+ final static int LAZY_ACTIVATION = 1;
+
void setSecurityContext(Object securityContext);
Object getSecurityContext();
@@ -41,6 +44,7 @@
IRequirement[] getRequirements();
IRequirement[] getDynamicRequirements();
R4Library[] getNativeLibraries();
+ int getActivationPolicy();
// Run-time data access methods.
Bundle getBundle();