use of org.jboss.as.cli.batch.BatchManager in project wildfly-core by wildfly.
the class IfElseControlFlow method executeBlock.
private void executeBlock(CommandContext ctx, List<String> block, String blockName) throws CommandLineException {
if (block != null && !block.isEmpty()) {
final BatchManager batchManager = ctx.getBatchManager();
// this is to discard a batch started by the block in case the block fails
// as the cli remains in the batch mode in case run-batch resulted in an error
final boolean discardActivatedBatch = !batchManager.isBatchActive();
try {
for (String l : block) {
ctx.handle(l);
}
} finally {
if (discardActivatedBatch && batchManager.isBatchActive()) {
batchManager.discardActiveBatch();
}
}
}
}
use of org.jboss.as.cli.batch.BatchManager in project wildfly-core by wildfly.
the class TryHandler method doHandle.
/* (non-Javadoc)
* @see org.jboss.as.cli.handlers.CommandHandlerWithHelp#doHandle(org.jboss.as.cli.CommandContext)
*/
@Override
protected void doHandle(CommandContext ctx) throws CommandLineException {
final BatchManager batchManager = ctx.getBatchManager();
if (batchManager.isBatchActive()) {
throw new CommandFormatException("try is not allowed while in batch mode.");
}
ctx.registerRedirection(new TryCatchFinallyControlFlow(ctx));
}
use of org.jboss.as.cli.batch.BatchManager in project wildfly-core by wildfly.
the class DeployArchiveCommand method activateNewBatch.
static String activateNewBatch(CommandContext ctx) {
String currentBatch = null;
BatchManager batchManager = ctx.getBatchManager();
Attachments attachments = null;
if (batchManager.isBatchActive()) {
Batch current = batchManager.getActiveBatch();
attachments = current.getAttachments();
currentBatch = "batch" + System.currentTimeMillis();
batchManager.holdbackActiveBatch(currentBatch);
}
batchManager.activateNewBatch();
Batch archiveBatch = batchManager.getActiveBatch();
// computation.
if (attachments != null) {
for (String f : attachments.getAttachedFiles()) {
archiveBatch.getAttachments().addFileAttachment(f);
}
}
return currentBatch;
}
use of org.jboss.as.cli.batch.BatchManager in project wildfly-core by wildfly.
the class ArchiveHandler method discardBatch.
private void discardBatch(CommandContext ctx, String holdbackBatch) {
BatchManager batchManager = ctx.getBatchManager();
batchManager.discardActiveBatch();
if (holdbackBatch != null) {
batchManager.activateHeldbackBatch(holdbackBatch);
}
}
use of org.jboss.as.cli.batch.BatchManager in project wildfly-core by wildfly.
the class ArchiveHandler method activateNewBatch.
private String activateNewBatch(CommandContext ctx) {
String currentBatch = null;
BatchManager batchManager = ctx.getBatchManager();
if (batchManager.isBatchActive()) {
currentBatch = "batch" + System.currentTimeMillis();
batchManager.holdbackActiveBatch(currentBatch);
}
batchManager.activateNewBatch();
return currentBatch;
}
Aggregations