本文整理匯總了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();
}