private void handleReparent(EclipseContext newParent, Set<Scheduled> scheduled) { // TBD should we lock waiting list while doing reparent? // Add "boolean inReparent" on the root context and process right away? processWaiting(); // 1) everybody who depends on me: I need to collect combined list of names injected Set<String> usedNames = new HashSet<String>(); collectDependentNames(usedNames); // 2) for each used name: for (Iterator<String> i = usedNames.iterator(); i.hasNext(); ) { String name = i.next(); if (localValues.containsKey(name)) continue; // it is a local value Object oldValue = get(name); Object newValue = (newParent != null) ? newParent.get(name) : null; if (oldValue != newValue) invalidate(name, ContextChangeEvent.ADDED, oldValue, scheduled); } ContextChangeEvent event = new ContextChangeEvent(this, ContextChangeEvent.ADDED, null, null, null); for (Computation computation : localValueComputations.values()) { Collection<HashSet<Computation>> allListeners = listeners.values(); for (HashSet<Computation> group : allListeners) { group.remove(computation); } computation.handleInvalid(event, scheduled); } localValueComputations.clear(); }
private void collectDependentNames(Set<String> usedNames) { Set<String> tmp = listeners.keySet(); // clone internal name list usedNames.addAll(tmp); for (EclipseContext childContext : getChildren()) { childContext.collectDependentNames(usedNames); } }