Exemple #1
0
  public void registerProcess(Process process) {
    Process existingProcess = getProcess(process.getOwner(), process.getID());

    // is there already a process registered for the ID?
    if (existingProcess == null) {
      synchronized (mProcesses) {
        mProcesses.addFirst(process);
      }
    } else {
      // maybe it is the same process?
      if (existingProcess != process) {
        throw new RuntimeException(
            this
                + " - Process ID "
                + process.getID()
                + " already in use for "
                + existingProcess
                + ". Can not use it for "
                + process
                + ".");
      }
    }
  }
Exemple #2
0
  /** Returns a process if it is changeable by the entity and has the given process number. */
  public Process getProcess(Identity owner, int processID) {
    synchronized (mProcesses) {
      if (mProcesses != null) {
        for (Process process : mProcesses) {
          if (process.getID() == processID) {
            // do we filter for owners?
            if (owner != null) {
              // check if the entities are the same
              if (process.isChangableBy(owner)) {
                return process;
              }
            } else {
              return process;
            }
          }
        }
      }
    }

    return null;
  }