public void handleEvent(org.osgi.service.event.Event event) { if (!requestor.isValid()) { unsubscribe(requestor); return; } addCurrentEvent(topic, event); requestor.resolveArguments(false); removeCurrentEvent(topic); if (uiSync == null) { if (logger != null) logger.log(Level.WARNING, "No realm found to process UI event " + event); return; } else { uiSync.syncExec( new Runnable() { public void run() { requestor.execute(); } }); } }
@Override public boolean update(IEclipseContext eventsContext, int eventType, Object[] extraArguments) { if (eventType == ContextChangeEvent.INITIAL) { // needs to be done inside runnable to establish dependencies for (int i = 0; i < keys.length; i++) { if (keys[i] == null) continue; IEclipseContext targetContext = (active[i]) ? context.getActiveLeaf() : context; if (ECLIPSE_CONTEXT_NAME.equals(keys[i])) { result[i] = targetContext; IEclipseContext parent = targetContext.getParent(); // creates pseudo-link if (parent == null) targetContext.get(ECLIPSE_CONTEXT_NAME); // pseudo-link in case there is no parent } else if (targetContext.containsKey(keys[i])) result[i] = targetContext.get(keys[i]); } return true; } if (eventType == ContextChangeEvent.DISPOSE) { if (eventsContext == context) { ContextObjectSupplier originatingSupplier = eventsContext.getLocal(ContextObjectSupplier.class); requestor.disposed(originatingSupplier); return false; } } else if (eventType == ContextChangeEvent.UNINJECTED) { if (eventsContext == context) { ContextObjectSupplier originatingSupplier = eventsContext.getLocal(ContextObjectSupplier.class); return requestor.uninject(extraArguments[0], originatingSupplier); } } else { if (!requestor.isValid()) return false; // remove this listener requestor.resolveArguments(false); requestor.execute(); } return true; }