@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; }
@Override public Object execute(CamelController camelController, PrintStream out, PrintStream err) throws Exception { List<Map<String, String>> dataFormats = camelController.listDataFormatsCatalog(label); if (dataFormats == null || dataFormats.isEmpty()) { return null; } final Map<String, Integer> columnWidths = computeColumnWidths(dataFormats); final String headerFormat = buildFormatString(columnWidths, true); final String rowFormat = buildFormatString(columnWidths, false); if (verbose) { out.println( String.format( headerFormat, TITLE_COLUMN_LABEL, NAME_COLUMN_LABEL, LABEL_COLUMN_LABEL, MAVEN_COLUMN_LABEL)); out.println(String.format(headerFormat, "-----", "----", "-----", "----------------")); } else { out.println(String.format(headerFormat, TITLE_COLUMN_LABEL, DESCRIPTION_COLUMN_LABEL)); out.println(String.format(headerFormat, "-----", "-----------")); } for (final Map<String, String> dataFormat : dataFormats) { if (verbose) { String title = safeNull(dataFormat.get("title")); String name = safeNull(dataFormat.get("name")); String label = safeNull(dataFormat.get("label")); String maven = ""; if (dataFormat.containsKey("groupId") && dataFormat.containsKey("artifactId") && dataFormat.containsKey("version")) { maven = dataFormat.get("groupId") + "/" + dataFormat.get("artifactId") + "/" + dataFormat.get("version"); } out.println(String.format(rowFormat, title, name, label, maven)); } else { String title = safeNull(dataFormat.get("title")); String description = safeNull(dataFormat.get("description")); out.println(String.format(rowFormat, title, description)); } } return null; }
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; }
@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); } } }