Search in sources :

Example 16 with BundleListener

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);
    }
}
Also used : BundleListener(org.osgi.framework.BundleListener) SynchronousBundleListener(org.osgi.framework.SynchronousBundleListener)

Example 17 with BundleListener

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);
    }
}
Also used : BundleEvent(org.osgi.framework.BundleEvent) BundleListener(org.osgi.framework.BundleListener) SynchronousBundleListener(org.osgi.framework.SynchronousBundleListener) SynchronousBundleListener(org.osgi.framework.SynchronousBundleListener)

Example 18 with BundleListener

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);
    }
}
Also used : BundleEvent(org.osgi.framework.BundleEvent) BundleListener(org.osgi.framework.BundleListener) BundleContext(org.osgi.framework.BundleContext)

Aggregations

BundleListener (org.osgi.framework.BundleListener)18 BundleEvent (org.osgi.framework.BundleEvent)14 SynchronousBundleListener (org.osgi.framework.SynchronousBundleListener)9 Bundle (org.osgi.framework.Bundle)8 File (java.io.File)5 BundleContext (org.osgi.framework.BundleContext)5 IOException (java.io.IOException)4 GitAPIException (org.eclipse.jgit.api.errors.GitAPIException)4 FileInputStream (java.io.FileInputStream)3 Properties (java.util.Properties)3 ZipFile (org.apache.commons.compress.archivers.zip.ZipFile)3 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 ExecutorService (java.util.concurrent.ExecutorService)2 MBeanServer (javax.management.MBeanServer)2 ObjectName (javax.management.ObjectName)2 Logger (org.apache.aries.jmx.Logger)2 Git (org.eclipse.jgit.api.Git)2