@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); } }
@Override public ModelNodeResult execute(String operation) throws CliException, IOException { checkClosed(); operation = adjustOperationForDomain.adjust(operation); log.debugf("Executing operation %s", operation); ModelNode parsedOperation; try { parsedOperation = cliContext.buildRequest(operation); } catch (CommandFormatException e) { throw new CliException(e); } ModelNode result = client.execute(parsedOperation); return new ModelNodeResult(result); }