/** * Close this {@code BundleTracker}. * * <p>This method should be called when this {@code BundleTracker} should end the tracking of * bundles. * * <p>This implementation calls {@link #getBundles()} to get the list of tracked bundles to * remove. */ public void close() { final Bundle[] bundles; final Tracked outgoing; synchronized (this) { outgoing = tracked; if (outgoing == null) { return; } if (DEBUG) { System.out.println("BundleTracker.close"); // $NON-NLS-1$ } outgoing.close(); bundles = getBundles(); tracked = null; try { context.removeBundleListener(outgoing); } catch (IllegalStateException e) { /* In case the context was stopped. */ } } if (bundles != null) { for (int i = 0; i < bundles.length; i++) { outgoing.untrack(bundles[i], null); } } }
/** * Remove a bundle from this {@code BundleTracker}. * * <p>The specified bundle will be removed from this {@code BundleTracker} . If the specified * bundle was being tracked then the {@code BundleTrackerCustomizer.removedBundle} method will be * called for that bundle. * * @param bundle The {@code Bundle} to be removed. */ public void remove(Bundle bundle) { final Tracked t = tracked(); if (t == null) { /* if BundleTracker is not open */ return; } t.untrack(bundle, null); }