@Argument(index = 1, name = "startLevel", description = "The bundle's new start level", required = false, multiValued = false)
Integer level;
protected void doExecute(Bundle bundle) throws Exception {
// Get package instance service.
BundleStartLevel bsl = bundle.adapt(BundleStartLevel.class);
if (bsl == null) {
System.out.println("StartLevel service is unavailable.");
return;
}
if (level == null) {
System.out.println("Level " + bsl.getStartLevel());
}
else if ((level < 50) && bsl.getStartLevel() > 50){
for (;;) {
StringBuffer sb = new StringBuffer();
System.err.println("You are about to designate bundle as a system bundle. Do you wish to continue (yes/no): ");
System.err.flush();
for (;;) {
int c = System.in.read();
if (c < 0) {
return;
}
System.err.println((char) c);
if (c == '\r' || c == '\n') {
break;
}
sb.append((char) c);
}
String str = sb.toString();
if ("yes".equals(str)) {
bsl.setStartLevel(level);
break;
} else if ("no".equals(str)) {
break;
}
}
} else {
bsl.setStartLevel(level);
}
}