@Override public int hashCode() { final int prime = 31; int hashRresult = 1; hashRresult = prime * hashRresult + ((context == null) ? 0 : context.hashCode()); hashRresult = prime * hashRresult + ((requestor == null) ? 0 : requestor.hashCode()); return hashRresult; }
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 equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; ContextInjectionListener other = (ContextInjectionListener) obj; if (context == null) { if (other.context != null) return false; } else if (!context.equals(other.context)) return false; if (requestor == null) { if (other.requestor != null) return false; } else if (!requestor.equals(other.requestor)) return false; return true; }
@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; }
@Override public String toString() { return requestor.toString(); }