in plugins/org.apache.karaf.eik.workbench/src/main/java/org/apache/karaf/eik/workbench/internal/eclipse/EclipseRuntimeDataProvider.java [154:227]
public void start() {
context.addBundleListener(eclipseBundleListener);
context.addServiceListener(eclipseAllServiceListener);
final Job initializeJob = new Job("Populating OSGi Runtime view data for: Eclipse Workbench") {
@Override
public IStatus run(IProgressMonitor monitor) {
if (monitor == null) {
monitor = new NullProgressMonitor();
}
final Bundle[] bundles;
final ServiceReference[] services;
try {
bundles = context.getBundles();
services = context.getAllServiceReferences(null, null);
} catch (InvalidSyntaxException e) {
// TODO: Log something?
return new Status(IStatus.ERROR, KarafWorkbenchActivator.PLUGIN_ID,
"Unable to get service references for running Eclipse Workbench", e);
}
int servicesLength = 0;
if (services != null) {
servicesLength = services.length;
}
monitor.worked(10);
monitor.beginTask("Populating view data set", bundles.length + servicesLength);
monitor.subTask("OSGi Bundles");
for (Bundle b : bundles) {
/*
* This bundle can't be added because it does not have a
* context
*/
if (b == null || b.getBundleContext() == null) {
continue;
}
synchronized (bundleSet) {
bundleSet.add(new BundleItem(b, startLevel, packageAdmin));
}
monitor.worked(1);
}
// If there are no services then this is null
if (services != null) {
monitor.subTask("OSGi Services");
for (ServiceReference r : services) {
synchronized (serviceSet) {
serviceSet.add(new ServiceItem(r));
}
monitor.worked(1);
}
}
monitor.done();
return Status.OK_STATUS;
}
};
initializeJob.setPriority(Job.LONG);
initializeJob.schedule();
fireStartEvent();
}