/**
   * Notifies all registered TreeModelListeners of a change.
   *
   * @param event The TreeModelEvent to notify the listeners with.
   * @param action The action that is being reported.
   */
  private void notifyTreeModelListeners(TreeModelEvent tme, int action) {
    if (treeModelListeners != null) {
      TreeModelListener o;
      Iterator iterator;

      // Notify each listener.
      iterator = treeModelListeners.values().iterator();
      while (iterator.hasNext()) {
        o = ((TreeModelListener) ((WeakReference) iterator.next()).get());
        switch (action) {
          case NODES_CHANGED:
            ((TreeModelListener) o).treeNodesChanged(tme);
            break;
          case NODES_INSERTED:
            ((TreeModelListener) o).treeNodesInserted(tme);
            break;
          case NODES_REMOVED:
            ((TreeModelListener) o).treeNodesRemoved(tme);
            break;
          case STRUCTURE_CHANGED:
            ((TreeModelListener) o).treeStructureChanged(tme);
        }
      }
    }
  }
  /**
   * The StatusEvent is sent to all registered listeners. This is done in the current thread.
   *
   * @param event The StatusEvent to notify the listeners with.
   */
  protected void notifyStatusListeners(StatusEvent e) {
    StatusListener sListener;
    Iterator iterator;

    // Notify each listener.  Since this class "echos" events recieved,
    // a check is made to be sure that the originating object is not
    // notified.  Such a thing may cause an endless loop if the source
    // object doesn't check the event's origin.
    iterator = statusListeners.values().iterator();
    while (iterator.hasNext()) {
      sListener = ((StatusListener) ((WeakReference) iterator.next()).get());
      if (sListener != null) {
        sListener.statusChanged(e);
      }
    }
  }
  public void close() {
    List<CodePoolClassloader> loaders;
    lock.lock();
    try {
      loaders = new ArrayList<>(classloaders.values());
      classloaders.clear();
    } finally {
      lock.unlock();
    }

    for (CodePoolClassloader cl : loaders) {
      try {
        cl.close();
      } catch (IOException err) {
      }
    }
  }