private void buildCommandArgs()

in uimaj-as-core/src/main/java/org/apache/uima/aae/controller/UimacppServiceController.java [353:466]


  private void buildCommandArgs(ArrayList<String> commandArgs, Map<String, String> envVarMap,
          String exeName) throws ResourceInitializationException {

    // Get the UIMACPP_HOME value and save for use by setEnvironmentVariables
    uimacppHome = (String) envVarMap.get("UIMACPP_HOME");
    if (uimacppHome == null) {
      uimacppHome = System.getenv("UIMACPP_HOME");
      if (uimacppHome == null) {
        uimacppHome = System.getenv("UIMA_HOME") + "/uimacpp";
      }
    }

    if (!(new File(uimacppHome)).exists()) {
      throw new ResourceInitializationException(new IOException("Invalid location of UIMACPP_HOME "
              + uimacppHome));
    }

    // the Uima C++ service wrapper exe
    String cmd = uimacppHome + System.getProperty("file.separator") + "bin"
            + System.getProperty("file.separator") + exeName;

    commandArgs.add(cmd);

    // arguments
    // UIMA AE descriptor
    // eclipse likes URL formats starting with file:, but C++ doesn't
    if (this.aeDesc.regionMatches(true, 0, "file:", 0, 5)) {
      this.aeDesc = this.aeDesc.substring(5);
    }
    Pattern mSlashDosDrive = Pattern.compile("/[a-zA-Z]:");
    Matcher matcher = mSlashDosDrive.matcher(this.aeDesc);
    if (matcher.find(0)) {
      // "/c:" doesn't work either
      this.aeDesc = this.aeDesc.substring(1);
    }

    commandArgs.add(aeDesc);
    if (!(new File(aeDesc)).exists()) {
      throw new ResourceInitializationException(new IOException(
              "Invalid location of AE descriptor " + aeDesc));
    }

    // input queue name
    commandArgs.add(queueName);

    // port this server is listening at
    commandArgs.add("-jport");
    commandArgs.add(Integer.toString(port));

    // number of instances of consumers the
    // service should start
    commandArgs.add("-n");
    if (numInstances < 1) {
      numInstances = 1;
    }
    commandArgs.add(Integer.toString(numInstances));

    // logging level setting obtained from the UIMA framework
    // translated to UIMA C++ logging levels.
    commandArgs.add("-l");
    if (uimaLogger.isLoggable(Level.FINE) || uimaLogger.isLoggable(Level.CONFIG)
            || uimaLogger.isLoggable(Level.FINER) || uimaLogger.isLoggable(Level.FINEST)
            || uimaLogger.isLoggable(Level.INFO)) {
      commandArgs.add(Integer.toString(0));
    } else if (uimaLogger.isLoggable(Level.WARNING)) {
      commandArgs.add(Integer.toString(1));
    } else if (uimaLogger.isLoggable(Level.SEVERE)) {
      commandArgs.add(Integer.toString(2));
    } else {
      commandArgs.add(Integer.toString(-1));
    }

    // translate logger level to trace level 0-4.
    // set based Level = CONFIG, INFO, FINE, FINER, FINEST...
    commandArgs.add("-t");
    if (uimaLogger.isLoggable(Level.FINEST)) {
      commandArgs.add(Integer.toString(3));
    } else if (uimaLogger.isLoggable(Level.FINER)) {
      commandArgs.add(Integer.toString(2));
    } else if (uimaLogger.isLoggable(Level.FINE)) {
      commandArgs.add(Integer.toString(1));
    } else if (uimaLogger.isLoggable(Level.CONFIG) || uimaLogger.isLoggable(Level.INFO)) {
      commandArgs.add(Integer.toString(0));
    } else {
      commandArgs.add(Integer.toString(-1));
    }
    // data directory used to resolve location of
    // files used by annotator.
    String uimacppDataPath = (String) envVarMap.get("UIMACPP_DATAPATH");
    if (uimacppDataPath != null && uimacppDataPath.length() != 0) {
      commandArgs.add("-d");
      commandArgs.add(uimacppDataPath);
    }

    if (processCasErrorThreshhold > 0) {
      commandArgs.add("-e");
      commandArgs.add(Integer.toString(processCasErrorThreshhold));
      if (processCasErrorWindow > 0) {
        commandArgs.add("-w");
        commandArgs.add(Integer.toString(processCasErrorWindow));
      }
    }

    if (terminateOnCPCError) {
      commandArgs.add("-a");
      commandArgs.add("true");
    }

    if (initialFsHeapSize > 0) {
      commandArgs.add("-fsheapsz");
      commandArgs.add(Integer.toString(initialFsHeapSize));
    }

  }