/** @return always the {@code operation} object itself, possibly modified */ Operation adjust(Operation operation) { if (!options.isDomain) { return operation; } // this relies on an assumption that Operation.getOperation always returns the underlying ModelNode // and not a copy (see also ControllerClientAssumptionTest) adjust(operation.getOperation()); return operation; }
@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); }
@Override public ModelNodeResult execute(ModelNode operation) throws IOException { checkClosed(); operation = adjustOperationForDomain.adjust(operation); log.debugf("Executing operation %s", ModelNodeOperationToCliString.convert(operation)); log.tracef("JSON format:%n%s", operation.toJSONString(false)); ModelNode result = client.execute(operation); return new ModelNodeResult(result); }
@Override public ModelNodeResult execute(Operation operation) throws IOException { checkClosed(); operation = adjustOperationForDomain.adjust(operation); log.debugf("Executing operation %s", ModelNodeOperationToCliString.convert(operation.getOperation())); log.tracef("JSON format:%n%s", operation.getOperation().toJSONString(false)); ModelNode result = client.execute(operation); return new ModelNodeResult(result); }