本文整理汇总了Java中org.springframework.shell.event.ShellStatus类的典型用法代码示例。如果您正苦于以下问题:Java ShellStatus类的具体用法?Java ShellStatus怎么用?Java ShellStatus使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ShellStatus类属于org.springframework.shell.event包,在下文中一共展示了ShellStatus类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onShellStatusChange
import org.springframework.shell.event.ShellStatus; //导入依赖的package包/类
@Override
public void onShellStatusChange(ShellStatus oldStatus, ShellStatus newStatus) {
if (newStatus.getStatus() == ShellStatus.Status.STARTED) {
try {
String cluster = client.getClusterName();
boolean available = client.isBlueprintAvailable();
if (cluster == null) {
if (available) {
context.setHint(Hints.BUILD_CLUSTER);
} else {
context.setHint(Hints.ADD_BLUEPRINT);
}
} else {
context.setHint(Hints.PROGRESS);
}
context.setCluster(cluster);
context.setBlueprintsAvailable(available);
} catch (Exception e) {
System.out.println(e.getMessage());
shell.executeCommand("quit");
}
}
}
示例2: run
import org.springframework.shell.event.ShellStatus; //导入依赖的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();
}
示例3: onShellStatusChange
import org.springframework.shell.event.ShellStatus; //导入依赖的package包/类
@Override
public void onShellStatusChange(ShellStatus oldStatus, ShellStatus newStatus) {
if (newStatus.getStatus().equals(ShellStatus.Status.STARTED)) {
Path rcFilePath = getRCFilePath();
if (Files.exists(rcFilePath)) {
Level logLevel = COMMAND_LOG.getLevel();
COMMAND_LOG.setLevel(Level.OFF);
LOG.info(String.format("Loading shell configuration from file %s", rcFilePath.toAbsolutePath()));
try (
InputStream inputStream = Files.newInputStream(rcFilePath);
InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
BufferedReader bufferedReader = new BufferedReader(inputStreamReader)
) {
String line;
int lineNumber = 1;
while ( (line = bufferedReader.readLine()) != null) {
if (!line.trim().isEmpty()) {
LOG.fine(String.format("Executing command %s", line));
boolean success = shell.executeCommand(line).isSuccess();
if (!success) {
LOG.severe(String.format("Failed to execute line %s: %s", lineNumber, line));
break;
}
}
lineNumber++;
}
} catch (Exception e) {
LOG.severe(String.format("Failed to load shell configuration because of exception: %s", e));
}
COMMAND_LOG.setLevel(logLevel);
} else {
LOG.fine(String.format("Shell configuration file [%s] does not exist", rcFilePath.toAbsolutePath()));
}
eventBus.fireAsync(new ShellStartedEvent());
}
}
示例4: getShellStatus
import org.springframework.shell.event.ShellStatus; //导入依赖的package包/类
@Override
public ShellStatus getShellStatus() {
throw new UnsupportedOperationException();
}