use of org.osgi.framework.BundleListener in project eclipse.platform.runtime by eclipse.
the class OSGiObjectSupplier method untrack.
private void untrack(final IRequestor requestor) {
synchronized (requestor2listener) {
BundleListener l = requestor2listener.remove(requestor);
localBundleContext.removeBundleListener(l);
}
}
use of org.osgi.framework.BundleListener in project eclipse.platform.runtime by eclipse.
the class OSGiObjectSupplier method track.
private void track(final Bundle bundle, final IRequestor requestor) {
// A _synchronous_ BundleListener asserts that the BC is un-injected,
// _before_ it becomes invalid (state-wise).
BundleListener listener = new SynchronousBundleListener() {
@Override
public void bundleChanged(BundleEvent event) {
if (event.getBundle().equals(bundle)) {
if (requestor.isValid()) {
requestor.resolveArguments(false);
requestor.execute();
}
}
}
};
synchronized (requestor2listener) {
localBundleContext.addBundleListener(listener);
requestor2listener.put(requestor, listener);
}
}
use of org.osgi.framework.BundleListener in project eclipse.platform.runtime by eclipse.
the class Expressions method createClassCaches.
private static void createClassCaches() {
if (fgKnownClasses == null) {
fgKnownClasses = new WeakHashMap<>();
fgNotFoundClasses = new WeakHashMap<>();
BundleContext bundleContext = ExpressionPlugin.getDefault().getBundleContext();
BundleListener listener = new BundleListener() {
@Override
public void bundleChanged(BundleEvent event) {
// Invalidate the caches if any of the bundles is stopped
if (event.getType() == BundleEvent.STOPPED) {
synchronized (Expressions.class) {
fgKnownClasses.clear();
fgNotFoundClasses.clear();
}
}
}
};
ExpressionPlugin.fgBundleListener = listener;
bundleContext.addBundleListener(listener);
}
}
Aggregations