Skip to content

Commit

Permalink
Sort the output of subsystem:list
Browse files Browse the repository at this point in the history
  • Loading branch information
bosschaert committed Jan 24, 2014
1 parent 4796d89 commit 6bd3bf5
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -55,12 +57,19 @@ public void stop(long id) {
}

public void list() throws InvalidSyntaxException {
Map<Long, String> subsystems = new TreeMap<Long, String>();

for (ServiceReference<Subsystem> 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) {
Expand Down

0 comments on commit 6bd3bf5

Please sign in to comment.