public class ServicesIdCompleter implements Completer {
private BundleContext bundleContext;
public int complete(String buffer, int cursor, List candidates) {
StringsCompleter delegate = new StringsCompleter();
Bundle[] bundles = bundleContext.getBundles();
for (Bundle bundle : bundles) {
ServiceReference[] references = bundle.getRegisteredServices();
if (references != null) {
for (ServiceReference reference : references) {
if (reference.getProperty(Constants.SERVICE_ID) != null) {
delegate.getStrings().add(reference.getProperty(Constants.SERVICE_ID).toString());
}
}
}
}
return delegate.complete(buffer, cursor, candidates);
}