Search in sources :

Example 21 with SynchronousBundleListener

use of org.osgi.framework.SynchronousBundleListener 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)

Aggregations

SynchronousBundleListener (org.osgi.framework.SynchronousBundleListener)21 BundleEvent (org.osgi.framework.BundleEvent)17 Bundle (org.osgi.framework.Bundle)13 File (java.io.File)8 BundleException (org.osgi.framework.BundleException)8 BundleListener (org.osgi.framework.BundleListener)6 IOException (java.io.IOException)5 HashMap (java.util.HashMap)5 Test (org.junit.Test)4 LinkedHashMap (java.util.LinkedHashMap)3 Map (java.util.Map)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 Equinox (org.eclipse.osgi.launch.Equinox)3 BundleContext (org.osgi.framework.BundleContext)3 FileInputStream (java.io.FileInputStream)2 ArrayList (java.util.ArrayList)2 Properties (java.util.Properties)2 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)2