protected void doExecute()

in gshell/gshell-osgi/src/main/java/org/apache/servicemix/kernel/gshell/osgi/BundleLevel.java [29:72]


    protected void doExecute(Bundle bundle) throws Exception {
        // Get package admin service.
        ServiceReference ref = getBundleContext().getServiceReference(StartLevel.class.getName());
        if (ref == null) {
            io.out.println("StartLevel service is unavailable.");
            return;
        }
        StartLevel sl = getService(StartLevel.class, ref);
        if (sl == null) {
            io.out.println("StartLevel service is unavailable.");
            return;
        }

        if (level == null) {
            io.out.println("Level " + sl.getBundleStartLevel(bundle));
        }
        else if ((level < 50) && sl.getBundleStartLevel(bundle) > 50){
            for (;;) {
                StringBuffer sb = new StringBuffer();
                io.err.println("You are about to designate bundle as a system bundle.  Do you want to continue (yes/no): ");
                io.err.flush();
                for (;;) {
                    int c = io.in.read();
                    if (c < 0) {
                        return;
                    }
                    io.err.println((char) c);
                    if (c == '\r' || c == '\n') {
                        break;
                    }
                    sb.append((char) c);
                }
                String str = sb.toString();
                if ("yes".equals(str)) {
                    sl.setBundleStartLevel(bundle, level);
                    break;
                } else if ("no".equals(str)) {
                    break;
                }
            }
        } else {
            sl.setBundleStartLevel(bundle, level);
        }
    }