예제 #1
0
  /**
   * Return the set of <code>Extension</code> objects representing optional packages that are
   * required by the application associated with the specified <code>Manifest</code>.
   *
   * @param manifest Manifest to be parsed
   * @return List of required extensions, or null if the application does not require any extensions
   */
  private ArrayList<Extension> getRequiredExtensions(Manifest manifest) {

    Attributes attributes = manifest.getMainAttributes();
    String names = attributes.getValue("Extension-List");
    if (names == null) return null;

    ArrayList<Extension> extensionList = new ArrayList<Extension>();
    names += " ";

    while (true) {

      int space = names.indexOf(' ');
      if (space < 0) break;
      String name = names.substring(0, space).trim();
      names = names.substring(space + 1);

      String value = attributes.getValue(name + "-Extension-Name");
      if (value == null) continue;
      Extension extension = new Extension();
      extension.setExtensionName(value);
      extension.setImplementationURL(attributes.getValue(name + "-Implementation-URL"));
      extension.setImplementationVendorId(attributes.getValue(name + "-Implementation-Vendor-Id"));
      String version = attributes.getValue(name + "-Implementation-Version");
      extension.setImplementationVersion(version);
      extension.setSpecificationVersion(attributes.getValue(name + "-Specification-Version"));
      extensionList.add(extension);
    }
    return extensionList;
  }
예제 #2
0
  /**
   * Return the set of <code>Extension</code> objects representing optional packages that are
   * bundled with the application associated with the specified <code>Manifest</code>.
   *
   * @param manifest Manifest to be parsed
   * @return List of available extensions, or null if the web application does not bundle any
   *     extensions
   */
  private ArrayList<Extension> getAvailableExtensions(Manifest manifest) {

    Attributes attributes = manifest.getMainAttributes();
    String name = attributes.getValue("Extension-Name");
    if (name == null) return null;

    ArrayList<Extension> extensionList = new ArrayList<Extension>();

    Extension extension = new Extension();
    extension.setExtensionName(name);
    extension.setImplementationURL(attributes.getValue("Implementation-URL"));
    extension.setImplementationVendor(attributes.getValue("Implementation-Vendor"));
    extension.setImplementationVendorId(attributes.getValue("Implementation-Vendor-Id"));
    extension.setImplementationVersion(attributes.getValue("Implementation-Version"));
    extension.setSpecificationVersion(attributes.getValue("Specification-Version"));

    extensionList.add(extension);

    return extensionList;
  }