Exemplo n.º 1
0
  /**
   * Runs the next component in the run list.
   *
   * <p>If null is passed it is assumed the call is from internal not a component; otherwise the
   * notifyDependants() call is made on the target.
   *
   * <p>After the notification, the next component with no dependencies is found and run via async
   * call; if none, the register stops.
   */
  public void componentReady(Component target) {
    if (runList != null) {

      // Nothing is running if we got this callback.
      running = null;

      // This target has run, so it is considered a resolved
      // dependency; notify any one depending on it, so our
      // next search finds (hopefully) another dependency
      // free component to run.
      if (target != null) {
        target.notifyWaiting();
        if (runList.contains(target)) runList.remove(target);
      }

      // Find next
      Component next = null;
      for (Component c : runList) {
        if (c.getDependencyCount() == 0) {
          next = c;
          break;
        }
      }

      // More?
      if (next != null) runComponentAsync(next);

      // Done?
      else {
        // Stop wait for components to load.
        if ((timer != null) && (runList.size() == 0)) {
          timer.cancel();
          timer = null;
        }
        invokeReadyCallbacks();
      }
    }
  }