public String get(Object key) { if (!(key instanceof String)) return null; String sKey = (String) key; if (Constants.EXPORT_PACKAGE.equalsIgnoreCase(sKey) || Constants.PROVIDE_CAPABILITY.equalsIgnoreCase(sKey)) { String systemProvideHeader = getEquinoxContainer() .getConfiguration() .getConfiguration( EquinoxConfiguration.PROP_SYSTEM_PROVIDE_HEADER, EquinoxConfiguration.SYSTEM_PROVIDE_HEADER_SYSTEM_EXTRA); boolean useSystemExtra = systemProvideHeader.equals(EquinoxConfiguration.SYSTEM_PROVIDE_HEADER_SYSTEM_EXTRA); boolean useSystem = systemProvideHeader.equals(EquinoxConfiguration.SYSTEM_PROVIDE_HEADER_SYSTEM) || useSystemExtra; String systemProp = useSystem ? (Constants.EXPORT_PACKAGE.equalsIgnoreCase(sKey) ? Constants.FRAMEWORK_SYSTEMPACKAGES : Constants.FRAMEWORK_SYSTEMCAPABILITIES) : null; String systemExtraProp = useSystemExtra ? (Constants.EXPORT_PACKAGE.equalsIgnoreCase(sKey) ? Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA : Constants.FRAMEWORK_SYSTEMCAPABILITIES_EXTRA) : null; return getExtra(sKey, systemProp, systemExtraProp); } return headers.get(key); }
private String getExtra(String header, String systemProp, String systemExtraProp) { String systemValue = systemProp != null ? getEquinoxContainer().getConfiguration().getConfiguration(systemProp) : null; String systemExtraValue = systemExtraProp != null ? getEquinoxContainer().getConfiguration().getConfiguration(systemExtraProp) : null; if (systemValue == null) systemValue = systemExtraValue; else if (systemExtraValue != null && systemExtraValue.trim().length() > 0) systemValue += ", " + systemExtraValue; // $NON-NLS-1$ String result = headers.get(header); if (systemValue != null && systemValue.trim().length() > 0) { if (result != null) result += ", " + systemValue; // $NON-NLS-1$ else result = systemValue; } return result; }
public int size() { return headers.size(); }
public Enumeration<String> elements() { return headers.elements(); }
public String remove(Object key) { return headers.remove(key); }
public String put(String key, String value) { return headers.put(key, value); }
public Enumeration<String> keys() { return headers.keys(); }
public boolean isEmpty() { return headers.isEmpty(); }
private BundleResourceBundle lookupResourceBundle(String localeString) { // get the localization header as late as possible to avoid accessing the raw headers // getting the first value from the raw headers forces the manifest to be parsed (bug 332039) String localizationHeader = rawHeaders.get(Constants.BUNDLE_LOCALIZATION); if (localizationHeader == null) localizationHeader = Constants.BUNDLE_LOCALIZATION_DEFAULT_BASENAME; BundleResourceBundle result = cache.get(localeString); if (result != null) return result.isEmpty() ? null : result; // Collect all the necessary inputstreams to create the resource bundle without // holding any locks. Finding resources and inputstreams from the wirings requires a // read lock on the module database. We must not hold the cache lock while doing this; // otherwise out of order locks will be possible when the resolver needs to clear the cache String[] nlVarients = buildNLVariants(localeString); InputStream[] nlStreams = new InputStream[nlVarients.length]; for (int i = nlVarients.length - 1; i >= 0; i--) { URL url = findResource( localizationHeader + (nlVarients[i].equals("") ? nlVarients[i] : '_' + nlVarients[i]) + ".properties"); //$NON-NLS-1$ //$NON-NLS-2$ if (url != null) { try { nlStreams[i] = url.openStream(); } catch (IOException e) { // ignore } } } synchronized (cache) { BundleResourceBundle parent = null; for (int i = nlVarients.length - 1; i >= 0; i--) { BundleResourceBundle varientBundle = null; InputStream varientStream = nlStreams[i]; if (varientStream == null) { varientBundle = cache.get(nlVarients[i]); } else { try { varientBundle = new LocalizationResourceBundle(varientStream); } catch (IOException e) { // ignore and continue } finally { if (varientStream != null) { try { varientStream.close(); } catch (IOException e3) { // Ignore exception } } } } if (varientBundle == null) { varientBundle = new EmptyResouceBundle(nlVarients[i]); } if (parent != null) varientBundle.setParent((ResourceBundle) parent); cache.put(nlVarients[i], varientBundle); parent = varientBundle; } result = cache.get(localeString); return result.isEmpty() ? null : result; } }