Move native library checking to resolver state. (FELIX-2035)
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@929983 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/FelixResolverState.java b/framework/src/main/java/org/apache/felix/framework/FelixResolverState.java
index f3b9bcb..9ff02c7 100644
--- a/framework/src/main/java/org/apache/felix/framework/FelixResolverState.java
+++ b/framework/src/main/java/org/apache/felix/framework/FelixResolverState.java
@@ -37,6 +37,7 @@
import org.apache.felix.framework.resolver.ResolveException;
import org.apache.felix.framework.resolver.Resolver;
import org.apache.felix.framework.util.Util;
+import org.apache.felix.framework.util.manifestparser.R4Library;
import org.osgi.framework.BundlePermission;
import org.osgi.framework.Constants;
import org.osgi.framework.Version;
@@ -808,6 +809,41 @@
}
}
+ public void checkNativeLibraries(Module module) throws ResolveException
+ {
+ // Next, try to resolve any native code, since the module is
+ // not resolvable if its native code cannot be loaded.
+ List<R4Library> libs = module.getNativeLibraries();
+ if (libs != null)
+ {
+ String msg = null;
+ // Verify that all native libraries exist in advance; this will
+ // throw an exception if the native library does not exist.
+ for (int libIdx = 0; (msg == null) && (libIdx < libs.size()); libIdx++)
+ {
+ String entryName = libs.get(libIdx).getEntryName();
+ if (entryName != null)
+ {
+ if (!module.getContent().hasEntry(entryName))
+ {
+ msg = "Native library does not exist: " + entryName;
+ }
+ }
+ }
+ // If we have a zero-length native library array, then
+ // this means no native library class could be selected
+ // so we should fail to resolve.
+ if (libs.size() == 0)
+ {
+ msg = "No matching native libraries found.";
+ }
+ if (msg != null)
+ {
+ throw new ResolveException(msg, module, null);
+ }
+ }
+ }
+
//
// Utility methods.
//
diff --git a/framework/src/main/java/org/apache/felix/framework/resolver/Resolver.java b/framework/src/main/java/org/apache/felix/framework/resolver/Resolver.java
index 9fd679c..a301969 100644
--- a/framework/src/main/java/org/apache/felix/framework/resolver/Resolver.java
+++ b/framework/src/main/java/org/apache/felix/framework/resolver/Resolver.java
@@ -33,5 +33,6 @@
{
Set<Capability> getCandidates(Module module, Requirement req, boolean obeyMandatory);
void checkExecutionEnvironment(Module module) throws ResolveException;
+ void checkNativeLibraries(Module module) throws ResolveException;
}
}
\ No newline at end of file
diff --git a/framework/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java b/framework/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java
index 723547f..963bea6 100644
--- a/framework/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java
+++ b/framework/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java
@@ -27,7 +27,6 @@
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
-import java.util.StringTokenizer;
import java.util.TreeSet;
import org.apache.felix.framework.FelixResolverState;
import org.apache.felix.framework.Logger;
@@ -36,7 +35,6 @@
import org.apache.felix.framework.capabilityset.CapabilitySet;
import org.apache.felix.framework.capabilityset.Directive;
import org.apache.felix.framework.capabilityset.Requirement;
-import org.apache.felix.framework.util.manifestparser.R4Library;
import org.apache.felix.framework.util.manifestparser.RequirementImpl;
import org.osgi.framework.Constants;
@@ -430,7 +428,7 @@
state.checkExecutionEnvironment(module);
// Verify that any native libraries match the current platform.
- verifyNativeLibraries(module);
+ state.checkNativeLibraries(module);
// Record cycle count.
cycleCount = new Integer(0);
@@ -1451,42 +1449,6 @@
return wireMap;
}
-// TODO: FELIX3 - This check should be moved to ResolverState.
- private static void verifyNativeLibraries(Module module)
- {
- // Next, try to resolve any native code, since the module is
- // not resolvable if its native code cannot be loaded.
- List<R4Library> libs = module.getNativeLibraries();
- if (libs != null)
- {
- String msg = null;
- // Verify that all native libraries exist in advance; this will
- // throw an exception if the native library does not exist.
- for (int libIdx = 0; (msg == null) && (libIdx < libs.size()); libIdx++)
- {
- String entryName = libs.get(libIdx).getEntryName();
- if (entryName != null)
- {
- if (!module.getContent().hasEntry(entryName))
- {
- msg = "Native library does not exist: " + entryName;
- }
- }
- }
- // If we have a zero-length native library array, then
- // this means no native library class could be selected
- // so we should fail to resolve.
- if (libs.size() == 0)
- {
- msg = "No matching native libraries found.";
- }
- if (msg != null)
- {
- throw new ResolveException(msg, module, null);
- }
- }
- }
-
private static class Packages
{
public final Map<String, Blame> m_exportedPkgs