Search in sources :

Example 6 with OperationCommand

use of org.jboss.as.cli.OperationCommand in project wildfly-core by wildfly.

the class CommandContextImpl method handleLegacyCommand.

private void handleLegacyCommand(String opLine, CommandHandler handler, boolean direct) throws CommandLineException {
    if (isBatchMode() && handler.isBatchMode(this)) {
        if (!(handler instanceof OperationCommand)) {
            throw new CommandLineException("The command is not allowed in a batch.");
        } else {
            try {
                Batch batch = getBatchManager().getActiveBatch();
                HandledRequest request = ((OperationCommand) handler).buildHandledRequest(this, batch.getAttachments());
                BatchedCommand batchedCmd = new DefaultBatchedCommand(this, opLine, request.getRequest(), request.getResponseHandler());
                batch.add(batchedCmd);
            } catch (CommandFormatException e) {
                throw new CommandFormatException("Failed to add to batch '" + opLine + "'", e);
            }
        }
    } else if (direct) {
        handler.handle(CommandContextImpl.this);
    } else {
        execute(() -> {
            executor.execute(handler, timeout, TimeUnit.SECONDS);
            return null;
        }, opLine);
    }
}
Also used : OperationCommand(org.jboss.as.cli.OperationCommand) Batch(org.jboss.as.cli.batch.Batch) CommandFormatException(org.jboss.as.cli.CommandFormatException) HandledRequest(org.jboss.as.cli.OperationCommand.HandledRequest) DefaultBatchedCommand(org.jboss.as.cli.batch.impl.DefaultBatchedCommand) CommandLineException(org.jboss.as.cli.CommandLineException) DefaultBatchedCommand(org.jboss.as.cli.batch.impl.DefaultBatchedCommand) BatchedCommand(org.jboss.as.cli.batch.BatchedCommand)

Aggregations

OperationCommand (org.jboss.as.cli.OperationCommand)6 CommandFormatException (org.jboss.as.cli.CommandFormatException)4 CommandLineException (org.jboss.as.cli.CommandLineException)4 CommandArgument (org.jboss.as.cli.CommandArgument)2 HandledRequest (org.jboss.as.cli.OperationCommand.HandledRequest)2 Batch (org.jboss.as.cli.batch.Batch)2 ParsedCommandLine (org.jboss.as.cli.operation.ParsedCommandLine)2 ModelNode (org.jboss.dmr.ModelNode)2 ArrayList (java.util.ArrayList)1 ArgumentValueConverter (org.jboss.as.cli.ArgumentValueConverter)1 CommandHandler (org.jboss.as.cli.CommandHandler)1 CommandLineCompleter (org.jboss.as.cli.CommandLineCompleter)1 BatchedCommand (org.jboss.as.cli.batch.BatchedCommand)1 DefaultBatchedCommand (org.jboss.as.cli.batch.impl.DefaultBatchedCommand)1 CommandCommandHandler (org.jboss.as.cli.handlers.CommandCommandHandler)1 ArgumentWithValue (org.jboss.as.cli.impl.ArgumentWithValue)1 OperationFormatException (org.jboss.as.cli.operation.OperationFormatException)1 DefaultCallbackHandler (org.jboss.as.cli.operation.impl.DefaultCallbackHandler)1 ModelType (org.jboss.dmr.ModelType)1 Property (org.jboss.dmr.Property)1