public Object execute()

in shell/src/main/java/org/apache/camel/karaf/shell/RestRegistryList.java [45:85]


    public Object execute() throws Exception {
        ShellTable table = new ShellTable();
        table.column("Url");
        table.column("Base Path");
        table.column("Uri Template");
        table.column("Method");
        table.column("State");

        List<CamelContext> camelContexts = getCamelContext(name);
        if (camelContexts.size() != 1) {
            System.err.println("Camel context " + name + " not found");
            return null;
        }

        List<RestRegistry.RestService> services = new ArrayList<>(camelContexts.get(0).getRestRegistry().listAllRestServices());
        Collections.sort(services, new Comparator<RestRegistry.RestService>() {
            @Override
            public int compare(RestRegistry.RestService s1, RestRegistry.RestService s2) {
                return s1.getUrl().compareTo(s2.getUrl());
            }
        });
        for (RestRegistry.RestService service : services) {
            String uri = service.getUrl();
            if (decode) {
                // decode uri so it's more human readable
                uri = URLDecoder.decode(uri, "UTF-8");
            }
            // sanitize and mask uri so we don't see passwords
            uri = URISupport.sanitizeUri(uri);
            table.addRow().addContent(uri,
                    service.getBasePath(),
                    service.getUriTemplate(),
                    service.getMethod(),
                    service.getState());

        }

        table.print(System.out);

        return null;
    }