You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2011/05/20 11:49:52 UTC
svn commit: r1125300 -
/karaf/branches/karaf-2.1.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/Shutdown.java
Author: jbonofre
Date: Fri May 20 09:49:52 2011
New Revision: 1125300
URL: http://svn.apache.org/viewvc?rev=1125300&view=rev
Log:
[KARAF-614] Add confirmation message for the osgi:shutdown command.
Modified:
karaf/branches/karaf-2.1.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/Shutdown.java
Modified: karaf/branches/karaf-2.1.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/Shutdown.java
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.1.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/Shutdown.java?rev=1125300&r1=1125299&r2=1125300&view=diff
==============================================================================
--- karaf/branches/karaf-2.1.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/Shutdown.java (original)
+++ karaf/branches/karaf-2.1.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/Shutdown.java Fri May 20 09:49:52 2011
@@ -27,17 +27,36 @@ import org.osgi.framework.Bundle;
public class Shutdown extends OsgiCommandSupport {
protected Object doExecute() throws Exception {
- new Thread() {
- public void run() {
- try {
- Bundle bundle = getBundleContext().getBundle(0);
- bundle.stop();
- } catch (Exception e) {
- log.error("Error when shutting down Apache Karaf", e);
+ for (;;) {
+ StringBuffer sb = new StringBuffer();
+ System.err.println("Do you really want to shutdown (yes/no): ");
+ System.err.flush();
+ for (;;) {
+ int c = session.getKeyboard().read();
+ if (c < 0) {
+ return null;
}
+ System.err.print((char) c);
+ if (c == '\r' || c == '\n') {
+ break;
+ }
+ sb.append((char) c);
+ }
+ String str = sb.toString();
+ if (str.equals("yes")) {
+ new Thread() {
+ public void run() {
+ try {
+ Bundle bundle = getBundleContext().getBundle(0);
+ bundle.stop();
+ } catch (Exception e) {
+ log.error("Error when shutting down Apache Karaf", e);
+ }
+ }
+ }.start();
}
- }.start();
- return null;
+ return null;
+ }
}
}