static void install(final Env env, final Config conf) { String path = conf.getString("crash.httpshell.path"); Router router = env.router(); router.get(path + "/{cmd:.*}", router.promise("direct", (req, deferred) -> { MediaType type = req.accepts(MediaType.json) .map(it -> MediaType.json) .orElse(MediaType.html); PluginContext ctx = req.require(PluginContext.class); ShellFactory shellFactory = ctx.getPlugin(ShellFactory.class); Shell shell = shellFactory.create(null); String cmd = req.param("cmd").value().replaceAll("/", " "); ShellProcess process = shell.createProcess(cmd); ShellProcessContext spc = new SimpleProcessContext( result -> deferred.resolve(result.type(type))); process.execute(spc); })); }
PluginContext ctx = req.require(PluginContext.class); ShellFactory factory = ctx.getPlugin(ShellFactory.class); Shell shell = factory.create(null);
void run() { Shell sh = task.factory.create(null); ShellProcess sp = sh.createProcess(task.def.getLine()); task.plugin.processes.add(this); task.plugin.history.add(this); while (task.plugin.history.size() > 100) { task.plugin.history.remove(); } active = true; log.log(Level.FINE, "Started task with id=" + task.def.hashCode() + " pattern=" + task.def.getSchedullingPattern() + " : " + task.def.getLine()); sp.execute(context); }
Shell shell = factory.shellFactory.create(user); ConsoleReader reader = new ConsoleReader(in, out, this) { @Override
@OnOpen public void start(Session wsSession) { current.set(wsSession); try { URI uri = wsSession.getRequestURI(); String path = uri.getPath(); log.fine("Establishing session for " + path); String contextPath = path.substring(0, path.lastIndexOf('/')); PluginContext context = WebPluginLifeCycle.getPluginContext(contextPath); if (context != null) { Boolean enabled = context.getProperty(WebPlugin.ENABLED); if (enabled != null && enabled) { log.fine("Using shell " + context); ShellFactory factory = context.getPlugin(ShellFactory.class); Principal user = wsSession.getUserPrincipal(); Shell shell = factory.create(user); CRaSHSession session = new CRaSHSession(wsSession, shell); sessions.put(wsSession.getId(), session); log.fine("Established session " + wsSession.getId()); } else { log.fine("Web plugin disabled"); } } else { log.fine("No shell found"); } } finally { current.set(null); } }
public void handle(final TermIO io, Principal user) { Shell shell = factory.create(user); ConsoleTerm term = new ConsoleTerm(io); Processor processor = new Processor(term, shell); processor.addListener(io); processor.addListener(shell); processor.run(); } }
Shell shell = pluginContext.getPlugin(ShellFactory.class).create(user); ShellProcess shellProcess = shell.createProcess(command);
shell = factory.create(null); } else { shell = null;
try { ShellFactory factory = bootstrap.getContext().getPlugin(ShellFactory.class); Shell shell = factory.create(null); RemoteClient client = new RemoteClient(port, shell); log.log(Level.INFO, "Callback back remote on port " + port);
public void testFoo() throws Exception { URL xml = SpringTestCase.class.getResource("spring.xml"); Assert.assertNotNull(xml); // GenericXmlApplicationContext context = new GenericXmlApplicationContext(new UrlResource(xml)); context.start(); // SpringBootstrap bootstrap = context.getBean(SpringBootstrap.class); // Test a bit ShellFactory factory = bootstrap.getContext().getPlugin(ShellFactory.class); Shell shell = factory.create(null); assertNotNull(shell); ShellProcess process = shell.createProcess("foo_cmd"); assertNotNull(process); BaseProcessContext pc = BaseProcessContext.create(process).execute(); assertTrue(pc.getResponse() instanceof ShellResponse.Ok); String r = pc.getOutput(); assertEquals("bar", r); } }
Shell shell = factory.shellFactory.create(user); ConsoleReader reader = new ConsoleReader(in, out, this) { @Override
Shell shell = factory.shellFactory.create(user, authInfo); ConsoleReader reader = new ConsoleReader(in, out, this) { @Override
@OnOpen public void start(Session wsSession) { current.set(wsSession); try { URI uri = wsSession.getRequestURI(); String path = uri.getPath(); log.fine("Establishing session for " + path); String contextPath = path.substring(0, path.lastIndexOf('/')); PluginContext context = WebPluginLifeCycle.getPluginContext(contextPath); if (context != null) { Boolean enabled = context.getProperty(WebPlugin.ENABLED); if (enabled != null && enabled) { log.fine("Using shell " + context); ShellFactory factory = context.getPlugin(ShellFactory.class); Principal user = wsSession.getUserPrincipal(); Shell shell = factory.create(user); CRaSHSession session = new CRaSHSession(wsSession, shell); sessions.put(wsSession.getId(), session); log.fine("Established session " + wsSession.getId()); } else { log.fine("Web plugin disabled"); } } else { log.fine("No shell found"); } } finally { current.set(null); } }
public void handle(final TermIO io, Principal user) { Shell shell = factory.create(user); ConsoleTerm term = new ConsoleTerm(io); Processor processor = new Processor(term, shell); processor.addListener(io); processor.addListener(shell); processor.run(); } }
public void handle(final TermIO io, Principal user) { Shell shell = factory.create(user); ConsoleTerm term = new ConsoleTerm(io); Processor processor = new Processor(term, shell); processor.addListener(io); processor.addListener(shell); processor.run(); } }
Shell shell = pluginContext.getPlugin(ShellFactory.class).create(user); ShellProcess shellProcess = shell.createProcess(command);
Shell shell = pluginContext.getPlugin(ShellFactory.class).create(user); ShellProcess shellProcess = shell.createProcess(command);
Shell shell = pluginContext.getPlugin(ShellFactory.class).create(user, authInfo); ShellProcess shellProcess = shell.createProcess(command);
try { ShellFactory factory = bootstrap.getContext().getPlugin(ShellFactory.class); Shell shell = factory.create(null, null); RemoteClient client = new RemoteClient(port, shell); log.log(Level.INFO, "Callback back remote on port " + port);
try { ShellFactory factory = bootstrap.getContext().getPlugin(ShellFactory.class); Shell shell = factory.create(null); RemoteClient client = new RemoteClient(port, shell); log.log(Level.INFO, "Callback back remote on port " + port);