karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject [4/6] karaf git commit: [KARAF-3529] Fix some problems when applying the computed resolution
Date Thu, 26 Feb 2015 10:35:23 GMT
[KARAF-3529] Fix some problems when applying the computed resolution

This problem is visible when installing spring-security feature where java.annotation is not
resolved at all. Another problem is when resolving fragments, as we need to check resources
wired to the host.

Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/da5a5771
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/da5a5771
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/da5a5771

Branch: refs/heads/master
Commit: da5a5771c3ffdf9111e37dd1dab9246e057dcb2f
Parents: 01fa005
Author: Guillaume Nodet <gnodet@gmail.com>
Authored: Thu Feb 26 09:06:17 2015 +0100
Committer: Guillaume Nodet <gnodet@gmail.com>
Committed: Thu Feb 26 10:53:26 2015 +0100

----------------------------------------------------------------------
 .../internal/resolver/SimpleFilter.java         |  2 +-
 .../features/internal/service/Deployer.java     | 11 ++++++-
 .../internal/service/FeaturesServiceImpl.java   | 33 ++++++++++----------
 3 files changed, 28 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/da5a5771/features/core/src/main/java/org/apache/karaf/features/internal/resolver/SimpleFilter.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/resolver/SimpleFilter.java
b/features/core/src/main/java/org/apache/karaf/features/internal/resolver/SimpleFilter.java
index 2354519..431d023 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/resolver/SimpleFilter.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/resolver/SimpleFilter.java
@@ -485,7 +485,7 @@ public class SimpleFilter {
                                         vr.getCeiling().toString(),
                                         SimpleFilter.LTE)
                         );
-                    } else {
+                    } else if (!vr.getCeiling().equals(VersionRange.INFINITE_VERSION)) {
                         SimpleFilter not =
                                 new SimpleFilter(null, new ArrayList(), SimpleFilter.NOT);
                         ((List<Object>) not.getValue()).add(

http://git-wip-us.apache.org/repos/asf/karaf/blob/da5a5771/features/core/src/main/java/org/apache/karaf/features/internal/service/Deployer.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/service/Deployer.java
b/features/core/src/main/java/org/apache/karaf/features/internal/service/Deployer.java
index 3b7d18d..9a0d6a3 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/service/Deployer.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/service/Deployer.java
@@ -761,7 +761,7 @@ public class Deployer {
         // Resolve bundles
         toResolve.addAll(toStart);
         toResolve.addAll(toRefresh.keySet());
-        removeFragmentsAndBundlesInState(toResolve, UNINSTALLED);
+        removeBundlesInState(toResolve, UNINSTALLED);
         callback.resolveBundles(toResolve, resolver.getWiring(), deployment.resToBnd);
 
         // Compute bundles to start
@@ -992,6 +992,15 @@ public class Deployer {
         }
     }
 
+    private void removeBundlesInState(Collection<Bundle> bundles, int state) {
+        for (Iterator<Bundle> iterator = bundles.iterator(); iterator.hasNext();) {
+            Bundle bundle = iterator.next();
+            if ((bundle.getState() & state) != 0) {
+                iterator.remove();
+            }
+        }
+    }
+
     protected void logDeployment(Deployer.Deployment overallDeployment, boolean verbose)
{
         if (overallDeployment.regions.isEmpty()) {
             print("No deployment change.", verbose);

http://git-wip-us.apache.org/repos/asf/karaf/blob/da5a5771/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java
b/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java
index 2573296..d98049f 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java
@@ -77,13 +77,13 @@ import org.osgi.framework.ServiceRegistration;
 import org.osgi.framework.Version;
 import org.osgi.framework.hooks.resolver.ResolverHook;
 import org.osgi.framework.hooks.resolver.ResolverHookFactory;
+import org.osgi.framework.namespace.HostNamespace;
 import org.osgi.framework.startlevel.BundleStartLevel;
 import org.osgi.framework.startlevel.FrameworkStartLevel;
 import org.osgi.framework.wiring.BundleCapability;
 import org.osgi.framework.wiring.BundleRequirement;
 import org.osgi.framework.wiring.BundleRevision;
 import org.osgi.framework.wiring.FrameworkWiring;
-import org.osgi.resource.Requirement;
 import org.osgi.resource.Resource;
 import org.osgi.resource.Wire;
 import org.osgi.service.cm.Configuration;
@@ -1181,23 +1181,24 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall
                 if (Thread.currentThread() == thread) {
                     Bundle sourceBundle = requirement.getRevision().getBundle();
                     Resource sourceResource = bndToRes.get(sourceBundle);
+                    Set<Resource> wired = new HashSet<>();
+                    // Get a list of allowed wired resources
+                    wired.add(sourceResource);
                     for (Wire wire : wiring.get(sourceResource)) {
-                        Requirement req = wire.getRequirement();
-                        if (req.getNamespace().equals(requirement.getNamespace())
-                                && req.getAttributes().equals(requirement.getAttributes())
-                                && req.getDirectives().equals(requirement.getDirectives()))
{
-                            for (Iterator<BundleCapability> capIter = candidates.iterator();
capIter.hasNext(); ) {
-                                BundleCapability cap = capIter.next();
-                                BundleRevision br = cap.getRevision();
-                                if (br == wire.getCapability().getResource()) {
-                                    continue;
-                                }
-                                Resource res = bndToRes.get(br.getBundle());
-                                if (res != wire.getCapability().getResource()) {
-                                    capIter.remove();
-                                }
+                        wired.add(wire.getProvider());
+                        if (HostNamespace.HOST_NAMESPACE.equals(wire.getRequirement().getNamespace()))
{
+                            for (Wire hostWire : wiring.get(wire.getProvider())) {
+                                wired.add(hostWire.getProvider());
                             }
-                            break;
+                        }
+                    }
+                    // Remove candidates that are not allowed
+                    for (Iterator<BundleCapability> candIter = candidates.iterator();
candIter.hasNext(); ) {
+                        BundleCapability cand = candIter.next();
+                        BundleRevision br = cand.getRevision();
+                        Resource res = bndToRes.get(br.getBundle());
+                        if (!wired.contains(br) && !wired.contains(res)) {
+                            candIter.remove();
                         }
                     }
                 }


Mime
View raw message