Package org.apache.felix.service.command

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


                if (encoding != null && encoding.indexOf('.') > 0) {
                    encoding = encoding.substring(encoding.indexOf('.') + 1);
                }
                Console console = consoleFactory.create(commandProcessor, threadIO, in,
                        lfToCrLfPrintStream(out), lfToCrLfPrintStream(err), terminal, encoding, destroyCallback);
                final CommandSession session = console.getSession();
                for (Map.Entry<String, String> e : env.getEnv().entrySet()) {
                    session.put(e.getKey(), e.getValue());
                }
                consoleFactory.startConsoleAs(console, subject, "ssh");
            } catch (Exception e) {
                throw (IOException) new IOException("Unable to start shell").initCause(e);
            }
View Full Code Here


        ArgumentList list = delimit(buffer, cursor);
        int argpos = list.getArgumentPosition();
        int argIndex = list.getCursorArgumentIndex();

        //Store the argument list so that it can be used by completers.
        CommandSession commandSession = CommandSessionHolder.getSession();
        if(commandSession != null) {
            commandSession.put(ARGUMENTS_LIST,list);
        }

        Completer comp = null;
        String[] args = list.getArguments();
        int index = 0;
View Full Code Here

    @Override
    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);
        addSystemProperties(session);
        session.put("pid", getPid());
        return console;
    }
View Full Code Here

        final String userName = getUserName(subject);
        new Thread(console, "Karaf Console " + consoleType + " user " + userName) {
            @Override
            public void run() {
                if (subject != null) {
                    CommandSession session = console.getSession();
                    session.put("USER", userName);
                    JaasHelper.doAs(subject, new PrivilegedAction<Object>() {
                        public Object run() {
                            doRun();
                            return null;
                        }
View Full Code Here

        }
        DelegateSession is = (DelegateSession) session;

        // make it active
        SecuredCommandProcessorImpl secCP = new SecuredCommandProcessorImpl(bundleContext);
        CommandSession s = secCP.createSession(consoleInput, out, err);

        // before the session is activated attributes may have been set on it. Pass these on to the real session now
        is.setDelegate(s);
        return secCP;
    }
View Full Code Here

        assertEquals(0, parser.c3);
    }

    @Test
    public void testCompleteOptions() throws Exception {
        CommandSession session = new DummyCommandSession();
        Completer comp = new ArgumentCompleter(session, new MyFunction(), "my:action");
        assertEquals(Arrays.asList("--check", "--foo", "--help", "--integer", "--string", "-c", "-f","-i","-s"), complete(comp, "action -"));
        assertEquals(Arrays.asList(), complete(comp, "action --foo "));
        assertEquals(Arrays.asList("action "), complete(comp, "acti"));
        assertEquals(Arrays.asList("my:action "), complete(comp, "my:ac"));
View Full Code Here

public class BooleanCompleterTest extends CompleterTestSupport {

    @Test
    public void testCompleteArgumnets() throws Exception {
        CommandSession session = new DummyCommandSession();
        Completer comp = new ArgumentCompleter(session, new SimpleCommand(MyAction.class), "my:action");

        // arg 0
        assertEquals(Arrays.asList("true "), complete(comp, "action t"));
        assertEquals(Arrays.asList("false "), complete(comp, "action f"));
View Full Code Here

public class FileCompleterTest extends CompleterTestSupport {

    @Test
    public void testCompleteArgumnets() throws Exception {
        CommandSession session = new DummyCommandSession();
        Completer comp = new ArgumentCompleter(session, new SimpleCommand(MyAction.class), "my:action");

        // arg 0
        assertEquals(Arrays.asList("src"+File.separator), complete(comp, "action s"));
        assertEquals(Arrays.asList("main"+File.separator), complete(comp, "action src/m"));
View Full Code Here

        String response;
        final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        final PrintStream printStream = new PrintStream(byteArrayOutputStream);
        final CommandProcessor commandProcessor = getOsgiService(CommandProcessor.class);
        final CommandSession commandSession = commandProcessor.createSession(System.in, printStream, System.err);

        final Callable<String> commandCallable = new Callable<String>() {
            @Override
            public String call() throws Exception {
                try {
                    if (!silent) {
                        System.err.println(command);
                    }
                    commandSession.execute(command);
                } catch (Exception e) {
                    throw new RuntimeException(e.getMessage(), e);
                }
                printStream.flush();
                return byteArrayOutputStream.toString();
View Full Code Here

public class CompleterValuesTest extends CompleterTestSupport {

    @Test
    public void testCompleteArgumnets() throws Exception {
        CommandSession session = new DummyCommandSession();
        Completer comp = new ArgumentCompleter(session, new SimpleCommand(MyAction.class), "my:action");

        // arg 0
        assertEquals(Arrays.asList("a1", "a2", "a3"), complete(comp, "action a"));
        assertEquals(Arrays.asList("b4", "b5"), complete(comp, "action b"));
View Full Code Here

TOP

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

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.