Package org.apache.felix.service.command

Examples of org.apache.felix.service.command.Function


    public Console create(CommandProcessor processor, ThreadIO threadIO, InputStream in, PrintStream out, PrintStream err, final Terminal terminal,
            String encoding, Runnable closeCallback) {
        ConsoleImpl console = new ConsoleImpl(processor, threadIO, in, out, err, terminal, encoding, closeCallback, bundleContext, true);
        CommandSession session = console.getSession();
        session.put("APPLICATION", System.getProperty("karaf.name", "root"));
        session.put("#LINES", new Function() {
            public Object execute(CommandSession session, List<Object> arguments) throws Exception {
                return Integer.toString(terminal.getHeight());
            }
        });
        session.put("#COLUMNS", new Function() {
            public Object execute(CommandSession session, List<Object> arguments) throws Exception {
                return Integer.toString(terminal.getWidth());
            }
        });
        session.put(".jline.terminal", terminal);
View Full Code Here


            Map<String, Completer> local = new HashMap<String, Completer>();

            // add argument completers for each command
            for (String command : names) {
                String rawCommand = stripScope(command);
                Function function = (Function) session.get(command);
                function = unProxy(function);
                if (function instanceof CommandWithAction) {
                    try {
                        global.put(command, new ArgumentCompleter(session, (CommandWithAction) function, command));
                        local.put(command, new ArgumentCompleter(session, (CommandWithAction) function, rawCommand));
View Full Code Here

                List<Object> commands = new ArrayList<Object>();

                if (scope != null && function != null) {
                    if (function.getClass().isArray()) {
                        for (Object f : ((Object[]) function)) {
                            Function target = new CommandProxy(context, reference,
                                    f.toString());
                            addCommand(scope.toString(), target, f.toString());
                            commands.add(target);
                        }
                    } else {
                        Function target = new CommandProxy(context, reference,
                                function.toString());
                        addCommand(scope.toString(), target, function.toString());
                        commands.add(target);
                    }
                    return commands;
View Full Code Here

                    continue;
                }
            }

            String description = null;
            Function function = (Function) session.get(name);
            function = unProxy(function);
            if (function instanceof AbstractCommand) {
                try {
                    Class<? extends Action> actionClass = ((AbstractCommand) function).getActionClass();                   
                    Command ann = new ActionMetaDataFactory().getCommand(actionClass);
View Full Code Here

    public Console create(CommandProcessor processor, ThreadIO threadIO, InputStream in, PrintStream out, PrintStream err, final Terminal terminal,
            String encoding, Runnable closeCallback) {
        ConsoleImpl console = new ConsoleImpl(processor, threadIO, in, out, err, terminal, encoding, closeCallback, bundleContext);
        CommandSession session = console.getSession();
        session.put("APPLICATION", System.getProperty("karaf.name", "root"));
        session.put("#LINES", new Function() {
            public Object execute(CommandSession session, List<Object> arguments) throws Exception {
                return Integer.toString(terminal.getHeight());
            }
        });
        session.put("#COLUMNS", new Function() {
            public Object execute(CommandSession session, List<Object> arguments) throws Exception {
                return Integer.toString(terminal.getWidth());
            }
        });
        session.put(".jline.terminal", terminal);
View Full Code Here

                        final CommandSession session = console.getSession();
                        session.put("APPLICATION", System.getProperty("karaf.name", "root"));
                        for (Map.Entry<String,String> e : env.getEnv().entrySet()) {
                            session.put(e.getKey(), e.getValue());
                        }
                        session.put("#LINES", new Function() {
                            public Object execute(CommandSession session, List<Object> arguments) throws Exception {
                                return Integer.toString(terminal.getHeight());
                            }
                        });
                        session.put("#COLUMNS", new Function() {
                            public Object execute(CommandSession session, List<Object> arguments) throws Exception {
                                return Integer.toString(terminal.getWidth());
                            }
                        });
                        session.put(".jline.terminal", terminal);
View Full Code Here

            String key = o.toString();
            session.put(key, System.getProperty(key));
        }
        session.put("USER", user);
        session.put("APPLICATION", System.getProperty("karaf.name", "root"));
        session.put("#LINES", new Function() {
            public Object execute(CommandSession session, List<Object> arguments) throws Exception {
                return Integer.toString(terminal.getHeight());
            }
        });
        session.put("#COLUMNS", new Function() {
            public Object execute(CommandSession session, List<Object> arguments) throws Exception {
                return Integer.toString(terminal.getWidth());
            }
        });
        if (ctype != null) {
View Full Code Here

            List<Completer> completers = new ArrayList<Completer>();
            completers.add(new StringsCompleter(aliases));

            // add argument completers for each command
            for (String command : names) {
                Function function = (Function) session.get(command);
                function = unProxy(function);
                if (function instanceof AbstractCommand) {
                    try {
                        completers.add(new ArgumentCompleter(session, (AbstractCommand) function, command));
                    } catch (Throwable t) {
View Full Code Here

        for (String name : names) {
            if (command != null && !name.startsWith(command)) {
                continue;
            }
            String description = null;
            Function function = (Function) session.get(name);
            function = unProxy(function);
            if (function instanceof AbstractCommand) {
                try {
                    Method mth = AbstractCommand.class.getDeclaredMethod("createNewAction");
                    mth.setAccessible(true);
View Full Code Here

            Console console = createConsole(commandProcessor, threadIO, in, out, err, terminal);
            CommandSession session = console.getSession();
            session.put("USER", user);
            session.put("APPLICATION", application);
            session.put(NameScoping.MULTI_SCOPE_MODE_KEY, Boolean.toString(isMultiScopeMode()));
            session.put("#LINES", new Function() {
                public Object execute(CommandSession session, List<Object> arguments) throws Exception {
                    return Integer.toString(terminal.getHeight());
                }
            });
            session.put("#COLUMNS", new Function() {
                public Object execute(CommandSession session, List<Object> arguments) throws Exception {
                    return Integer.toString(terminal.getWidth());
                }
            });
            session.put(".jline.terminal", terminal);
View Full Code Here

TOP

Related Classes of org.apache.felix.service.command.Function

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.