@Override public Object execute() throws Exception { if (force) { if (reboot) { systemService.reboot(time, determineSwipeType()); } else { systemService.halt(time); } return null; } for (; ; ) { String karafName = System.getProperty("karaf.name"); String msg; if (reboot) { msg = String.format("Confirm: reboot instance %s (yes/no): ", karafName); } else { msg = String.format("Confirm: halt instance %s (yes/no): ", karafName); } String str = null; try { str = session.readLine(msg, null); } catch (UnsupportedOperationException e) { // this is a remote client with shutdown argument so here isn't a interactive way // so return a prompt message instead of NPE System.out.println( "please use \"shutdown -f\" or \"shutdown --force\" to shutdown instance: " + karafName); return null; } if (str.equalsIgnoreCase("yes")) { if (reboot) { systemService.reboot(time, determineSwipeType()); } else { systemService.halt(time); } } return null; } }
public String getHelp(final Session session, String path) { if (path == null) { path = "%root%"; } Map<String, String> props = new HashMap<String, String>(); props.put("data", "${" + path + "}"); final List<HelpProvider> providers = session.getRegistry().getServices(HelpProvider.class); InterpolationHelper.performSubstitution( props, new InterpolationHelper.SubstitutionCallback() { public String getValue(final String key) { for (HelpProvider hp : providers) { String result = hp.getHelp(session, key); if (result != null) { return removeNewLine(result); } } return null; } }); return props.get("data"); }