本文整理汇总了Java中org.springframework.shell.event.ShellStatus.Status类的典型用法代码示例。如果您正苦于以下问题:Java Status类的具体用法?Java Status怎么用?Java Status使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Status类属于org.springframework.shell.event.ShellStatus包,在下文中一共展示了Status类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getResult
import org.springframework.shell.event.ShellStatus.Status; //导入依赖的package包/类
Result getResult() {
CompositeResultData compositeResultData = ResultBuilder.createCompositeResultData();
compositeResultData.setHeader(
"************************* Execution Summary ***********************\nScript file: "
+ filePath);
for (int i = 0; i < this.commandAndStatusList.size(); i++) {
int commandSrNo = i + 1;
SectionResultData section = compositeResultData.addSection("" + (i + 1));
CommandAndStatus commandAndStatus = commandAndStatusList.get(i);
section.addData("Command-" + String.valueOf(commandSrNo), commandAndStatus.command);
section.addData("Status", commandAndStatus.status);
if (commandAndStatus.status.equals("FAILED")) {
compositeResultData.setStatus(org.apache.geode.management.cli.Result.Status.ERROR);
}
if (i != this.commandAndStatusList.size()) {
section.setFooter(Gfsh.LINE_SEPARATOR);
}
}
return ResultBuilder.buildResult(compositeResultData);
}
示例2: promptLoop
import org.springframework.shell.event.ShellStatus.Status; //导入依赖的package包/类
/**
* We override this method just to fool runner thread in reading from nothing. It waits for
* Condition endOfShell which is signalled when terminate is called. This achieves clean
* shutdown of runner thread.
*/
@Override
public void promptLoop() {
lock.lock();
try {
while (true) {
try {
endOfShell.await();
} catch (InterruptedException e) {
// e.printStackTrace();
}
this.exitShellRequest = ExitShellRequest.NORMAL_EXIT;
setShellStatus(Status.SHUTTING_DOWN);
break;
}
} finally {
lock.unlock();
}
}
示例3: promptLoop
import org.springframework.shell.event.ShellStatus.Status; //导入依赖的package包/类
@Override
public void promptLoop() {
String line = null;
String prompt = getPromptText();
try {
gfshHistory.setAutoFlush(false);
// NOTE: Similar code is in executeScript()
while (exitShellRequest == null && (line = readLine(reader, prompt)) != null) {
if (!line.endsWith(SyntaxConstants.CONTINUATION_CHARACTER)) { // see 45893
List<String> commandList = MultiCommandHelper.getMultipleCommands(line);
for (String cmdLet : commandList) {
String trimmedCommand = cmdLet.trim();
if (!trimmedCommand.isEmpty()) {
executeCommand(cmdLet);
}
}
prompt = getPromptText();
} else {
prompt = getDefaultSecondaryPrompt();
reader.getCursorBuffer().cursor = 0;
reader.getCursorBuffer().write(removeBackslash(line) + LINE_SEPARATOR);
}
}
if (line == null) {
// Possibly Ctrl-D was pressed on empty prompt. ConsoleReader.readLine
// returns null on Ctrl-D
this.exitShellRequest = ExitShellRequest.NORMAL_EXIT;
gfshFileLogger.info("Exiting gfsh, it seems Ctrl-D was pressed.");
}
} catch (IOException e) {
logSevere(e.getMessage(), e);
}
println((line == null ? LINE_SEPARATOR : "") + "Exiting... ");
setShellStatus(Status.SHUTTING_DOWN);
}
示例4: HeadlessGfsh
import org.springframework.shell.event.ShellStatus.Status; //导入依赖的package包/类
public HeadlessGfsh(String name, int timeout, Properties envProps, String parentDir)
throws ClassNotFoundException, IOException {
this.timeout = timeout;
System.setProperty("jline.terminal", GfshUnsupportedTerminal.class.getName());
this.shell = new HeadlessGfshShell(name, this, parentDir);
this.shell.setEnvProperty(Gfsh.ENV_APP_RESULT_VIEWER, "non-basic");
if (envProps != null) {
for (String key : envProps.stringPropertyNames()) {
this.shell.setEnvProperty(key, envProps.getProperty(key));
}
}
// This allows us to avoid race conditions during startup - in particular a NPE on the
// ConsoleReader which is
// created in a separate thread during start()
CountDownLatch shellStarted = new CountDownLatch(1);
this.shell.addShellStatusListener((oldStatus, newStatus) -> {
if (newStatus.getStatus() == Status.STARTED) {
shellStarted.countDown();
}
});
this.shell.start();
this.setThreadLocalInstance();
try {
shellStarted.await();
} catch (InterruptedException e) {
e.printStackTrace(System.out);
}
}
示例5: handleExecutionResult
import org.springframework.shell.event.ShellStatus.Status; //导入依赖的package包/类
@Override
protected void handleExecutionResult(Object result) {
try {
if (result instanceof Result) {
Result commandResult = (Result) result;
boolean isError = Result.Status.ERROR.equals(commandResult.getStatus());
if (isError) {
setLastExecutionStatus(-2);
} else {
setLastExecutionStatus(0);
}
while (commandResult.hasNextLine()) {
write(commandResult.nextLine(), isError);
}
if (result instanceof CommandResult) {
CommandResult cmdResult = (CommandResult) result;
if (cmdResult.hasIncomingFiles()) {
boolean isAlreadySaved = cmdResult.getNumTimesSaved() > 0;
if (!isAlreadySaved) {
cmdResult.saveIncomingFiles(null);
}
Gfsh.println();// Empty line
}
}
}
if (result != null && !(result instanceof Result)) {
printAsInfo(result.toString());
}
} catch (Exception e) {
printAsWarning(e.getMessage());
logToFile(e.getMessage(), e);
}
}
示例6: run
import org.springframework.shell.event.ShellStatus.Status; //导入依赖的package包/类
protected void run(String[] args)
{
ServerConfigHelper.initConfig("env.properties");
ServerConfigHelper.initLog4j("log4j-shell.xml");
DomainMapperHelper.scanMapperRegistryClass();
System.setProperty("jline.WindowsTerminal.directConsole", "false");
String[] contextPath={ "gemlite-shell.xml" };
bootstrap = new Bootstrap(args,contextPath);
shell = (GShellComponent)bootstrap.getJLineShellComponent();
shell.setDevelopmentMode(true);
shell.addShellStatusListener(new ShellStatusListener()
{
@Override
public void onShellStatusChange(ShellStatus oldStatus, ShellStatus newStatus)
{
if(newStatus.getStatus()==Status.STARTED)
{
DomainMapperHelper.scanMapperRegistryClass();
shell.executeCommand("connect");
shell.executeCommand("mn connect");
}
}
});
shell.start();
shell.waitForComplete();
}
示例7: handleExecutionResult
import org.springframework.shell.event.ShellStatus.Status; //导入依赖的package包/类
@Override
protected void handleExecutionResult(Object result) {
try {
if (result instanceof Result) {
Result commandResult = (Result) result;
boolean isError = Result.Status.ERROR.equals(commandResult.getStatus());
if (isError) {
setLastExecutionStatus(-2);
} else {
setLastExecutionStatus(0);
}
if (useExternalViewer(commandResult)) {
// - Save file and pass to less so that viewer can scroll through
// results
CliUtil.runLessCommandAsExternalViewer(commandResult, isError);
} else {
if (!isScriptRunning) {
// Normal Command
while (commandResult.hasNextLine()) {
write(commandResult.nextLine(), isError);
}
} else if (!supressScriptCmdOutput) {
// Command is part of script. Show output only when quite=false
while (commandResult.hasNextLine()) {
write(commandResult.nextLine(), isError);
}
}
}
resultTypeTL.set(null);
if (result instanceof CommandResult) {
CommandResult cmdResult = (CommandResult) result;
if (cmdResult.hasIncomingFiles()) {
boolean isAlreadySaved = cmdResult.getNumTimesSaved() > 0;
if (!isAlreadySaved) {
cmdResult.saveIncomingFiles(null);
}
Gfsh.println();// Empty line
}
}
}
if (result != null && !(result instanceof Result)) {
printAsInfo(result.toString());
}
} catch (Exception e) {
printAsWarning(e.getMessage());
logToFile(e.getMessage(), e);
}
}
示例8: promptLoop
import org.springframework.shell.event.ShellStatus.Status; //导入依赖的package包/类
@Override
public void promptLoop() {
String line = null;
String prompt = getPromptText();
try {
gfshHistory.setAutoFlush(false);
// NOTE: Similar code is in executeScript()
while (exitShellRequest == null && (line = readLine(reader, prompt)) != null) {
if (!line.endsWith(SyntaxConstants.CONTINUATION_CHARACTER)) { // see 45893
String command = null;
do {
int index = line.indexOf(SyntaxConstants.COMMAND_DELIMITER);
if (index != -1) {
command = line.substring(0, index+1);
} else {
command = line;
}
String trimmedCommand = command.trim();
if (trimmedCommand.equals(SyntaxConstants.COMMAND_DELIMITER)) {
// do nothing // see 46098 - skip if line contains only a ';'
} else if (!trimmedCommand.isEmpty()) {
executeCommand(command);
}
line = line.substring(index + 1);
} while (ParserUtils.contains(line, SyntaxConstants.COMMAND_DELIMITER));
prompt = getPromptText();
} else {
prompt = getDefaultSecondaryPrompt();
reader.getCursorBuffer().cursor = 0;
reader.getCursorBuffer().write(removeBackslash(line) + LINE_SEPARATOR);
}
}
if (line == null) {
// Possibly Ctrl-D was pressed on empty prompt. ConsoleReader.readLine
// returns null on Ctrl-D
this.exitShellRequest = ExitShellRequest.NORMAL_EXIT;
gfshFileLogger.info("Exiting gfsh, it seems Ctrl-D was pressed.");
}
} catch (IOException e) {
logSevere(e.getMessage(), e);
}
println((line == null ? LINE_SEPARATOR : "") + "Exiting... ");
setShellStatus(Status.SHUTTING_DOWN);
}