protected Object doExecute()

in gshell/gshell-osgi/src/main/java/org/apache/servicemix/kernel/gshell/osgi/BundleCommand.java [34:76]


    protected Object doExecute() throws Exception {
        Bundle bundle = getBundleContext().getBundle(id);
        if (bundle == null) {
            io.out.println("Bundle " + id + " not found");
            return Result.FAILURE;
        }
        if (!force) {
            ServiceReference ref = getBundleContext().getServiceReference(StartLevel.class.getName());
            if (ref != null) {
                StartLevel sl = getService(StartLevel.class, ref);
                if (sl != null) {
                    int level = sl.getBundleStartLevel(bundle);
                    if (level < 50) {
                        for (;;) {
                            StringBuffer sb = new StringBuffer();
                            io.err.print("You are about to access a system bundle.  Do you want to continue (yes/no): ");
                            io.err.flush();
                            for (;;) {
                                int c = io.in.read();
                                if (c < 0) {
                                    return Result.FAILURE;
                                }
                                io.err.print((char) c);
                                if (c == '\r' || c == '\n') {
                                    break;
                                }
                                sb.append((char) c);
                            }
                            String str = sb.toString();
                            if ("yes".equals(str)) {
                                break;
                            }
                            if ("no".equals(str)) {
                                return Result.FAILURE;
                            }
                        }
                    }
                }
            }
        }
        doExecute(bundle);
        return Result.SUCCESS;
    }