use of org.apache.karaf.shell.support.table.ShellTable in project karaf by apache.
the class ListCommand method execute.
@Override
public Object execute() throws Exception {
ShellTable table = new ShellTable();
table.column("Name");
table.column("Service Id");
table.column("Product");
table.column("Version");
table.column("URL");
table.column("Status");
boolean duplication = false;
Map<String, Long> nameToId = new HashMap<>();
List<Long> datasources = this.getJdbcService().datasourceServiceIds();
Collections.sort(datasources);
for (Long id : datasources) {
try {
Map<String, String> info = this.getJdbcService().info(Long.toString(id));
table.addRow().addContent(info.get("name"), info.get("service.id"), info.get("db.product"), info.get("db.version"), info.get("url"), "OK");
if (nameToId.put(info.get("name"), id) != null) {
duplication = true;
}
} catch (Exception e) {
table.addRow().addContent(id, "", "", "", "", "Error " + e.getMessage());
}
}
table.print(System.out);
if (duplication) {
System.out.println("\nThere are multiple data source services registered with the same name. Please review your configuration.");
}
return null;
}
use of org.apache.karaf.shell.support.table.ShellTable in project karaf by apache.
the class ConnectionFactoriesCommand method execute.
@Override
public Object execute() throws Exception {
ShellTable table = new ShellTable();
table.column("JMS Connection Factory");
List<String> connectionFactories = getJmsService().connectionFactories();
for (String connectionFactory : connectionFactories) {
table.addRow().addContent(connectionFactory);
}
table.print(System.out);
return null;
}
use of org.apache.karaf.shell.support.table.ShellTable in project karaf by apache.
the class QueryCommand method execute.
@Override
public Object execute() throws Exception {
ShellTable table = new ShellTable();
Map<String, List<String>> map = this.getJdbcService().query(datasource, query);
int rowCount = 0;
for (String column : map.keySet()) {
table.column(column);
rowCount = map.get(column).size();
}
for (int i = 0; i < rowCount; i++) {
Row row = table.addRow();
for (String column : map.keySet()) {
row.addContent(map.get(column).get(i));
}
}
table.print(System.out);
return null;
}
use of org.apache.karaf.shell.support.table.ShellTable in project karaf by apache.
the class CountCommand method execute.
@Override
public Object execute() throws Exception {
ShellTable table = new ShellTable();
table.column("Messages Count");
table.addRow().addContent(getJmsService().count(connectionFactory, queue, username, password));
table.print(System.out);
return null;
}
use of org.apache.karaf.shell.support.table.ShellTable in project karaf by apache.
the class InfoCommand method execute.
@Override
public Object execute() throws Exception {
ShellTable table = new ShellTable();
table.column("Property");
table.column("Value");
Map<String, String> info = getJmsService().info(connectionFactory, username, password);
for (String key : info.keySet()) {
table.addRow().addContent(key, info.get(key));
}
table.print(System.out);
return null;
}
Aggregations