Bug: 550219 - Register CommandProviderAdapter service with the same
ranking than the adapted CommandProvider service

Change-Id: I59c00ad276bf454a71794d9cbb7f753d84e33344
Signed-off-by: Maxime Porhel <maxime.porhel@obeo.fr>
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/command/adapter/Activator.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/command/adapter/Activator.java
old mode 100755
new mode 100644
index 7159457..e2a6a43
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/command/adapter/Activator.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/command/adapter/Activator.java
@@ -39,6 +39,7 @@
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleException;
+import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceReference;
 import org.osgi.framework.ServiceRegistration;
 import org.osgi.service.condpermadmin.ConditionalPermissionAdmin;
@@ -184,7 +185,12 @@
 
 				if (commandMethods.length > 0) {
 					List<ServiceRegistration<?>> registrations = new ArrayList<>();
-					registrations.add(context.registerService(Object.class, new CommandProviderAdapter(command, commandMethods), getAttributes(commandMethods)));
+					Dictionary<String, Object> attributes = getAttributes(commandMethods);
+					Object serviceRanking = reference.getProperty(Constants.SERVICE_RANKING);
+					if (serviceRanking != null) {
+					    attributes.put(Constants.SERVICE_RANKING, serviceRanking);
+					}
+					registrations.add(context.registerService(Object.class, new CommandProviderAdapter(command, commandMethods), attributes));
 					return registrations;
 				} else {
 					context.ungetService(reference);