From 6bd3bf56b7610682aa596e0f5aefd5f96d1d2321 Mon Sep 17 00:00:00 2001 From: David Bosschaert Date: Fri, 24 Jan 2014 09:19:52 +0000 Subject: [PATCH] Sort the output of subsystem:list --- .../org/coderthoughts/subsystems/gogo/Activator.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/subsystem-gogo-command/src/main/java/org/coderthoughts/subsystems/gogo/Activator.java b/subsystem-gogo-command/src/main/java/org/coderthoughts/subsystems/gogo/Activator.java index 3164c1a..c9704d0 100644 --- a/subsystem-gogo-command/src/main/java/org/coderthoughts/subsystems/gogo/Activator.java +++ b/subsystem-gogo-command/src/main/java/org/coderthoughts/subsystems/gogo/Activator.java @@ -16,6 +16,8 @@ import java.net.URL; import java.util.Dictionary; import java.util.Hashtable; +import java.util.Map; +import java.util.TreeMap; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; @@ -55,12 +57,19 @@ public void stop(long id) { } public void list() throws InvalidSyntaxException { + Map subsystems = new TreeMap(); + for (ServiceReference ref : bundleContext.getServiceReferences(Subsystem.class, null)) { Subsystem s = bundleContext.getService(ref); if (s != null) { - System.out.printf("%d\t%s\t%s\n", s.getSubsystemId(), s.getState(), s.getSymbolicName()); + subsystems.put(s.getSubsystemId(), + String.format("%d\t%s\t%s %s", s.getSubsystemId(), s.getState(), s.getSymbolicName(), s.getVersion())); } } + + for (String entry : subsystems.values()) { + System.out.println(entry); + } } private Subsystem getSubsystem(long id) {