Search in sources :

Example 6 with ShellTable

use of org.apache.karaf.shell.support.table.ShellTable in project karaf by apache.

the class ServletListCommand method execute.

@Override
public Object execute() throws Exception {
    ShellTable table = new ShellTable();
    table.column(new Col("ID"));
    table.column(new Col("Servlet"));
    table.column(new Col("Servlet-Name"));
    table.column(new Col("State"));
    table.column(new Col("Alias"));
    table.column(new Col("Url"));
    for (ServletInfo info : servletService.getServlets()) {
        table.addRow().addContent(info.getBundleId(), info.getClassName(), info.getName(), info.getStateString(), info.getAlias(), Arrays.toString(info.getUrls()));
    }
    table.print(System.out, !noFormat);
    return null;
}
Also used : ServletInfo(org.apache.karaf.http.core.ServletInfo) Col(org.apache.karaf.shell.support.table.Col) ShellTable(org.apache.karaf.shell.support.table.ShellTable)

Example 7 with ShellTable

use of org.apache.karaf.shell.support.table.ShellTable in project karaf by apache.

the class ListCommand method doExecute.

protected Object doExecute() throws Exception {
    Instance[] instances = getInstanceService().getInstances();
    ShellTable table = new ShellTable();
    table.column("SSH Port").alignRight();
    table.column("SSH Host").alignRight();
    table.column("RMI Registry").alignRight();
    table.column("RMI Registry Host").alignRight();
    table.column("RMI Server").alignRight();
    table.column("RMI Server Host").alignRight();
    table.column("State");
    table.column("PID");
    table.column(getRightColumnHeader());
    for (Instance instance : instances) {
        table.addRow().addContent(instance.getSshPort(), instance.getSshHost(), instance.getRmiRegistryPort(), instance.getRmiRegistryHost(), instance.getRmiServerPort(), instance.getRmiServerHost(), instance.getState(), instance.getPid(), getRightColumnValue(instance));
    }
    table.print(System.out, !noFormat);
    return null;
}
Also used : ShellTable(org.apache.karaf.shell.support.table.ShellTable) Instance(org.apache.karaf.instance.core.Instance)

Example 8 with ShellTable

use of org.apache.karaf.shell.support.table.ShellTable in project karaf by apache.

the class ProfileList method execute.

@Override
public Object execute() throws Exception {
    List<String> ids = new ArrayList<>(profileService.getProfiles());
    Collections.sort(ids);
    ShellTable table = new ShellTable();
    table.column("id");
    table.column("parents");
    for (String id : ids) {
        Profile profile = profileService.getProfile(id);
        if (profile != null && (hidden || !profile.isHidden())) {
            String parents = join(" ", profile.getParentIds());
            table.addRow().addContent(id, parents);
        }
    }
    table.print(System.out);
    return null;
}
Also used : ShellTable(org.apache.karaf.shell.support.table.ShellTable) ArrayList(java.util.ArrayList) Profile(org.apache.karaf.profile.Profile)

Example 9 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");
    table.column("Registration bundle");
    Set<DataSourceFactoryInfo> factories = new TreeSet<>(comparator);
    Collection<ServiceReference<DataSourceFactory>> refs = context.getServiceReferences(DataSourceFactory.class, null);
    for (ServiceReference<DataSourceFactory> ref : refs) {
        DataSourceFactoryInfo info = new DataSourceFactoryInfo();
        info.driverName = (String) ref.getProperty(DataSourceFactory.OSGI_JDBC_DRIVER_NAME);
        info.driverClass = (String) ref.getProperty(DataSourceFactory.OSGI_JDBC_DRIVER_CLASS);
        info.driverVersion = (String) ref.getProperty(DataSourceFactory.OSGI_JDBC_DRIVER_VERSION);
        if (ref.getBundle() != null && ref.getBundle().getSymbolicName() != null) {
            info.bundle = String.format("%s [%s]", ref.getBundle().getSymbolicName(), ref.getBundle().getBundleId());
        } else {
            info.bundle = "";
        }
        factories.add(info);
    }
    for (DataSourceFactoryInfo info : factories) {
        table.addRow().addContent(info.driverName, info.driverClass, info.driverVersion, info.bundle);
    }
    table.print(System.out);
    return null;
}
Also used : ShellTable(org.apache.karaf.shell.support.table.ShellTable) DataSourceFactory(org.osgi.service.jdbc.DataSourceFactory) TreeSet(java.util.TreeSet) ServiceReference(org.osgi.framework.ServiceReference)

Example 10 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)59 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 Feature (org.apache.karaf.features.Feature)3 Repository (org.apache.karaf.features.Repository)3 List (java.util.List)2 TreeMap (java.util.TreeMap)2 Bus (org.apache.cxf.Bus)2 Booking (org.apache.karaf.examples.jdbc.api.Booking)2 Booking (org.apache.karaf.examples.jpa.Booking)2 MavenRepositoryURL (org.apache.karaf.maven.core.MavenRepositoryURL)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