Package org.apache.felix.service.command

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


    public Console create(CommandProcessor processor, InputStream in, PrintStream out, PrintStream err, final Terminal terminal,
            String encoding, Runnable closeCallback) {
        ConsoleImpl console = new ConsoleImpl(processor, in, out, err, terminal, encoding, closeCallback);
        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"));
        session.put("LINES", Integer.toString(terminal.getHeight()));
        session.put("COLUMNS", Integer.toString(terminal.getWidth()));
        session.put(".jline.terminal", terminal);
        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());
            }
        });
        addSystemProperties(session);
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 {
                    Class<? extends Action> actionClass = ((AbstractCommand) function).getActionClass();                   
                    Command ann = new ActionMetaDataFactory().getCommand(actionClass);
View Full Code Here

                                   encoding,
                                   callback);
        CommandSession session = console.getSession();
        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

            Console console = createConsole(commandProcessor, 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

                    if (line.isEmpty() || line.charAt(0) == '#') {
                        continue;
                    }
                    final Class<Action> actionClass = (Class<Action>) cl.loadClass(line);
                    Command cmd = actionClass.getAnnotation(Command.class);
                    Function function = new AbstractCommand() {
                        @Override
                        public Action createNewAction() {
                            try {
                                return ((Class<? extends Action>) actionClass).newInstance();
                            } catch (InstantiationException e) {
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

            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

        ConsoleImpl console = new ConsoleImpl(processor, threadIO, in, out, err, terminal, encoding, closeCallback, bundleContext, true);
        CommandSession session = console.getSession();
       
        session.put("USER", ShellUtil.getCurrentUserName());
        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

            }
            // Verify scope if
            // - the command name has no scope
            // - we have a session
            if (!args[index].contains(":") && commandSession != null) {
                Function f1 = unProxy((Function) commandSession.get("*:" + args[index]));
                Function f2 = unProxy(this.function);
                if (f1 != null && f1 != f2) {
                    return -1;
                }
            }
            index++;
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.