Better manage Bootstrap created objects

Fixes https://github.com/spring-projects/spring-shell/issues/96
This commit is contained in:
Eric Bottard
2016-10-10 13:11:26 +02:00
parent 71f9da5578
commit 1626a4919f

View File

@@ -43,19 +43,14 @@ public class Bootstrap {
private final static String[] CONTEXT_PATH = { "classpath*:/META-INF/spring/spring-shell-plugin.xml" }; private final static String[] CONTEXT_PATH = { "classpath*:/META-INF/spring/spring-shell-plugin.xml" };
private static Bootstrap bootstrap; private CommandLine commandLine;
private static StopWatch sw = new StopWatch("Spring Shell");
private static CommandLine commandLine;
private GenericApplicationContext ctx; private GenericApplicationContext ctx;
public static void main(String[] args) throws IOException { public static void main(String[] args) throws IOException {
sw.start();
ExitShellRequest exitShellRequest; ExitShellRequest exitShellRequest;
try { try {
bootstrap = new Bootstrap(args); Bootstrap bootstrap = new Bootstrap(args);
exitShellRequest = bootstrap.run(); exitShellRequest = bootstrap.run();
} }
catch (RuntimeException t) { catch (RuntimeException t) {
@@ -144,7 +139,7 @@ public class Bootstrap {
} }
public ExitShellRequest run() { public ExitShellRequest run() {
StopWatch sw = new StopWatch("Spring Shell");
String[] commandsToExecuteAndThenQuit = commandLine.getShellCommandsToExecute(); String[] commandsToExecuteAndThenQuit = commandLine.getShellCommandsToExecute();
// The shell is used // The shell is used
JLineShellComponent shell = ctx.getBean("shell", JLineShellComponent.class); JLineShellComponent shell = ctx.getBean("shell", JLineShellComponent.class);
@@ -187,4 +182,4 @@ public class Bootstrap {
public JLineShellComponent getJLineShellComponent() { public JLineShellComponent getJLineShellComponent() {
return ctx.getBean("shell", JLineShellComponent.class); return ctx.getBean("shell", JLineShellComponent.class);
} }
} }