/** * Returns CLI status. * * @return true if and only if the CLI has finished. */ public boolean hasQuit() { return ctx.isTerminated(); }
@Override public boolean isTerminated() { return wrapped.isTerminated(); }
/** * Returns CLI status. * * @return true if and only if the CLI has finished. */ public boolean hasQuit() { return ctx.isTerminated(); }
public boolean isTerminated() { return delegate.isTerminated(); }
@Override public boolean isTerminated() { return wrapped.isTerminated(); }
public boolean isClosed() { return cmdCtx.isTerminated(); }
public boolean isTerminated() { return delegate.isTerminated(); }
/** * Terminate the current CommandContext. */ public void terminate() { if (!ctx.isTerminated()) { ctx.terminateSession(); } }
/** * Terminate the current CommandContext. */ public void terminate() { if (!ctx.isTerminated()) { ctx.terminateSession(); } }
private boolean checkStatus() { return cmdCtx.getExitCode() == 0 && !cmdCtx.isTerminated(); }
private static void processCommands(List<String> commands, CommandContext cmdCtx) { int i = 0; while (cmdCtx.getExitCode() == 0 && i < commands.size() && !cmdCtx.isTerminated()) { cmdCtx.handleSafe(commands.get(i)); ++i; } }
private static void processCommands(List<String> commands, CommandContext cmdCtx) { int i = 0; while (cmdCtx.getExitCode() == 0 && i < commands.size() && !cmdCtx.isTerminated()) { cmdCtx.handleSafe(commands.get(i)); ++i; } }
private static void processFile(File file, final CommandContext cmdCtx) { BufferedReader reader = null; try { reader = new BufferedReader(new FileReader(file)); String line = reader.readLine(); while (cmdCtx.getExitCode() == 0 && !cmdCtx.isTerminated() && line != null) { cmdCtx.handleSafe(line.trim()); line = reader.readLine(); } } catch (Throwable e) { throw new IllegalStateException("Failed to process file '" + file.getAbsolutePath() + "'", e); } finally { StreamUtils.safeClose(reader); } }
private static void processFile(File file, final CommandContext cmdCtx) { BufferedReader reader = null; try { reader = new BufferedReader(new FileReader(file)); String line = reader.readLine(); while (cmdCtx.getExitCode() == 0 && !cmdCtx.isTerminated() && line != null) { cmdCtx.handleSafe(line.trim()); line = reader.readLine(); } } catch (Throwable e) { throw new IllegalStateException("Failed to process file '" + file.getAbsolutePath() + "'", e); } finally { StreamUtils.safeClose(reader); } }
private void executeScripts(final CommandContext ctx) throws IOException { for (File script : scripts) { BufferedReader reader = null; try { reader = new BufferedReader(new InputStreamReader(new FileInputStream(script), "UTF-8")); String line = reader.readLine(); while (!ctx.isTerminated() && line != null) { try { ctx.handle(line.trim()); } catch (CommandFormatException e) { throw new IllegalArgumentException(String.format("Command '%s' is invalid. %s", line, e.getLocalizedMessage()), e); } catch (CommandLineException e) { throw new IllegalArgumentException(String.format("Command execution failed for command '%s'. %s", line, e.getLocalizedMessage()), e); } line = reader.readLine(); } } catch (Exception e) { throw new IllegalStateException("Failed to process file '" + script.getAbsolutePath() + "'", e); } finally { IoUtils.safeClose(reader); } } }
if (param.getCtx().isTerminated()) { throw new IllegalStateException("FAILED: Could not double checking " + param.getName() + " with management operations for " + param.getGoalStr() + "!" + "Because connection to cli is closed!");
@Override public void executeCli(String cliOperation) throws CliException, IOException { if (cliOperation.trim().startsWith("connect")) { throw new CliException("The 'connect' operation is not supported"); } checkClosed(); cliOperation = adjustOperationForDomain.adjust(cliOperation); log.debugf("Executing CLI operation %s", cliOperation); try { if ("reload".equals(cliOperation.trim())) { // CLI requires a special implementation of ModelControllerClient for "reload" and "shutdown", // but we only have the standard one, so these operations won't work // // however, "reload" with no options is particularly common in CLI scripts, so this special case // helps in those situations new Administration(this).reload(); } else { cliContext.handle(cliOperation); } } catch (Exception e) { if (e.getCause() instanceof IOException) { throw (IOException) e.getCause(); } throw new CliException(e); } if (cliContext.getExitCode() != 0 || cliContext.isTerminated()) { throw new CliException("CLI operation failed: " + cliOperation); } }
while (!ctx.isTerminated() && line != null) { ctx.handle(line); line = reader.readLine();
while (!ctx.isTerminated() && line != null) { ctx.handle(line); line = reader.readLine();
reader = new BufferedReader(new FileReader(scriptFile)); String line = reader.readLine(); while (!ctx.isTerminated() && line != null) { context.handle(line); line = reader.readLine();