Package org.eclipse.osgi.framework.util

Examples of org.eclipse.osgi.framework.util.Headers


    ResourceBundle localeProperties = getResourceBundle(localeString);
    if (localeProperties == null && !isDefaultLocale)
      // could not find the requested locale use the default locale
      localeProperties = getResourceBundle(defaultLocale);
    Enumeration e = this.rawHeaders.keys();
    Headers localeHeaders = new Headers(this.rawHeaders.size());
    while (e.hasMoreElements()) {
      String key = (String) e.nextElement();
      String value = (String) this.rawHeaders.get(key);
      if (value.startsWith("%") && (value.length() > 1)) { //$NON-NLS-1$
        String propertiesKey = value.substring(1);
        try {
          value = localeProperties == null ? propertiesKey : (String) localeProperties.getObject(propertiesKey);
        } catch (MissingResourceException ex) {
          value = propertiesKey;
        }
      }
      localeHeaders.set(key, value);
    }
    localeHeaders.setReadOnly();
    if (isDefaultLocale) {
      defaultLocaleHeaders = localeHeaders;
    }
    return (localeHeaders);
  }
View Full Code Here


        if (cp[i].getFile().endsWith("/")) { //$NON-NLS-1$
          manifest = new URL(cp[i], org.eclipse.osgi.framework.internal.core.Constants.OSGI_BUNDLE_MANIFEST).openStream();
        } else {
          manifest = new URL("jar:" + cp[i].toExternalForm() + "!/" + org.eclipse.osgi.framework.internal.core.Constants.OSGI_BUNDLE_MANIFEST).openStream(); //$NON-NLS-1$ //$NON-NLS-2$
        }
        Map headers = ManifestElement.parseBundleManifest(manifest, new Headers(10));
        String bsnSpec = getValue(headers, Constants.BUNDLE_SYMBOLICNAME);
        if (bsnSpec == null)
          continue;
        String internalBSN = org.eclipse.osgi.framework.internal.core.Constants.getInternalSymbolicName();
        if (internalBSN.equals(bsnSpec)) {
View Full Code Here

      Enumeration manifests = cl != null ? cl.getResources(Constants.OSGI_BUNDLE_MANIFEST) : ClassLoader.getSystemResources(Constants.OSGI_BUNDLE_MANIFEST);
      while (manifests.hasMoreElements()) {
        URL url = (URL) manifests.nextElement();
        try {
          // check each manifest until we find one with the Eclipse-SystemBundle: true header
          Headers headers = Headers.parseManifest(url.openStream());
          if ("true".equals(headers.get(Constants.ECLIPSE_SYSTEMBUNDLE))) //$NON-NLS-1$
            return url.openStream();
        } catch (BundleException e) {
          // ignore and continue to next URL
        }
      }
View Full Code Here

   * @throws IllegalArgumentException If <code>dictionary</code> contains
   *         case variants of the same key name.
   */
  public boolean match(Dictionary dictionary) {
    if (dictionary != null) {
      dictionary = new Headers(dictionary);
    }

    return match0(dictionary);
  }
View Full Code Here

        FrameworkLogEntry entry = new FrameworkLogEntry(FrameworkAdaptor.FRAMEWORK_SYMBOLICNAME, FrameworkLogEntry.ERROR, 0, message, 0, e, null);
        storageHook.getAdaptor().getFrameworkLog().log(entry);
        return null;
      }
    if (manifest == null) {
      Headers empty = new Headers(0);
      empty.setReadOnly();
      manifest = empty;
      return empty;
    }
    return manifest;
  }
View Full Code Here

    }
    return false;
  }

  private Headers checkManifestAndParent(String cacheLocation, String symbolicName, String version, byte inputType) throws BundleException {
    Headers result = basicCheckManifest(cacheLocation, symbolicName, version, inputType);
    if (result != null)
      return result;
    Location parentConfiguration = null;
    if ((parentConfiguration = LocationManager.getConfigurationLocation().getParentLocation()) != null)
      result = basicCheckManifest(new File(parentConfiguration.getURL().getFile(), FrameworkAdaptor.FRAMEWORK_SYMBOLICNAME + '/' + LocationManager.MANIFESTS_DIR).toString(), symbolicName, version, inputType);
View Full Code Here

  }

  private Dictionary generateManifest(Dictionary builtIn) throws BundleException {
    String cacheLocation = FrameworkProperties.getProperty(LocationManager.PROP_MANIFEST_CACHE);
    if (bundledata.getSymbolicName() != null) {
      Headers existingHeaders = checkManifestAndParent(cacheLocation, bundledata.getSymbolicName(), bundledata.getVersion().toString(), manifestType);
      if (existingHeaders != null)
        return existingHeaders;
    }

    PluginConverterImpl converter = PluginConverterImpl.getDefault();
    if (converter == null)
      converter = new PluginConverterImpl(bundledata.getAdaptor(), bundledata.getAdaptor().getContext());

    Dictionary generatedManifest;
    try {
      generatedManifest = converter.convertManifest(bundledata.getBundleFile().getBaseFile(), true, null, true, null);
    } catch (PluginConversionException pce) {
      String message = NLS.bind(EclipseAdaptorMsg.ECLIPSE_CONVERTER_ERROR_CONVERTING, bundledata.getBundleFile().getBaseFile());
      throw new BundleException(message, BundleException.MANIFEST_ERROR, pce);
    }

    //Now we know the symbolicId and the version of the bundle, we check to see if don't have a manifest for it already
    Version version = Version.parseVersion((String) generatedManifest.get(Constants.BUNDLE_VERSION));
    String symbolicName = ManifestElement.parseHeader(org.osgi.framework.Constants.BUNDLE_SYMBOLICNAME, (String) generatedManifest.get(org.osgi.framework.Constants.BUNDLE_SYMBOLICNAME))[0].getValue();
    ManifestElement generatedFrom = ManifestElement.parseHeader(PluginConverterImpl.GENERATED_FROM, (String) generatedManifest.get(PluginConverterImpl.GENERATED_FROM))[0];
    Headers existingHeaders = checkManifestAndParent(cacheLocation, symbolicName, version.toString(), Byte.parseByte(generatedFrom.getAttribute(PluginConverterImpl.MANIFEST_TYPE_ATTRIBUTE)));
    //We don't have a manifest.
    manifestTimeStamp = Long.parseLong(generatedFrom.getValue());
    manifestType = Byte.parseByte(generatedFrom.getAttribute(PluginConverterImpl.MANIFEST_TYPE_ATTRIBUTE));
    if (bundledata.getAdaptor().isReadOnly() || existingHeaders != null)
      return existingHeaders;
View Full Code Here

      Enumeration manifests = cl != null ? cl.getResources(Constants.OSGI_BUNDLE_MANIFEST) : ClassLoader.getSystemResources(Constants.OSGI_BUNDLE_MANIFEST);
      while (manifests.hasMoreElements()) {
        URL url = (URL) manifests.nextElement();
        try {
          // check each manifest until we find one with the Eclipse-SystemBundle: true header
          Headers headers = Headers.parseManifest(url.openStream());
          if ("true".equals(headers.get(Constants.ECLIPSE_SYSTEMBUNDLE))) //$NON-NLS-1$
            return url.openStream();
        } catch (BundleException e) {
          // ignore and continue to next URL
        }
      }
View Full Code Here

   * @return <code>true</code> if the Dictionary's keys match this filter;
   * <code>false</code> otherwise.
   */
  public boolean match(Dictionary dictionary) {
    if (dictionary != null) {
      dictionary = new Headers(dictionary);
    }

    return match0(dictionary);
  }
View Full Code Here

    }
    return false;
  }

  private Headers checkManifestAndParent(String cacheLocation, String symbolicName, String version, byte inputType) throws BundleException {
    Headers result = basicCheckManifest(cacheLocation, symbolicName, version, inputType);
    if (result != null)
      return result;
    Location parentConfiguration = null;
    if ((parentConfiguration = LocationManager.getConfigurationLocation().getParentLocation()) != null)
      result = basicCheckManifest(new File(parentConfiguration.getURL().getFile(), FrameworkAdaptor.FRAMEWORK_SYMBOLICNAME + '/' + LocationManager.MANIFESTS_DIR).toString(), symbolicName, version, inputType);
View Full Code Here

TOP

Related Classes of org.eclipse.osgi.framework.util.Headers

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.