public boolean getBooleanDebugOption(String option, boolean defaultValue) { if (debugTracker == null) { if (JobManager.DEBUG) JobMessages.message("Debug tracker is not set"); // $NON-NLS-1$ return defaultValue; } DebugOptions options = (DebugOptions) debugTracker.getService(); if (options != null) { String value = options.getOption(option); if (value != null) return value.equalsIgnoreCase("true"); // $NON-NLS-1$ } return defaultValue; }
/** * Returns the bundle id of the bundle that contains the provided object, or <code>null</code> if * the bundle could not be determined. */ public String getBundleId(Object object) { if (bundleTracker == null) { if (JobManager.DEBUG) JobMessages.message("Bundle tracker is not set"); // $NON-NLS-1$ return null; } PackageAdmin packageAdmin = (PackageAdmin) bundleTracker.getService(); if (object == null) return null; if (packageAdmin == null) return null; Bundle source = packageAdmin.getBundle(object.getClass()); if (source != null && source.getSymbolicName() != null) return source.getSymbolicName(); return null; }
void openServices() { BundleContext context = JobActivator.getContext(); if (context == null) { if (JobManager.DEBUG) JobMessages.message("JobsOSGiUtils called before plugin started"); // $NON-NLS-1$ return; } debugTracker = new ServiceTracker(context, DebugOptions.class.getName(), null); debugTracker.open(); bundleTracker = new ServiceTracker(context, PackageAdmin.class.getName(), null); bundleTracker.open(); }