public void execute() { log.info("execute cli command"); try { ctx.handle(CMD_READ_MSG); } catch (CommandLineException e) { e.printStackTrace(); } }
public void init() { log.info("connect to server"); try { ctx = CommandContextFactory.getInstance().newCommandContext(); // ctx = CommandContextFactory.getInstance().newCommandContext("user", "password"); ctx.connectController("127.0.0.1", 9999); } catch (CliInitializationException e) { throw new IllegalStateException("Failed to initialize CLI context", e); } catch (CommandLineException e) { log.error("error connecting to server " + e.toString()); } }