@Override public void start() throws Exception { ShellServer server = ShellServer.create(vertx); AtomicInteger ai = new AtomicInteger(0); server.shellHandler(shell -> { shell.setPrompt(s -> { try { TelnetTermOptions tto = new TelnetTermOptions().setPort(3000).setHost("localhost"); TermServer telnetTermServer = TermServer.createTelnetTermServer(vertx,tto); server.registerTermServer(telnetTermServer); server.registerCommandResolver(CommandResolver.baseCommands(vertx)); server.listen(ar -> { if (!ar.succeeded()) { ar.cause().printStackTrace();
@Before public void before(TestContext context) throws Exception { vertx = Vertx.vertx(); server = ShellServer.create(vertx).registerCommandResolver(new BaseCommandPack(vertx)).listen(context.asyncAssertSuccess()); }
public ShellServiceImpl(Vertx vertx, ShellServiceOptions options) { this.vertx = vertx; this.options = options; this.server = ShellServer.create(vertx, new ShellServerOptions(options)); this.registry = CommandRegistry.getShared(vertx); }
private void startServer(List<CommandResolver> resolvers, Handler<AsyncResult<Void>> startHandler) { TelnetTermOptions telnetOptions = options.getTelnetOptions(); SSHTermOptions sshOptions = options.getSSHOptions(); HttpTermOptions webOptions = options.getHttpOptions(); if (telnetOptions != null) { server.registerTermServer(new TelnetTermServer(vertx, telnetOptions)); } if (sshOptions != null) { server.registerTermServer(new SSHServer(vertx, sshOptions)); } if (webOptions != null) { server.registerTermServer(new HttpTermServer(vertx, webOptions)); } resolvers.forEach(server::registerCommandResolver); server.listen(startHandler); }
@Before public void before() { vertx = Vertx.vertx(); commands = new TestCommands(vertx); server = ShellServer.create(vertx).registerCommandResolver(commands); }
/** * Close the shell server, this is an asynchronous close. * @param completionHandler handler for getting notified when service is stopped */ public void close(Handler<AsyncResult<Void>> completionHandler) { delegate.close(completionHandler); }
/** * Start the shell service, this is an asynchronous start. * @return */ public io.vertx.rxjava.ext.shell.ShellServer listen() { delegate.listen(); return this; }
/** * Create a new shell, the returned shell should be closed explicitely. * @return the created shell */ public io.vertx.rxjava.ext.shell.Shell createShell() { io.vertx.rxjava.ext.shell.Shell ret = io.vertx.rxjava.ext.shell.Shell.newInstance(delegate.createShell()); return ret; }
/** * Register a term server to this shell server, the term server lifecycle methods are managed by this shell server. * @param termServer the term server to add * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.ext.shell.ShellServer registerTermServer(io.vertx.rxjava.ext.shell.term.TermServer termServer) { delegate.registerTermServer(termServer.getDelegate()); return this; }
/** * Register a command resolver for this server. * @param resolver the resolver * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.ext.shell.ShellServer registerCommandResolver(io.vertx.rxjava.ext.shell.command.CommandResolver resolver) { delegate.registerCommandResolver(resolver.getDelegate()); return this; }
/** * Called when a new shell is created. Can be used to prepopulate the shell session with objects * or set the prompt. * @param shellHandler handler for getting notified when the server creates a new shell. */ public void shellHandler(Handler<io.vertx.rxjava.ext.shell.Shell> shellHandler) { delegate.shellHandler(new Handler<io.vertx.ext.shell.Shell>() { public void handle(io.vertx.ext.shell.Shell event) { shellHandler.handle(io.vertx.rxjava.ext.shell.Shell.newInstance(event)); } }); }
@Before public void before(TestContext context) throws Exception { ctx = new AtomicReference<>(null); vertx = Vertx.vertx(); server = ShellServer.create(vertx) .registerCommandResolver(new BaseCommandPack(vertx)).listen(context.asyncAssertSuccess()); }
/** * Create a new shell server with specific options. * @param vertx the vertx * @return the created shell server */ public static io.vertx.rxjava.ext.shell.ShellServer create(io.vertx.rxjava.core.Vertx vertx) { io.vertx.rxjava.ext.shell.ShellServer ret = io.vertx.rxjava.ext.shell.ShellServer.newInstance(io.vertx.ext.shell.ShellServer.create(vertx.getDelegate())); return ret; }
/** * Close the shell server, this is an asynchronous close. */ public void close() { delegate.close(); }
/** * Start the shell service, this is an asynchronous start. * @param listenHandler handler for getting notified when service is started * @return */ public io.vertx.rxjava.ext.shell.ShellServer listen(Handler<AsyncResult<Void>> listenHandler) { delegate.listen(listenHandler); return this; }
/** * Create a new shell, the returned shell should be closed explicitely. * @return the created shell */ public io.vertx.rxjava.ext.shell.Shell createShell() { io.vertx.rxjava.ext.shell.Shell ret = io.vertx.rxjava.ext.shell.Shell.newInstance(delegate.createShell()); return ret; }
/** * Register a term server to this shell server, the term server lifecycle methods are managed by this shell server. * @param termServer the term server to add * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.ext.shell.ShellServer registerTermServer(io.vertx.rxjava.ext.shell.term.TermServer termServer) { delegate.registerTermServer(termServer.getDelegate()); return this; }
/** * Register a command resolver for this server. * @param resolver the resolver * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.ext.shell.ShellServer registerCommandResolver(io.vertx.rxjava.ext.shell.command.CommandResolver resolver) { delegate.registerCommandResolver(resolver.getDelegate()); return this; }
/** * Called when a new shell is created. Can be used to prepopulate the shell session with objects * or set the prompt. * @param shellHandler handler for getting notified when the server creates a new shell. */ public void shellHandler(Handler<io.vertx.rxjava.ext.shell.Shell> shellHandler) { delegate.shellHandler(new Handler<io.vertx.ext.shell.Shell>() { public void handle(io.vertx.ext.shell.Shell event) { shellHandler.handle(io.vertx.rxjava.ext.shell.Shell.newInstance(event)); } }); }
private void startShellServer(TestContext context, long sessionTimeout, long reaperInterval) { if (shellServer != null) { throw new IllegalStateException("Already started"); } Async latch = context.async(); shellServer = ShellServer.create(vertx, new ShellServerOptions().setSessionTimeout(sessionTimeout).setReaperInterval(reaperInterval)). registerTermServer(termServer). registerCommandResolver(registry). listen(context.asyncAssertSuccess(v -> latch.complete())); latch.awaitSuccess(20000); }