@Override public int getExitCode() { return wrapped.getExitCode(); }
@Override public int getExitCode() { return wrapped.getExitCode(); }
public int getExitCode() { return delegate.getExitCode(); }
public int getExitCode() { return delegate.getExitCode(); }
private boolean checkStatus() { return cmdCtx.getExitCode() == 0 && !cmdCtx.isTerminated(); }
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 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); } }
/** * Sends command line to CLI. * * @param line specifies the command line. * @param readEcho if set to true reads the echo response form the CLI. * @throws Exception */ public boolean sendLine(String line, boolean ignoreError) { consoleOut.reset(); if(ignoreError) { ctx.handleSafe(line); return ctx.getExitCode() == 0; } else { try { ctx.handle(line); } catch (CommandLineException e) { Assert.fail("Failed to execute line '" + line + "': " + e.getLocalizedMessage()); } } return true; }
/** * Sends command line to CLI. * * @param line specifies the command line. * @param ignoreError if set to false, asserts that handling the line did not result in a {@link org.jboss.as.cli.CommandLineException}. * * @return true if the CLI is in a non-error state following handling the line */ public boolean sendLine(String line, boolean ignoreError) { consoleOut.reset(); if(ignoreError) { ctx.handleSafe(line); return ctx.getExitCode() == 0; } else { try { ctx.handle(line); } catch (CommandLineException e) { StringWriter stackTrace = new StringWriter(); e.printStackTrace(new PrintWriter(stackTrace)); Assert.fail(String.format("Failed to execute line '%s'%n%s", line, stackTrace.toString())); } } return true; }
if(ctx.getExitCode() != 0) { throw new CliInitializationException("Failed to process " + jbossCliRcFile.getAbsoluteFile());
if(ctx.getExitCode() != 0) { throw new CliInitializationException("Failed to process " + jbossCliRcFile.getAbsoluteFile());
@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); } }
if((cmdCtx != null) && !gui) { cmdCtx.terminateSession(); if(cmdCtx.getExitCode() != 0) { exitCode = cmdCtx.getExitCode();
if((cmdCtx != null) && !gui) { cmdCtx.terminateSession(); if(cmdCtx.getExitCode() != 0) { exitCode = cmdCtx.getExitCode();
return new Result(cliCommand, ctx.getExitCode()); } else { ctx.handle(cliCommand); return new Result(cliCommand, ctx.getExitCode());
return new Result(cliCommand, ctx.getExitCode()); } else { ctx.handle(cliCommand); return new Result(cliCommand, ctx.getExitCode());