You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ri...@apache.org on 2011/10/28 23:30:02 UTC
svn commit: r1190586 - in
/felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework:
BundleWiringImpl.java StatefulResolver.java
Author: rickhall
Date: Fri Oct 28 21:30:02 2011
New Revision: 1190586
URL: http://svn.apache.org/viewvc?rev=1190586&view=rev
Log:
Initial support for dynamic imports using OBR resolver.
Modified:
felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/BundleWiringImpl.java
felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/StatefulResolver.java
Modified: felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/BundleWiringImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/BundleWiringImpl.java?rev=1190586&r1=1190585&r2=1190586&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/BundleWiringImpl.java (original)
+++ felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/BundleWiringImpl.java Fri Oct 28 21:30:02 2011
@@ -2560,7 +2560,7 @@ public class BundleWiringImpl implements
}
*/
// Next, check to see if the package is dynamically imported by the revision.
- if (resolver.isAllowedDynamicImport(revision, pkgName))
+ if (resolver.getMatchingDynamicRequirement(revision, pkgName) != null)
{
// Try to see if there is an exporter available.
Map<String, String> dirs = Collections.EMPTY_MAP;
Modified: felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/StatefulResolver.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/StatefulResolver.java?rev=1190586&r1=1190585&r2=1190586&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/StatefulResolver.java (original)
+++ felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/StatefulResolver.java Fri Oct 28 21:30:02 2011
@@ -229,7 +229,8 @@ class StatefulResolver
// dynamic import is allowed without holding any locks, but this is
// okay since the resolver will double check later after we have
// acquired the global lock below.
- if ((revision.getWiring() != null) && isAllowedDynamicImport(revision, pkgName))
+ Requirement dynReq = getMatchingDynamicRequirement(revision, pkgName);
+ if (dynReq != null)
{
// Acquire global lock.
boolean locked = m_felix.acquireGlobalLock();
@@ -248,6 +249,9 @@ class StatefulResolver
}
m_isResolving = true;
+ // Get matching dynamic requirement.
+ Requirement dynReq = getMatchingDynamicRequirement(revision, pkgName);
+ SortedSet candidates = getDynamicCandidates(dynReq, pkg)
Map<Resource, List<Wire>> wireMap = null;
try
{
@@ -272,10 +276,9 @@ class StatefulResolver
ResolutionException rethrow = null;
try
{
-// TODO: RFC-112 - Fix dynamic import resolve.
-// wireMap = m_resolver.resolve(
-// m_resolverState, revision, pkgName,
-// m_resolverState.getFragments());
+ wireMap = m_resolver.resolve(
+ m_resolverState, revision, dynReq,
+ candidates, m_resolverState.getFragments());
}
catch (ResolutionException ex)
{
@@ -487,15 +490,13 @@ class StatefulResolver
}
}
- // This method duplicates a lot of logic from:
- // ResolverImpl.getDynamicImportCandidates()
- boolean isAllowedDynamicImport(BundleRevision revision, String pkgName)
+ Requirement getMatchingDynamicRequirement(BundleRevision revision, String pkgName)
{
// Unresolved revisions cannot dynamically import, nor can the default
// package be dynamically imported.
if ((revision.getWiring() == null) || pkgName.length() == 0)
{
- return false;
+ return null;
}
// If the revision doesn't have dynamic imports, then just return
@@ -504,7 +505,7 @@ class StatefulResolver
Util.getDynamicRequirements(revision.getWiring().getRequirements(null));
if ((dynamics == null) || dynamics.isEmpty())
{
- return false;
+ return null;
}
// If the revision exports this package, then we cannot
@@ -514,7 +515,7 @@ class StatefulResolver
if (cap.getNamespace().equals(BundleRevision.PACKAGE_NAMESPACE)
&& cap.getAttributes().get(BundleRevision.PACKAGE_NAMESPACE).equals(pkgName))
{
- return false;
+ return null;
}
}
@@ -522,7 +523,7 @@ class StatefulResolver
// we cannot dynamically import it.
if (((BundleWiringImpl) revision.getWiring()).hasPackageSource(pkgName))
{
- return false;
+ return null;
}
// Loop through the importer's dynamic requirements to determine if