startLevelService.open();
startLevelService.restoreState();
  public Framework(Object m) throws Exception {    // guard this for profiles without System.setProperty     try {      System.setProperty(Constants.FRAMEWORK_EXECUTIONENVIRONMENT, defaultEE);    } catch (Exception e) {      if(Debug.packages) {	Debug.println("FGailed to set execution environment: " + e);      }    }    String whichStorageImpl = "org.knopflerfish.framework.bundlestorage." +       System.getProperty("org.knopflerfish.framework.bundlestorage", "file") +      ".BundleStorageImpl";    bIsMemoryStorage = whichStorageImpl.equals("org.knopflerfish.framework.bundlestorage.memory.BundleStorageImpl");        // We just happens to know that the memory storage impl isn't R3    // compatible. And it never will be since it isn't persistent    // by design.    if(R3_TESTCOMPLIANT && bIsMemoryStorage) {      throw new RuntimeException("Memory bundle storage is not compatible " + 				 "with R3 complicance");    }    Class storageImpl = Class.forName(whichStorageImpl);    storage           = (BundleStorage)storageImpl.newInstance();    dataStorage       = Util.getFileStorage("data");    packages          = new Packages(this);    systemBundle      = new SystemBundle(this);    systemBC          = new BundleContextImpl(systemBundle);    bundles           = new Bundles(this);    systemBundle.setBundleContext(systemBC);        if (System.getSecurityManager() != null) {      bPermissions = true;      permissions       = new PermissionAdminImpl(this);      String [] classes = new String [] { PermissionAdmin.class.getName() };      services.register(systemBundle,			classes,			permissions,			null);      Policy.setPolicy(new FrameworkPolicy(permissions));    }    String[] classes = new String [] { PackageAdmin.class.getName() };    services.register(systemBundle,		      classes,		      new PackageAdminImpl(this),		      null);    String useStartLevel =       System.getProperty("org.knopflerfish.startlevel.use", "true");    if("true".equals(useStartLevel)) {      if(Debug.startlevel) {	Debug.println("[using startlevel service]");      }      startLevelService = new StartLevelImpl(this);      startLevelService.open();            services.register(systemBundle,			new String [] { StartLevel.class.getName() },			startLevelService,			null);    }    bundles.load();    mainHandle = m;    urlStreamHandlerFactory = new ServiceURLStreamHandlerFactory(this);    contentHandlerFactory   = new ServiceContentHandlerFactory(this);    urlStreamHandlerFactory      .setURLStreamHandler(BundleURLStreamHandler.PROTOCOL,			   new BundleURLStreamHandler(bundles));    urlStreamHandlerFactory      .setURLStreamHandler(ReferenceURLStreamHandler.PROTOCOL,			   new ReferenceURLStreamHandler());        // Install service based URL stream handler    URL.setURLStreamHandlerFactory(urlStreamHandlerFactory);				       URLConnection.setContentHandlerFactory(contentHandlerFactory);  }