コード例 #1
0
  /**
   * Returns all the target VMs that are running at this launcher's target address. Note that these
   * target VMs may or may not have been launched by this launcher. Note also that if the list of
   * running VMs doesn't change on the target, two calls to this method return VMs that are equal.
   *
   * @return the list of running target VMs
   */
  public LocalVirtualMachine[] getRunningVirtualMachines() {
    // Select the VMs that are actually running
    Vector actuallyRunning = new Vector();
    Enumeration en = this.runningVMs.elements();
    while (en.hasMoreElements()) {
      LocalVirtualMachine vm = (LocalVirtualMachine) en.nextElement();
      if (vm.isRunning()) actuallyRunning.addElement(vm);
    }
    this.runningVMs = actuallyRunning;

    // Return the running VMs
    int size = actuallyRunning.size();
    LocalVirtualMachine[] result = new LocalVirtualMachine[size];
    for (int i = 0; i < size; i++) result[i] = (LocalVirtualMachine) actuallyRunning.elementAt(i);
    return result;
  }