felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dsav...@apache.org
Subject svn commit: r820341 - /felix/trunk/sigil/common/core/src/org/apache/felix/sigil/core/repository/BundleResolver.java
Date Wed, 30 Sep 2009 16:38:02 GMT
Author: dsavage
Date: Wed Sep 30 16:38:02 2009
New Revision: 820341

URL: http://svn.apache.org/viewvc?rev=820341&view=rev
Log:
Search for requirements in resolution context first (FELIX-1665)

Modified:
    felix/trunk/sigil/common/core/src/org/apache/felix/sigil/core/repository/BundleResolver.java

Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/core/repository/BundleResolver.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/core/repository/BundleResolver.java?rev=820341&r1=820340&r2=820341&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/core/repository/BundleResolver.java
(original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/core/repository/BundleResolver.java
Wed Sep 30 16:38:02 2009
@@ -468,51 +468,84 @@
 
             try
             {
-                int[] priorities = repositoryManager.getPriorityLevels();
+                if ( !findInContext( requirement, ctx ) ) 
+                {
+                    findInRepositories( requirement, ctx );
+                }
+            }
+            finally
+            {
+                ctx.endRequirement( requirement );
+            }
+        }
+    }
 
-                outer: for ( int i = 0; i < priorities.length; i++ )
+
+    private boolean findInContext(final IRequirementModelElement requirement,
+        final ResolutionContext ctx)
+    {
+        for ( final ISigilBundle b : ctx.resolution.providees.keySet() ) 
+        {
+            b.visit( new IModelWalker() 
+            {
+                public boolean visit(IModelElement element)
                 {
-                    List<ISigilBundle> providers = findProvidersAtPriority( priorities[i],
requirement, ctx );
+                    if ( requirement.accepts(element) ) {
+                        ctx.resolution.addProvider( requirement, b );
+                        return false;
+                    }
+                    return !ctx.monitor.isCanceled();
+                }
+                
+            });
+        }
+        
+        return ctx.resolution.getProvider(requirement) != null;
+    }
+
 
-                    if ( !providers.isEmpty() && !ctx.monitor.isCanceled() )
+    private void findInRepositories(IRequirementModelElement requirement,
+        ResolutionContext ctx) throws ResolutionException
+    {
+        int[] priorities = repositoryManager.getPriorityLevels();
+
+        outer: for ( int i = 0; i < priorities.length; i++ )
+        {
+            List<ISigilBundle> providers = findProvidersAtPriority( priorities[i],
requirement, ctx );
+
+            if ( !providers.isEmpty() && !ctx.monitor.isCanceled() )
+            {
+                if ( providers.size() > 1 )
+                {
+                    Collections.sort( providers, new BundleOrderComparator( requirement )
);
+                }
+
+                for ( ISigilBundle provider : providers )
+                {
+                    // reset validity - if there's another provider it can still be solved
+                    ctx.setValid( true );
+                    if ( ctx.resolution.addProvider( requirement, provider ) )
                     {
-                        if ( providers.size() > 1 )
+                        if ( ctx.config.isDependents() )
                         {
-                            Collections.sort( providers, new BundleOrderComparator( requirement
) );
+                            resolveElement( provider, ctx );
                         }
 
-                        for ( ISigilBundle provider : providers )
+                        if ( ctx.isValid() )
                         {
-                            // reset validity - if there's another provider it can still
be solved
-                            ctx.setValid( true );
-                            if ( ctx.resolution.addProvider( requirement, provider ) )
-                            {
-                                if ( ctx.config.isDependents() )
-                                {
-                                    resolveElement( provider, ctx );
-                                }
-
-                                if ( ctx.isValid() )
-                                {
-                                    break outer;
-                                }
-                                else
-                                {
-                                    ctx.resolution.removeProvider( requirement, provider
);
-                                }
-                            }
-                            else
-                            {
-                                break outer;
-                            }
+                            break outer;
                         }
+                        else
+                        {
+                            ctx.resolution.removeProvider( requirement, provider );
+                        }
+                    }
+                    else
+                    {
+                        break outer;
                     }
                 }
             }
-            finally
-            {
-                ctx.endRequirement( requirement );
-            }
         }
     }
 



Mime
View raw message