use of org.apache.karaf.shell.support.table.ShellTable in project karaf by apache.
the class ListKarCommand method execute.
@Override
public Object execute() throws Exception {
ShellTable table = new ShellTable();
table.column("KAR Name");
for (String karName : karService.list()) {
table.addRow().addContent(karName);
}
table.print(System.out, !noFormat);
return null;
}
use of org.apache.karaf.shell.support.table.ShellTable in project karaf by apache.
the class ContextsCommand method execute.
@Override
public Object execute() throws Exception {
ShellTable table = new ShellTable();
table.column("JNDI Sub-Context");
List<String> contexts;
if (context == null) {
contexts = jndiService.contexts();
} else {
contexts = jndiService.contexts(context);
}
for (String c : contexts) {
table.addRow().addContent(c);
}
table.print(System.out);
return null;
}
use of org.apache.karaf.shell.support.table.ShellTable in project karaf by apache.
the class DSFactoriesCommand method execute.
@Override
public Object execute() throws Exception {
ShellTable table = new ShellTable();
table.column("Name");
table.column("Class");
table.column("Version");
Collection<ServiceReference<DataSourceFactory>> refs = context.getServiceReferences(DataSourceFactory.class, null);
for (ServiceReference<DataSourceFactory> ref : refs) {
String driverName = (String) ref.getProperty(DataSourceFactory.OSGI_JDBC_DRIVER_NAME);
String driverClass = (String) ref.getProperty(DataSourceFactory.OSGI_JDBC_DRIVER_CLASS);
String driverVersion = (String) ref.getProperty(DataSourceFactory.OSGI_JDBC_DRIVER_VERSION);
table.addRow().addContent(driverName, driverClass, driverVersion);
}
table.print(System.out);
return null;
}
use of org.apache.karaf.shell.support.table.ShellTable in project karaf by apache.
the class ThreadsAction method execute.
@Override
public Object execute() throws Exception {
Map<Long, ThreadInfo> threadInfos = new TreeMap<>();
ThreadMXBean threadsBean = ManagementFactory.getThreadMXBean();
ThreadInfo[] infos;
if (threadsBean.isObjectMonitorUsageSupported() && threadsBean.isSynchronizerUsageSupported()) {
infos = threadsBean.dumpAllThreads(true, true);
} else {
infos = threadsBean.getThreadInfo(threadsBean.getAllThreadIds(), Integer.MAX_VALUE);
}
for (ThreadInfo info : infos) {
threadInfos.put(info.getThreadId(), info);
}
if (id != null) {
ThreadInfo ti = threadInfos.get(id);
if (ti != null) {
System.out.println("Thread " + ti.getThreadId() + " " + ti.getThreadName() + " " + ti.getThreadState());
System.out.println("Stacktrace:");
StackTraceElement[] st = ti.getStackTrace();
for (StackTraceElement ste : st) {
System.out.println(ste.getClassName() + "." + ste.getMethodName() + " line: " + ste.getLineNumber());
}
}
} else if (list) {
ShellTable table = new ShellTable();
table.column("Id");
table.column("Name");
table.column("State");
table.column("CPU time");
table.column("Usr time");
for (ThreadInfo thread : threadInfos.values()) {
long id = thread.getThreadId();
table.addRow().addContent(id, thread.getThreadName(), thread.getThreadState(), threadsBean.getThreadCpuTime(id) / 1000000, threadsBean.getThreadUserTime(id) / 1000000);
}
table.print(System.out, !noFormat);
} else {
ThreadGroup group = Thread.currentThread().getThreadGroup();
while (group.getParent() != null) {
group = group.getParent();
}
ThreadGroupData data = new ThreadGroupData(group, threadInfos);
data.print();
}
return null;
}
use of org.apache.karaf.shell.support.table.ShellTable in project karaf by apache.
the class ListFeatureVersionsCommand method doExecute.
protected void doExecute(FeaturesService admin) throws Exception {
ShellTable table = new ShellTable();
table.column("Version");
table.column("Repository");
table.column("Repository URL");
table.emptyTableText("No versions available for features '" + feature + "'");
for (Repository r : Arrays.asList(admin.listRepositories())) {
for (Feature f : r.getFeatures()) {
if (f.getName().equals(feature)) {
table.addRow().addContent(f.getVersion(), r.getName(), r.getURI());
}
}
}
table.print(System.out, !noFormat);
}
Aggregations