From adf131ab20f3266dd1d44a858957edd3b5739342 Mon Sep 17 00:00:00 2001 From: mhussein Date: Wed, 22 Apr 2015 11:06:47 +0200 Subject: bug390470 Use ranking to select services In 3.7.1, org.eclipse.equinox.p2.core does not select services based on ranking. This is a serious issue and impacts installing your own services. This patch uses existing service.ranking property to rank services. Check bug390470 for more details on the problems and solution. Change-Id: I36382a260f12cb1df82be21959eb5aac97fcbd0f Signed-off-by: mhussein --- .../src/org/eclipse/equinox/internal/p2/core/ProvisioningAgent.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/ProvisioningAgent.java b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/ProvisioningAgent.java index 32a6a30ef..954691dce 100644 --- a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/ProvisioningAgent.java +++ b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/ProvisioningAgent.java @@ -51,16 +51,16 @@ public class ProvisioningAgent implements IProvisioningAgent, ServiceTrackerCust if (service != null) return service; //attempt to get factory service from service registry - Collection> refs; + PriorityQueue> refs; try { - refs = context.getServiceReferences(IAgentServiceFactory.class, "(" + IAgentServiceFactory.PROP_CREATED_SERVICE_NAME + '=' + serviceName + ')'); //$NON-NLS-1$ + refs = new PriorityQueue>(context.getServiceReferences(IAgentServiceFactory.class, "(" + IAgentServiceFactory.PROP_CREATED_SERVICE_NAME + '=' + serviceName + ')')); //$NON-NLS-1$ } catch (InvalidSyntaxException e) { } catch (InvalidSyntaxException e) { e.printStackTrace(); return null; } if (refs == null || refs.isEmpty()) return null; - ServiceReference firstRef = refs.iterator().next(); + ServiceReference firstRef = refs.peek(); //track the factory so that we can automatically remove the service when the factory goes away ServiceTracker tracker = new ServiceTracker(context, firstRef, this); tracker.open(); -- cgit v1.2.3