コード例 #1
0
  public synchronized void init(String reqName, ServletConfig config, Properties prop)
      throws ServletException, IOException {
    super.init(reqName, config, prop);

    if (!mIsInitialized) {
      mAdminPassword = prop.getProperty("adminPassword", null);
      mIsInitialized = true;
    }
  }
コード例 #2
0
ファイル: ResponderTask.java プロジェクト: rophy/rundeck
  private void runResponder() {
    int step = 0;
    try {
      // look for input pattern
      if (null != responder.getInputSuccessPattern()
          || null != responder.getInputFailurePattern()) {
        logger.debug(
            "Awaiting input: "
                + responder.getInputSuccessPattern()
                + ";"
                + responder.getInputFailurePattern());
        boolean detected;
        try {
          detected =
              detect(
                  responder.getInputSuccessPattern(),
                  responder.getInputFailurePattern(),
                  responder.getInputMaxTimeout(),
                  responder.getInputMaxLines(),
                  reader,
                  partialLineBuffer);
          logger.debug("Success detected? " + detected);
          if (Thread.currentThread().isInterrupted()) {
            logger.debug("interrupted");
            return;
          }
          if (!detected) {
            fail(step, "Expected input was not seen");
            return;
          }
        } catch (ThreshholdException e) {
          if (responder.isFailOnInputLinesThreshold() && e.getType() == ThresholdType.lines) {
            logger.debug("Threshold met " + reason(e));
            fail(step, reason(e));
            return;
          } else if (responder.isFailOnInputTimeoutThreshold()
              && e.getType() == ThresholdType.milliseconds) {
            logger.debug("Threshold met " + reason(e));
            fail(step, reason(e));
            return;
          } else if (responder.isSuccessOnInputThreshold()) {
            success = true;
            return;
          }
        }
      }
      step++;

      byte[] bytes = responder.getInputBytes();
      if (null != bytes) {
        logger.debug("Writing to output");
        // write responseString
        outputStream.write(bytes, 0, bytes.length);
        outputStream.flush();
        logger.debug("Wrote to output");
      }
      step++;

      if (null != responder.getResponseSuccessPattern()
          || null != responder.getResponseFailurePattern()) {
        // detect success/failure response
        boolean succeeded = false;
        try {
          logger.debug(
              "Awaiting response: "
                  + responder.getResponseSuccessPattern()
                  + ", "
                  + responder.getResponseFailurePattern());
          succeeded =
              detect(
                  responder.getResponseSuccessPattern(),
                  responder.getResponseFailurePattern(),
                  responder.getResponseMaxTimeout(),
                  responder.getResponseMaxLines(),
                  reader,
                  partialLineBuffer);
          if (Thread.currentThread().isInterrupted()) {
            logger.debug("interrupted");
            return;
          }
          success = succeeded;
          if (!succeeded) {
            fail(step, "Did not see the correct response");
          }
          logger.debug("Success detected? " + succeeded);
          return;
        } catch (ThreshholdException e) {
          if (responder.isFailOnResponseThreshold()) {
            logger.debug("Threshold met " + reason(e));
            fail(step, reason(e));
            return;
          }
        }
      }
      success = true;
    } catch (IOException e) {
      logger.debug("IOException " + e.getMessage(), e);
      fail(step, e.getMessage());
      e.printStackTrace();
    }
  }