⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 framework.java

📁 OSGI这是一个中间件,与UPNP齐名,是用于移植到嵌入式平台之上
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
   * <p>If the Framework is already started, this method does nothing.   * If the Framework is not started, this method will:   * <ol>   * <li>Enable event handling. At this point, events can be delivered to   * listeners.</li>   * <li>Attempt to start all bundles marked for starting as described in the   * {@link Bundle#start} method.   * Reports any exceptions that occur during startup using   * <code>FrameworkErrorEvents</code>.</li>   * <li>Set the state of the Framework to <i>active</i>.</li>   * <li>Broadcasting a <code>FrameworkEvent</code> through the   * <code>FrameworkListener.frameworkStarted</code> method.</li>   * </ol></p>   *   * <p>If this Framework is not launched, it can still install,   * uninstall, start and stop bundles.  (It does these tasks without   * broadcasting events, however.)  Using Framework without launching   * it allows for off-line debugging of the Framework.</p>   *   * @param startBundle If it is specified with a value larger than 0,   *                    then the bundle with that id is started.   *                    Otherwise start all suspended bundles.   */  public void launch(long startBundle) throws BundleException {    if (!active) {      active = true;      if (startBundle > 0) {	startBundle(startBundle);      } else {	for (Iterator i = storage.getStartOnLaunchBundles().iterator(); i.hasNext(); ) {	  Bundle b = bundles.getBundle((String)i.next());	  try {	    b.start();	  } catch (BundleException be) {	    listeners.frameworkError(b, be);	  }	}      }      systemBundle.systemActive();      // start level open is delayed to this point to       // correctly work at restart      if(startLevelService != null) {        startLevelService.open();      }      listeners.frameworkEvent(new FrameworkEvent(FrameworkEvent.STARTED, systemBundle, null));    }  }  /**   * Stop this Framework, suspending all started contexts.   * This method suspends all started contexts so that they can be   * automatically restarted when this Framework is next launched.   *   * <p>If the framework is not started, this method does nothing.   * If the framework is started, this method will:   * <ol>   * <li>Set the state of the Framework to <i>inactive</i>.</li>   * <li>Suspended all started bundles as described in the   * {@link Bundle#stop} method except that the persistent   * state of the bundle will continue to be started.   * Reports any exceptions that occur during stopping using   * <code>FrameworkErrorEvents</code>.</li>   * <li>Disable event handling.</li>   * </ol></p>   *   */  public void shutdown() {    if (active) {      // No shuttingdown event specified      // listeners.frameworkChanged(new FrameworkEvent(FrameworkEvent.SHUTTING_DOWN));      active = false;      List slist = storage.getStartOnLaunchBundles();      shuttingdown = true;      if(startLevelService != null) {	startLevelService.close();      }      systemBundle.systemShuttingdown();      // Stop bundles, in reverse start order      for (int i = slist.size()-1; i >= 0; i--) {	Bundle b = bundles.getBundle((String)slist.get(i));	try {	  if(b != null) {	    synchronized (b) {	      if (b.getState() == Bundle.ACTIVE) {		b.stop();	      }	    }	  }	} catch (BundleException be) {	  listeners.frameworkEvent(new FrameworkEvent(FrameworkEvent.ERROR, b, be));	}      }      shuttingdown = false;       // Purge any unrefreshed bundles      BundleImpl [] all = bundles.getBundles();      for (int i = 0; i < all.length; i++) {	all[i].purge();      }    }  }  /**   * Install a bundle from the given location.   *   * @param location The location identifier of the bundle to install.   * @param in The InputStream from which the bundle will be read.   * @return The BundleImpl object of the installed bundle.   * @exception BundleException If the install failed.   */  public long installBundle(String location, InputStream in) throws BundleException {    return bundles.install(location, in).id;  }  /**   * Start a bundle.   *   * @param id Id of bundle to start.   * @exception BundleException If start failed.   */  public void startBundle(long id) throws BundleException {    BundleImpl b = bundles.getBundle(id);    if (b != null) {      b.start();    } else {      throw new BundleException("No such bundle: " + id);    }  }  /**   * Stop a bundle.   *   * @param id Id of bundle to stop.   * @exception BundleException If stop failed.   */  public void stopBundle(long id) throws BundleException {    BundleImpl b = bundles.getBundle(id);    if (b != null) {      b.stop();    } else {      throw new BundleException("No such bundle: " + id);    }  }  /**   * Uninstall a bundle.   *   * @param id Id of bundle to stop.   * @exception BundleException If uninstall failed.   */  public void uninstallBundle(long id) throws BundleException {    BundleImpl b = bundles.getBundle(id);    if (b != null) {      b.uninstall();    } else {      throw new BundleException("No such bundle: " + id);    }  }  /**   * Update a bundle.   *   * @param id Id of bundle to update.   * @exception BundleException If update failed.   */  public void updateBundle(long id) throws BundleException {    BundleImpl b = bundles.getBundle(id);    if (b != null) {      b.update();    } else {      throw new BundleException("No such bundle: " + id);    }  }  /**   * Retrieve location of the bundle that has the given   * unique identifier.   *   * @param id The identifier of the bundle to retrieve.   * @return A location as a string, or <code>null</code>   * if the identifier doesn't match any installed bundle.   */  public String getBundleLocation(long id) {    BundleImpl b = bundles.getBundle(id);    if (b != null) {      return b.location;    } else {      return null;    }  }  /**   * Retrieve bundle id of the bundle that has the given   * unique location.   *   * @param location The location of the bundle to retrieve.   * @return The unique identifier of the bundle, or <code>-1</code>   * if the location doesn't match any installed bundle.   */  public long getBundleId(String location) {    BundleImpl b = bundles.getBundle(location);    if (b != null) {      return b.id;    } else {      return -1;    }  }  /**   * Check that we have admin permission.   *   * @exception SecurityException if we don't have admin permission.   */  void checkAdminPermission() {    if (bPermissions) {      AccessController.checkPermission(ADMIN_PERMISSION);    }  }  /**   * Get private bundle data storage file handle.   */  FileTree getDataStorage() {    return dataStorage;  }  /**   * Check if an execution environment string is accepted   */  boolean isValidEE(String ee) {    if(ee == null || "".equals(ee)) {      return true;    }    String fwEE = System.getProperty(Constants.FRAMEWORK_EXECUTIONENVIRONMENT);    if(fwEE == null) {      eeCacheSet.clear();    } else {      if(!fwEE.equals(eeCache)) {	eeCacheSet.clear();	String[] l = Util.splitwords(fwEE, ",", '\"');	for(int i = 0 ; i < l.length; i++) {	  eeCacheSet.add(l[i]);	}      }    }    eeCache = fwEE;    String[] eel   = Util.splitwords(ee, ",", '\"');        for(int i = 0 ; i < eel.length; i++) {      if(eeCacheSet.contains(eel[i])) {	return true;      }    }    return false;  }  // Cached value of   // System.getProperty(Constants.FRAMEWORK_EXECUTIONENVIRONMENT)  // Used and updated by isValidEE()  Set    eeCacheSet = new HashSet();  String eeCache = null;  //  // Static package methods  //  /**   * Retrieve the value of the named framework property.   *   */  public static String getProperty(String key) {    if (Constants.FRAMEWORK_VERSION.equals(key)) {      // The version of the framework.       return SPEC_VERSION;    } else if (Constants.FRAMEWORK_VENDOR.equals(key)) {      // The vendor of this framework implementation.       return "Knopflerfish";    } else if (Constants.FRAMEWORK_LANGUAGE.equals(key)) {      // The language being used. See ISO 639 for possible values.       return Locale.getDefault().getLanguage();    } else if (Constants.FRAMEWORK_OS_NAME.equals(key)) {      // The name of the operating system of the hosting computer.       return osName;    } else if (Constants.FRAMEWORK_OS_VERSION.equals(key)) {      // The version number of the operating system of the hosting computer.       return osVersion;    } else if (Constants.FRAMEWORK_PROCESSOR.equals(key)) {      // The name of the processor of the hosting computer.       return osArch;    } else if (Constants.FRAMEWORK_EXECUTIONENVIRONMENT.equals(key)) {      // The name of the fw execution environment      return System.getProperty(Constants.FRAMEWORK_EXECUTIONENVIRONMENT);    } else {      return System.getProperty(key);    }  }  /**   * Get the bundle context used by the system bundle.   */  public BundleContext getSystemBundleContext() {    return (BundleContext)      AccessController.doPrivileged(new  PrivilegedAction() {	  public Object run() {	    return systemBC;	  }});  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -