Package org.apache.karaf.shell.table

Examples of org.apache.karaf.shell.table.ShellTable


    @Option(name = "-v", aliases = { "--verbose" }, description = "Display JMS properties", required = false, multiValued = false)
    boolean verbose = false;

    public Object doExecute() throws Exception {

        ShellTable table = new ShellTable();
        table.column("Message ID");
        table.column("Content").maxSize(80);
        table.column("Charset");
        table.column("Type");
        table.column("Correlation ID");
        table.column("Delivery Mode");
        table.column("Destination");
        table.column("Expiration");
        table.column("Priority");
        table.column("Redelivered");
        table.column("ReplyTo");
        table.column("Timestamp");
        if (verbose) {
            table.column("Properties");
        }

        List<JmsMessage> messages = getJmsService().browse(connectionFactory, queue, selector, username, password);
        for (JmsMessage message : messages) {
            if (verbose) {
                StringBuilder properties = new StringBuilder();
                for (String property : message.getProperties().keySet()) {
                    properties.append(property).append("=").append(message.getProperties().get(property)).append("\n");
                }
                table.addRow().addContent(
                        message.getMessageId(),
                        message.getContent(),
                        message.getCharset(),
                        message.getType(),
                        message.getCorrelationID(),
                        message.getDeliveryMode(),
                        message.getDestination(),
                        message.getExpiration(),
                        message.getPriority(),
                        message.isRedelivered(),
                        message.getReplyTo(),
                        message.getTimestamp(),
                        properties.toString());
            } else {
                table.addRow().addContent(
                        message.getMessageId(),
                        message.getContent(),
                        message.getCharset(),
                        message.getType(),
                        message.getCorrelationID(),
                        message.getDeliveryMode(),
                        message.getDestination(),
                        message.getExpiration(),
                        message.getPriority(),
                        message.isRedelivered(),
                        message.getReplyTo(),
                        message.getTimestamp());
            }
        }

        table.print(System.out);

        return null;
    }
View Full Code Here


    @Option(name = "-p", aliases = { "--password" }, description = "Password to connect to the JMS broker", required = false, multiValued = false)
    String password = "karaf";

    public Object doExecute() throws Exception {
        ShellTable table = new ShellTable();

        table.column("JMS Topics");

        for (String topic : getJmsService().topics(connectionFactory, username, password)) {
            table.addRow().addContent(topic);
        }

        table.print(System.out);

        return null;
    }
View Full Code Here

    protected void doExecute(FeaturesService featuresService) throws Exception {
        if (reload) {
            reloadAllRepos(featuresService);
        }
       
        ShellTable table = new ShellTable();
        table.column("Repository");
        table.column("URL");
        table.emptyTableText("No repositories available");

        Repository[] repos = featuresService.listRepositories();
       for (Repository repo : repos) {
           table.addRow().addContent(repo.getName(), repo.getURI().toString());
       }
       table.print(System.out, !noFormat);
    }
View Full Code Here

    protected void printMethodList(CommandSession session, PrintStream out, SortedMap<String, String> commands) {
        Terminal term = (Terminal) session.get(".jline.terminal");
        int termWidth = term != null ? term.getWidth() : 80;
        out.println(Ansi.ansi().a(Ansi.Attribute.INTENSITY_BOLD).a("COMMANDS").a(Ansi.Attribute.RESET));
        ShellTable table = new ShellTable().noHeaders().separator(" ").size(termWidth);
        table.column(new Col("Command").maxSize(35));
        table.column(new Col("Description"));
        for (Map.Entry<String,String> entry : commands.entrySet()) {
            String key = NameScoping.getCommandNameWithoutGlobalPrefix(session, entry.getKey());
            table.addRow().addContent(key, entry.getValue());
        }
        table.print(out, true);
    }
View Full Code Here

    @Override
    protected Object doExecute(BackingEngine engine) throws Exception {
        List<UserPrincipal> users = engine.listUsers();

        ShellTable table = new ShellTable();
        table.column("User Name");
        table.column("Role");

        for (UserPrincipal user : users) {
            String userName = user.getName();
            List<RolePrincipal> roles = engine.listRoles(user);

            if (roles != null && roles.size() >= 1) {
                for (RolePrincipal role : roles) {
                    String roleName = role.getName();
                    table.addRow().addContent(userName, roleName);
                }
            } else {
                table.addRow().addContent(userName, "");
            }

        }

        table.print(System.out);

        return null;
    }
View Full Code Here

    protected void doExecute(FeaturesService featuresService) throws Exception {
        if (reload) {
            reloadAllRepos(featuresService);
        }
       
        ShellTable table = new ShellTable();
        table.column("Repository");
        table.column("URL");
        table.emptyTableText("No repositories available");

        Repository[] repos = featuresService.listRepositories();
       for (Repository repo : repos) {
           Row row = table.addRow();
           row.addContent(repo.getName());
            row.addContent(repo.getURI().toString());
       }
       table.print(System.out);
    }
View Full Code Here

    }

    protected Object doExecute() throws Exception {
        List<JaasRealm> realms = getRealms();

        ShellTable table = new ShellTable();
        table.column("Index");
        table.column("Realm Name");
        table.column("Login Module Class Name");

        if (realms != null && realms.size() > 0) {
            int index = 1;
            for (JaasRealm realm : realms) {
                String realmName = realm.getName();
                AppConfigurationEntry[] entries = realm.getEntries();

                if (entries != null && entries.length > 0) {
                    for (int i = 0; i < entries.length; i++) {
                        String moduleClass = (String) entries[i].getOptions().get(ProxyLoginModule.PROPERTY_MODULE);
                        table.addRow().addContent(index++, realmName, moduleClass);
                    }
                }
            }
        }

        table.print(System.out);

        return null;
    }
View Full Code Here

            maxPName = Math.max(maxPName, emptyIfNull(resource.getPresentationName()).length());
            maxSName = Math.max(maxSName, emptyIfNull(resource.getSymbolicName()).length());
            maxVersion = Math.max(maxVersion, emptyIfNull(resource.getVersion()).length());
        }

        ShellTable table = new ShellTable();
        table.column("Name");
        table.column("Symbolic Name");
        table.column("Version");
        table.emptyTableText("No matching bundles");

        for (Resource resource : resources) {
            table.addRow().addContent(emptyIfNull(resource.getPresentationName()),
                    emptyIfNull(resource.getSymbolicName()),
                    emptyIfNull(resource.getVersion()));
        }

        table.print(System.out);

        return null;
    }
View Full Code Here

@Command(scope = "obr", name = "url-list", description = "Displays the repository URLs currently associated with the OBR service.")
public class ListUrlCommand extends ObrCommandSupport {

    protected void doExecute(RepositoryAdmin admin) {

        ShellTable table = new ShellTable();
        table.column("Index");
        table.column("OBR URL");
        table.emptyTableText("No OBR repository URL");

        Repository[] repos = admin.listRepositories();
        if (repos != null) {
            for (int i = 0; i < repos.length; i++) {
                table.addRow().addContent(i, repos[i].getURI());
            }
        }

        table.print(System.out);
    }
View Full Code Here

    boolean javaOpts;

    protected Object doExecute() throws Exception {
        getInstanceService().refreshInstance();
        Instance[] instances = getInstanceService().getInstances();
        ShellTable table = new ShellTable();
        table.column("SSH Port").alignRight();
        table.column("RMI Registry").alignRight();
        table.column("RMI Server").alignRight();
        table.column("State");
        table.column("PID");
        table.column(getRightColumnHeader());
        for (Instance instance : instances) {
            table.addRow().addContent(
                    instance.getSshPort(),
                    instance.getRmiRegistryPort(),
                    instance.getRmiServerPort(),
                    instance.getState(),
                    instance.getPid(),
                    getRightColumnValue(instance));
        }
        table.print(System.out);
        return null;
    }
View Full Code Here

TOP

Related Classes of org.apache.karaf.shell.table.ShellTable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.