示例#1
0
  @Override
  public Object execute(CamelController camelController, PrintStream out, PrintStream err)
      throws Exception {
    final List<CamelContext> camelContexts = camelController.getCamelContexts();

    final Map<String, Integer> columnWidths = computeColumnWidths(camelContexts);
    final String headerFormat = buildFormatString(columnWidths, true);
    final String rowFormat = buildFormatString(columnWidths, false);

    if (camelContexts.size() > 0) {
      out.println(
          String.format(
              headerFormat, CONTEXT_COLUMN_LABEL, STATUS_COLUMN_LABEL, UPTIME_COLUMN_LABEL));
      out.println(String.format(headerFormat, "-------", "------", "------"));
      for (final CamelContext camelContext : camelContexts) {
        out.println(
            String.format(
                rowFormat,
                camelContext.getName(),
                camelContext.getStatus(),
                camelContext.getUptime()));
      }
    }

    return null;
  }
示例#2
0
  protected Object doExecute() throws Exception {
    final List<CamelContext> camelContexts = camelController.getCamelContexts();

    final Map<String, Integer> columnWidths = computeColumnWidths(camelContexts);
    final String headerFormat = buildFormatString(columnWidths, true);
    final String rowFormat = buildFormatString(columnWidths, false);
    final PrintStream out = System.out;

    if (camelContexts.size() > 0) {
      out.println(
          String.format(headerFormat, NAME_COLUMN_LABEL, STATUS_COLUMN_LABEL, UPTIME_COLUMN_LABEL));
      for (final CamelContext camelContext : camelContexts) {
        out.println(
            String.format(
                rowFormat,
                camelContext.getName(),
                camelContext.getStatus(),
                camelContext.getUptime()));
      }
    }

    return null;
  }
示例#3
0
  @Override
  public Object execute(CamelController camelController, PrintStream out, PrintStream err)
      throws Exception {
    if (camelController instanceof LocalCamelController) {
      return executeLocal((LocalCamelController) camelController, out, err);
    } else {
      boolean found = false;
      List<Map<String, String>> contexts = camelController.getCamelContexts();
      for (Map<String, String> entry : contexts) {
        String name = entry.get("name");
        if (context.equals(name)) {
          found = true;
          break;
        }
      }

      if (!found) {
        err.println("Camel context " + context + " not found.");
        return null;
      } else {
        return performContextCommand(camelController, context, out, err);
      }
    }
  }