private void cleanup() { m_dependencyEvents.values().forEach(eventList -> { eventList.forEach(event -> event.close()); eventList.clear(); }); }
private void handleSwapped(DependencyContext dc, Event oldEvent, Event newEvent) { try { if (! m_isStarted) { return; } Set<Event> dependencyEvents = m_dependencyEvents.get(dc); dependencyEvents.remove(oldEvent); dependencyEvents.add(newEvent); // Depending on the state, we possible have to invoke the callbacks and update the component instance. switch (m_state) { case WAITING_FOR_REQUIRED: // No need to swap, we don't have yet injected anything break; case INSTANTIATED_AND_WAITING_FOR_REQUIRED: // Only swap *non* instance-bound dependencies if (!dc.isInstanceBound()) { invokeSwapCallback(dc, oldEvent, newEvent); } break; case TRACKING_OPTIONAL: invokeSwapCallback(dc, oldEvent, newEvent); break; default: } } finally { oldEvent.close(); } }