Only merge fragments for dynamic imports if necessary. (FELIX-1435)
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@808433 13f79535-47bb-0310-9956-ffa450edef68
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 62690f0..1516d86 100644
--- a/framework/src/main/java/org/apache/felix/framework/Felix.java
+++ b/framework/src/main/java/org/apache/felix/framework/Felix.java
@@ -3938,14 +3938,19 @@
// Before trying to resolve, tell the resolver state to
// merge all fragments into their hosts.
- try
+// TODO: FRAGMENT - We need to rethink how we do fragment merging...probably merging
+// as bundles are installed would be better.
+ if (Resolver.isDynamicImportAllowed(importer, pkgName))
{
- m_resolverState.mergeFragments(null);
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
- throw new ResolveException("Unable to merge fragments", importer, null);
+ try
+ {
+ m_resolverState.mergeFragments(null);
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ throw new ResolveException("Unable to merge fragments", importer, null);
+ }
}
Object[] result = m_resolver.resolveDynamicImport(m_resolverState, importer, pkgName);
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 c3dad18..14b843c 100644
--- a/framework/src/main/java/org/apache/felix/framework/FelixResolverState.java
+++ b/framework/src/main/java/org/apache/felix/framework/FelixResolverState.java
@@ -89,8 +89,8 @@
}
// Need to remove any previously attached, but not resolved fragments.
- // TODO: FRAGMENT - Would be better to have the previous resolves
- // not leave fragments attached.
+// TODO: FRAGMENT - We need to rethink how we do fragment merging...probably merging
+// as bundles are installed would be better.
((ModuleImpl) host).attachFragments(null);
// Fragments are grouped by symbolic name and descending version.
diff --git a/framework/src/main/java/org/apache/felix/framework/searchpolicy/Resolver.java b/framework/src/main/java/org/apache/felix/framework/searchpolicy/Resolver.java
index 3531402..5450de5 100644
--- a/framework/src/main/java/org/apache/felix/framework/searchpolicy/Resolver.java
+++ b/framework/src/main/java/org/apache/felix/framework/searchpolicy/Resolver.java
@@ -196,7 +196,11 @@
return null;
}
- private static boolean isDynamicImportAllowed(IModule importer, String pkgName)
+// TODO: FRAGMENT - This is only public so we could avoid merging fragments when
+// when it wasn't necessary for dynamic imports. We need to rethink how we
+// do fragment merging...probably merging as bundles are installed would be
+// better.
+ public static boolean isDynamicImportAllowed(IModule importer, String pkgName)
{
// If any of the module exports this package, then we cannot
// attempt to dynamically import it.