コード例 #1
0
  public BundleInfo[] loadConfiguration(BundleContext context, String infoPath) throws IOException {
    URI installArea = EquinoxUtils.getInstallLocationURI(context);

    URL configURL = null;
    InputStream stream = null;

    if (infoPath == null) {
      SimpleConfiguratorImpl simpleImpl = new SimpleConfiguratorImpl(context, null);
      configURL = simpleImpl.getConfigurationURL();
    } else {
      // == (not .equals) use the default source info, currently SOURCE_INFO_PATH
      boolean defaultSource = (infoPath == SOURCE_INFO);
      if (defaultSource) infoPath = SOURCE_INFO_PATH;

      Location configLocation = EquinoxUtils.getConfigLocation(context);
      configURL = configLocation.getDataArea(infoPath);
      try {
        stream = configURL.openStream();
      } catch (FileNotFoundException e) {
        if (defaultSource && configLocation.getParentLocation() != null) {
          configURL = configLocation.getParentLocation().getDataArea(infoPath);
        } else {
          return new BundleInfo[0];
        }
      }
    }
    if (configURL == null) return new BundleInfo[0];
    else if (stream == null) {
      try {
        stream = configURL.openStream();
      } catch (FileNotFoundException e) {
        return new BundleInfo[0];
      }
    }

    // stream will be closed
    return loadConfiguration(stream, installArea);
  }