Search in sources :

Example 1 with StartupMonitor

use of org.eclipse.osgi.service.runnable.StartupMonitor in project rt.equinox.framework by eclipse.

the class EclipseStarter method updateSplash.

private static void updateSplash(Semaphore semaphore, StartupEventListener listener) throws InterruptedException {
    ServiceTracker<StartupMonitor, StartupMonitor> monitorTracker = new ServiceTracker<>(context, StartupMonitor.class.getName(), null);
    try {
        monitorTracker.open();
    } catch (IllegalStateException e) {
        // do nothing; this can happen if the framework shutdown
        return;
    }
    try {
        while (true) {
            StartupMonitor monitor = monitorTracker.getService();
            if (monitor != null) {
                try {
                    monitor.update();
                } catch (Throwable e) {
                // ignore exceptions thrown by the monitor
                }
            }
            // can we acquire the semaphore yet?
            if (semaphore.tryAcquire(50, TimeUnit.MILLISECONDS))
                // done
                break;
        // else still working, spin another update
        }
    } finally {
        if (listener != null) {
            try {
                context.removeBundleListener(listener);
                monitorTracker.close();
            } catch (IllegalStateException e) {
            // do nothing; this can happen if the framework shutdown
            }
        }
    }
}
Also used : StartupMonitor(org.eclipse.osgi.service.runnable.StartupMonitor) ServiceTracker(org.osgi.util.tracker.ServiceTracker)

Aggregations

StartupMonitor (org.eclipse.osgi.service.runnable.StartupMonitor)1 ServiceTracker (org.osgi.util.tracker.ServiceTracker)1