@Override public String preprocess(Session session, CommandLine commandLine) { Object service = session.getRegistry().getService(clazz); if (service instanceof Parser) { return ((Parser) service).preprocess(session, commandLine); } throw new IllegalStateException("Could not find specified parser"); } }
@Override public String preprocess(Session session, CommandLine commandLine) { Object service = session.getRegistry().getService(clazz); if (service instanceof Parser) { return ((Parser) service).preprocess(session, commandLine); } throw new IllegalStateException("Could not find specified parser"); } }
@Override public CommandLine parse(Session session, String command, int cursor) { Object service = session.getRegistry().getService(clazz); if (service instanceof Parser) { return ((Parser) service).parse(session, command, cursor); } throw new IllegalStateException("Could not find specified parser"); }
@Override public CommandLine parse(Session session, String command, int cursor) { Object service = session.getRegistry().getService(clazz); if (service instanceof Parser) { return ((Parser) service).parse(session, command, cursor); } throw new IllegalStateException("Could not find specified parser"); }
return parent.getService(clazz);
@Override public void completeCandidates(Session session, CommandLine commandLine, List<Candidate> candidates) { Object service = session.getRegistry().getService(clazz); if (service instanceof Completer) { ((Completer) service).completeCandidates(session, commandLine, candidates); } } }
@Override public void completeCandidates(Session session, CommandLine commandLine, List<Candidate> candidates) { Object service = session.getRegistry().getService(clazz); if (service instanceof Completer) { ((Completer) service).completeCandidates(session, commandLine, candidates); } } }
@Override public int complete(Session session, CommandLine commandLine, List<String> candidates) { Object service = session.getRegistry().getService(clazz); if (service instanceof Completer) { return ((Completer) service).complete(session, commandLine, candidates); } return -1; }
@Override public int complete(Session session, CommandLine commandLine, List<String> candidates) { Object service = session.getRegistry().getService(clazz); if (service instanceof Completer) { return ((Completer) service).complete(session, commandLine, candidates); } return -1; }
@Reference(cardinality = ReferenceCardinality.OPTIONAL, policy = ReferencePolicy.DYNAMIC) public void setSessionFactory(SessionFactory sessionFactory) { this.sessionFactory = sessionFactory; manager = sessionFactory.getRegistry().getService(Manager.class); manager.register(CommandWrapper.class); registerCommands(); }
@Init public void init() { sessionFactory.getRegistry().getService(Manager.class).register(SshAction.class); }
@Destroy public void destroy() { sessionFactory.getRegistry().getService(Manager.class).register(SshAction.class); }
@Init public void init() { sessionFactory.getRegistry().getService(Manager.class).register(SshAction.class); }
@Destroy public void destroy() { sessionFactory.getRegistry().getService(Manager.class).register(SshAction.class); }
@Override protected void doStop() { if (sessionFactory != null) { sessionFactory.getRegistry().getService(Manager.class).unregister(SshAction.class); sessionFactory = null; } if (server != null) { try { server.stop(true); } catch (IOException e) { LOGGER.warn("Exception caught while stopping SSH server", e); } server = null; } super.doStop(); }
@Override protected void doStop() { if (sessionFactory != null) { sessionFactory.getRegistry().getService(Manager.class).unregister(SshAction.class); sessionFactory = null; } if (server != null) { try { server.stop(true); } catch (IOException e) { LOGGER.warn("Exception caught while stopping SSH server", e); } server = null; } super.doStop(); }
@Override public int complete(Session session, CommandLine commandLine, List<String> candidates) { String arg = commandLine.getCursorArgument(); int pos = commandLine.getArgumentPosition(); CommandLine cmdLine = new DefaultParser().parse(session, arg, pos); Completer completer = session.getRegistry().getService(CommandsCompleter.class); List<String> cands = new ArrayList<>(); int res = completer.complete(session, cmdLine, cands); for (String cand : cands) { candidates.add(arg.substring(0, cmdLine.getBufferPosition() - cmdLine.getArgumentPosition()) + cand); } if (res >= 0) { res += commandLine.getBufferPosition() - commandLine.getArgumentPosition(); } return res; }
@Override public int complete(Session session, CommandLine commandLine, List<String> candidates) { String arg = commandLine.getCursorArgument(); int pos = commandLine.getArgumentPosition(); CommandLine cmdLine = new DefaultParser().parse(session, arg, pos); Completer completer = session.getRegistry().getService(CommandsCompleter.class); List<String> cands = new ArrayList<>(); int res = completer.complete(session, cmdLine, cands); for (String cand : cands) { candidates.add(arg.substring(0, cmdLine.getBufferPosition() - cmdLine.getArgumentPosition()) + cand); } if (res >= 0) { res += commandLine.getBufferPosition() - commandLine.getArgumentPosition(); } return res; }
@Override protected void doStart() throws Exception { SessionFactory sf = getTrackedService(SessionFactory.class); if (sf == null) { return; } RegexCommandLoggingFilter filter = new RegexCommandLoggingFilter(); filter.setPattern("ssh (.*?)-P +([^ ]+)"); filter.setGroup(2); register(CommandLoggingFilter.class, filter); filter = new RegexCommandLoggingFilter(); filter.setPattern("ssh (.*?)--password +([^ ]+)"); filter.setGroup(2); register(CommandLoggingFilter.class, filter); sessionFactory = sf; sessionFactory.getRegistry().getService(Manager.class).register(SshAction.class); if (Boolean.parseBoolean(bundleContext.getProperty("karaf.startRemoteShell"))) { createAndRunSshServer(); } }
@Override protected void doStart() throws Exception { SessionFactory sf = getTrackedService(SessionFactory.class); if (sf == null) { return; } RegexCommandLoggingFilter filter = new RegexCommandLoggingFilter(); filter.setPattern("ssh (.*?)-P +([^ ]+)"); filter.setGroup(2); register(CommandLoggingFilter.class, filter); filter = new RegexCommandLoggingFilter(); filter.setPattern("ssh (.*?)--password +([^ ]+)"); filter.setGroup(2); register(CommandLoggingFilter.class, filter); sessionFactory = sf; sessionFactory.getRegistry().getService(Manager.class).register(SshAction.class); if (Boolean.parseBoolean(bundleContext.getProperty("karaf.startRemoteShell"))) { createAndRunSshServer(); } }