CommandHandler ch = registry.getComponent(CommandHandler.class, "commandHandler");
if (ch == null) {
if (config.getPropertyAsBoolean("jconsole", false)) {
ConsoleUI console = new ConsoleUI();
PrintStream consoleStream = new PrintStream(console.getOutputStream());
ch = new CommandHandler(consoleStream, consoleStream);
JFrame w = new JFrame("ConsoleUI");
w.add(console);
w.setBounds(20, 20, 520, 400);
w.setLocationByPlatform(true);
String key = "console";
WindowUtils.restoreWindowBounds(key, w);
WindowUtils.addSaveOnShutdown(key, w);
w.setVisible(true);
console.setCommandHandler(ch);
} else {
ch = new StreamCommandHandler(System.in, System.out, System.err, PROMPT);
}
registry.registerComponent("commandHandler", ch);
}