Search in sources :

Example 1 with ShellTable

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;
}
Also used : ShellTable(org.apache.karaf.shell.support.table.ShellTable)

Example 2 with ShellTable

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;
}
Also used : ShellTable(org.apache.karaf.shell.support.table.ShellTable)

Example 3 with ShellTable

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;
}
Also used : ShellTable(org.apache.karaf.shell.support.table.ShellTable) DataSourceFactory(org.osgi.service.jdbc.DataSourceFactory) ServiceReference(org.osgi.framework.ServiceReference)

Example 4 with ShellTable

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;
}
Also used : ThreadMXBean(java.lang.management.ThreadMXBean) ThreadInfo(java.lang.management.ThreadInfo) ShellTable(org.apache.karaf.shell.support.table.ShellTable) TreeMap(java.util.TreeMap)

Example 5 with ShellTable

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);
}
Also used : Repository(org.apache.karaf.features.Repository) ShellTable(org.apache.karaf.shell.support.table.ShellTable) Feature(org.apache.karaf.features.Feature)

Aggregations

ShellTable (org.apache.karaf.shell.support.table.ShellTable)47 Row (org.apache.karaf.shell.support.table.Row)10 Col (org.apache.karaf.shell.support.table.Col)7 ArrayList (java.util.ArrayList)4 Bundle (org.osgi.framework.Bundle)4 Map (java.util.Map)3 Repository (org.apache.karaf.features.Repository)3 List (java.util.List)2 TreeMap (java.util.TreeMap)2 Bus (org.apache.cxf.Bus)2 Feature (org.apache.karaf.features.Feature)2 MavenRepositoryURL (org.apache.karaf.maven.core.MavenRepositoryURL)2 PackageVersion (org.apache.karaf.packages.core.PackageVersion)2 Proxy (org.apache.maven.settings.Proxy)2 Attribute (ddf.catalog.data.Attribute)1 Result (ddf.catalog.data.Result)1 SortByImpl (ddf.catalog.filter.impl.SortByImpl)1 QueryRequest (ddf.catalog.operation.QueryRequest)1 SourceResponse (ddf.catalog.operation.SourceResponse)1 QueryImpl (ddf.catalog.operation.impl.QueryImpl)1