Пример #1
0
  private void addJREPackageCapabilities(Resolver resolver, EE ee) throws IOException {
    // EE Package Capabilities
    Properties pkgProps = new Properties();
    URL pkgsResource = ResolveOperation.class.getResource(ee.name() + ".properties");
    if (pkgsResource == null)
      throw new IOException(
          String.format(
              "No JRE package definition available for Execution Env %s.", ee.getEEName()));

    InputStream stream = null;
    try {
      stream = pkgsResource.openStream();
      pkgProps.load(stream);
    } finally {
      if (stream != null) IO.close(stream);
    }
    String pkgsStr = pkgProps.getProperty(Constants.FRAMEWORK_SYSTEMPACKAGES);

    Map<String, Map<String, String>> header = OSGiHeader.parseHeader(pkgsStr);
    for (Entry<String, Map<String, String>> entry : header.entrySet()) {
      String pkgName = Processor.removeDuplicateMarker(entry.getKey());
      String version = entry.getValue().get(Constants.VERSION_ATTRIBUTE);

      Map<String, String> capabilityProps = new HashMap<String, String>();
      capabilityProps.put(ObrConstants.FILTER_PACKAGE, pkgName);
      if (version != null) capabilityProps.put(ObrConstants.FILTER_VERSION, version);

      Capability capability = helper.capability(ObrConstants.REQUIREMENT_PACKAGE, capabilityProps);
      resolver.addGlobalCapability(capability);
    }
  }
Пример #2
0
  private File findFramework(MultiStatus status) {
    String runFramework = model.getRunFramework();
    Map<String, Map<String, String>> header = OSGiHeader.parseHeader(runFramework);
    if (header.size() != 1) {
      status.add(
          new Status(
              IStatus.ERROR,
              Plugin.PLUGIN_ID,
              0,
              "Invalid format for " + BndConstants.RUNFRAMEWORK + " header",
              null));
      return null;
    }

    Entry<String, Map<String, String>> entry = header.entrySet().iterator().next();
    VersionedClause clause = new VersionedClause(entry.getKey(), entry.getValue());

    String versionRange = clause.getVersionRange();
    if (versionRange == null) versionRange = new Version(0, 0, 0).toString();

    try {
      Container container =
          getProject().getBundle(clause.getName(), versionRange, Strategy.HIGHEST, null);
      if (container.getType() == TYPE.ERROR) {
        status.add(
            new Status(
                IStatus.ERROR,
                Plugin.PLUGIN_ID,
                0,
                "Unable to find specified OSGi framework: " + container.getError(),
                null));
        return null;
      }
      return container.getFile();
    } catch (Exception e) {
      status.add(
          new Status(
              IStatus.ERROR,
              Plugin.PLUGIN_ID,
              0,
              "Error while trying to find the specified OSGi framework.",
              e));
      return null;
    }
  }