diff options
author | Thomas Watson | 2012-09-12 19:18:32 +0000 |
---|---|---|
committer | Thomas Watson | 2012-09-12 19:18:32 +0000 |
commit | 2d5349b00ba24c3011a69ad85e61daebd23691cb (patch) | |
tree | b6747a594f836a4d7747ba10a4d57848321dbc6a | |
parent | 070f711dd9283feb6d47d06990a6f5fc0c7d0c8f (diff) | |
download | rt.equinox.framework-2d5349b00ba24c3011a69ad85e61daebd23691cb.tar.gz rt.equinox.framework-2d5349b00ba24c3011a69ad85e61daebd23691cb.tar.xz rt.equinox.framework-2d5349b00ba24c3011a69ad85e61daebd23691cb.zip |
Change native environment namespace to use fully qualified attributes. Also have the capability provide the aliases not the requirement.
-rw-r--r-- | bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/builders/OSGiManifestBuilderFactory.java | 46 | ||||
-rw-r--r-- | bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/namespaces/EquinoxNativeEnvironmentNamespace.java (renamed from bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/namespaces/EquinoxNativeCodeNamespace.java) | 22 | ||||
-rw-r--r-- | bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/AliasMapper.java | 135 | ||||
-rw-r--r-- | bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxConfiguration.java | 16 | ||||
-rw-r--r-- | bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/OSGiFrameworkHooks.java | 6 | ||||
-rw-r--r-- | bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/NativeCodeFinder.java | 6 | ||||
-rw-r--r-- | bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java | 32 |
7 files changed, 128 insertions, 135 deletions
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/builders/OSGiManifestBuilderFactory.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/builders/OSGiManifestBuilderFactory.java index 4f604a97e..60ce2aca2 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/builders/OSGiManifestBuilderFactory.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/builders/OSGiManifestBuilderFactory.java @@ -757,23 +757,23 @@ public final class OSGiManifestBuilderFactory { allFilters.append(filter.toString()); Map<String, String> directives = new HashMap<String, String>(3); - directives.put(EquinoxNativeCodeNamespace.REQUIREMENT_FILTER_DIRECTIVE, filter.toString()); - directives.put(EquinoxNativeCodeNamespace.REQUIREMENT_RESOLUTION_DIRECTIVE, EquinoxNativeCodeNamespace.RESOLUTION_OPTIONAL); + directives.put(EquinoxNativeEnvironmentNamespace.REQUIREMENT_FILTER_DIRECTIVE, filter.toString()); + directives.put(EquinoxNativeEnvironmentNamespace.REQUIREMENT_RESOLUTION_DIRECTIVE, EquinoxNativeEnvironmentNamespace.RESOLUTION_OPTIONAL); String selectionFilter = nativeCode.getAttribute(Constants.SELECTION_FILTER_ATTRIBUTE); if (selectionFilter != null) { allSelectionFilters.add(selectionFilter); - directives.put(EquinoxNativeCodeNamespace.REQUIREMENT_SELECTION_FILTER_DIRECTIVE, selectionFilter); + directives.put(EquinoxNativeEnvironmentNamespace.REQUIREMENT_SELECTION_FILTER_DIRECTIVE, selectionFilter); } Map<String, Object> attributes = new HashMap<String, Object>(2); - attributes.put(EquinoxNativeCodeNamespace.REQUIREMENT_NATIVE_PATHS_ATTRIBUTE, nativePaths); - builder.addRequirement(EquinoxNativeCodeNamespace.EQUINOX_NATIVECODE_NAMESPACE, directives, attributes); + attributes.put(EquinoxNativeEnvironmentNamespace.REQUIREMENT_NATIVE_PATHS_ATTRIBUTE, nativePaths); + builder.addRequirement(EquinoxNativeEnvironmentNamespace.NATIVE_ENVIRONMENT_NAMESPACE, directives, attributes); } allFilters.append(')'); if (!optional) { Map<String, String> directives = new HashMap<String, String>(2); - directives.put(EquinoxNativeCodeNamespace.REQUIREMENT_FILTER_DIRECTIVE, allFilters.toString()); + directives.put(EquinoxNativeEnvironmentNamespace.REQUIREMENT_FILTER_DIRECTIVE, allFilters.toString()); if (!allSelectionFilters.isEmpty()) { StringBuilder selectionFilter = new StringBuilder(); selectionFilter.append("(|"); //$NON-NLS-1$ @@ -781,9 +781,9 @@ public final class OSGiManifestBuilderFactory { selectionFilter.append(filter); } selectionFilter.append(")"); //$NON-NLS-1$ - directives.put(EquinoxNativeCodeNamespace.REQUIREMENT_SELECTION_FILTER_DIRECTIVE, selectionFilter.toString()); + directives.put(EquinoxNativeEnvironmentNamespace.REQUIREMENT_SELECTION_FILTER_DIRECTIVE, selectionFilter.toString()); } - builder.addRequirement(EquinoxNativeCodeNamespace.EQUINOX_NATIVECODE_NAMESPACE, directives, Collections.<String, Object> emptyMap()); + builder.addRequirement(EquinoxNativeEnvironmentNamespace.NATIVE_ENVIRONMENT_NAMESPACE, directives, Collections.<String, Object> emptyMap()); } } @@ -792,40 +792,28 @@ public final class OSGiManifestBuilderFactory { Collection<String> attrAliases = new HashSet<String>(1); if (attrValues != null) { for (String attrValue : attrValues) { - Object aliasedName = null; - if (Constants.BUNDLE_NATIVECODE_OSNAME.equals(attribute)) { - aliasedName = aliasMapper.aliasOSName(attrValue); - } else if (Constants.BUNDLE_NATIVECODE_PROCESSOR.equals(attribute)) { - aliasedName = aliasMapper.aliasProcessor(attrValue); - } - - if (aliasedName == null) { - attrAliases.add(attrValue); - } else if (aliasedName instanceof String) { - attrAliases.add(aliasedName.toString().toLowerCase()); - } else { - for (Iterator<?> iAliases = ((Collection<?>) aliasedName).iterator(); iAliases.hasNext();) { - attrAliases.add(iAliases.next().toString().toLowerCase()); - } + if (Constants.BUNDLE_NATIVECODE_OSNAME.equals(attribute) || Constants.BUNDLE_NATIVECODE_PROCESSOR.equals(attribute)) { + attrValue = attrValue.toLowerCase(); } + attrAliases.add(attrValue); } } String filterAttribute = attribute; if (Constants.BUNDLE_NATIVECODE_OSNAME.equals(attribute)) { - filterAttribute = EquinoxNativeCodeNamespace.CAPABILITY_OS_NAME_ATTRIBUTE; + filterAttribute = EquinoxNativeEnvironmentNamespace.CAPABILITY_OS_NAME_ATTRIBUTE; } else if (Constants.BUNDLE_NATIVECODE_PROCESSOR.equals(attribute)) { - filterAttribute = EquinoxNativeCodeNamespace.CAPABILITY_PROCESSOR_ATTRIBUTE; + filterAttribute = EquinoxNativeEnvironmentNamespace.CAPABILITY_PROCESSOR_ATTRIBUTE; } else if (Constants.BUNDLE_NATIVECODE_LANGUAGE.equals(attribute)) { - filterAttribute = EquinoxNativeCodeNamespace.CAPABILITY_LANGUAGE_ATTRIBUTE; + filterAttribute = EquinoxNativeEnvironmentNamespace.CAPABILITY_LANGUAGE_ATTRIBUTE; } else if (Constants.BUNDLE_NATIVECODE_OSVERSION.equals(attribute)) { - filterAttribute = EquinoxNativeCodeNamespace.CAPABILITY_OS_VERSION_ATTRIBUTE; + filterAttribute = EquinoxNativeEnvironmentNamespace.CAPABILITY_OS_VERSION_ATTRIBUTE; } if (attrAliases.size() > 1) { filter.append("(|"); //$NON-NLS-1$ } for (String attrAlias : attrAliases) { - if (EquinoxNativeCodeNamespace.CAPABILITY_OS_VERSION_ATTRIBUTE.equals(attribute)) { - filter.append(new VersionRange(attrAlias).toFilterString(attribute)); + if (EquinoxNativeEnvironmentNamespace.CAPABILITY_OS_VERSION_ATTRIBUTE.equals(filterAttribute)) { + filter.append(new VersionRange(attrAlias).toFilterString(filterAttribute)); } else { filter.append('(').append(filterAttribute).append('=').append(attrAlias).append(')'); } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/namespaces/EquinoxNativeCodeNamespace.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/namespaces/EquinoxNativeEnvironmentNamespace.java index 45ba96db2..3219b584b 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/namespaces/EquinoxNativeCodeNamespace.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/namespaces/EquinoxNativeEnvironmentNamespace.java @@ -27,39 +27,39 @@ import org.osgi.resource.Namespace; * @noinstantiate This class is not intended to be instantiated by clients. * @since 3.10 */ -public class EquinoxNativeCodeNamespace extends Namespace { +public class EquinoxNativeEnvironmentNamespace extends Namespace { /** - * Namespace name for native code. Unlike typical name spaces + * Namespace name for native environment. Unlike typical name spaces * this namespace is not intended to be used as an attribute. */ - public static final String EQUINOX_NATIVECODE_NAMESPACE = "equinox.native.code"; //$NON-NLS-1$ + public static final String NATIVE_ENVIRONMENT_NAMESPACE = "equinox.native.environment"; //$NON-NLS-1$ /** - * Specifies the supported canonical name for the environment OS. + * Specifies the supported canonical names for the environment OS. * All names are lower case. - * The value of this attribute must be of type {@code String}. + * The value of this attribute must be of type {@code List<String>}. */ - public static final String CAPABILITY_OS_NAME_ATTRIBUTE = "osname"; //$NON-NLS-1$ + public static final String CAPABILITY_OS_NAME_ATTRIBUTE = NATIVE_ENVIRONMENT_NAMESPACE + ".osname"; //$NON-NLS-1$ /** * Specifies the environment OS version. * The value of this attribute must be of type {@code Version}. */ - public static final String CAPABILITY_OS_VERSION_ATTRIBUTE = "osversion"; //$NON-NLS-1$ + public static final String CAPABILITY_OS_VERSION_ATTRIBUTE = NATIVE_ENVIRONMENT_NAMESPACE + ".osversion"; //$NON-NLS-1$ /** - * Specifies the canonical name for the environment processor. The value + * Specifies the canonical names for the environment processor. The value * is lower case. - * The value of this attribute must be of type {@code String}. + * The value of this attribute must be of type {@code List<String>}. */ - public static final String CAPABILITY_PROCESSOR_ATTRIBUTE = "processor"; //$NON-NLS-1$ + public static final String CAPABILITY_PROCESSOR_ATTRIBUTE = NATIVE_ENVIRONMENT_NAMESPACE + ".processor"; //$NON-NLS-1$ /** * Specifies the language supported by the environment. The value * of this attribute must be of type {@code String}. */ - public static final String CAPABILITY_LANGUAGE_ATTRIBUTE = "language"; //$NON-NLS-1$ + public static final String CAPABILITY_LANGUAGE_ATTRIBUTE = NATIVE_ENVIRONMENT_NAMESPACE + ".language"; //$NON-NLS-1$ /** * Specifies the paths to the native libraries for the native code requirement. If this diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/AliasMapper.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/AliasMapper.java index ed8cd9e9a..1cf09526c 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/AliasMapper.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/AliasMapper.java @@ -19,45 +19,28 @@ import org.eclipse.osgi.internal.debug.Debug; * This class maps aliases. */ public class AliasMapper { - private static Map<String, Object> processorAliasTable; - private static Map<String, Object> osnameAliasTable; - - // Safe lazy initialization - private static synchronized Map<String, Object> getProcessorAliasTable() { - if (processorAliasTable == null) { - InputStream in = AliasMapper.class.getResourceAsStream("processor.aliases"); //$NON-NLS-1$ - if (in != null) { - try { - processorAliasTable = initAliases(in); - } finally { - try { - in.close(); - } catch (IOException ee) { - // nothing - } - } - } - } - return processorAliasTable; + private static final Map<String, Collection<String>> processorAliasTable = new HashMap<String, Collection<String>>(); + private static final Map<String, String> processorCanonicalTable = new HashMap<String, String>(); + private static final Map<String, Collection<String>> osnameAliasTable = new HashMap<String, Collection<String>>(); + private static final Map<String, String> osnameCanonicalTable = new HashMap<String, String>(); + static { + getTables("osname.aliases", osnameAliasTable, osnameCanonicalTable); //$NON-NLS-1$ + getTables("processor.aliases", processorAliasTable, processorCanonicalTable); //$NON-NLS-1$ } - // Safe lazy initialization - private static synchronized Map<String, Object> getOSNameAliasTable() { - if (osnameAliasTable == null) { - InputStream in = AliasMapper.class.getResourceAsStream("osname.aliases"); //$NON-NLS-1$ - if (in != null) { + private static void getTables(String resourceName, Map<String, Collection<String>> aliasTable, Map<String, String> canonicalTable) { + InputStream in = AliasMapper.class.getResourceAsStream(resourceName); + if (in != null) { + try { + initAliases(in, aliasTable, canonicalTable); + } finally { try { - osnameAliasTable = initAliases(in); - } finally { - try { - in.close(); - } catch (IOException ee) { - // nothing - } + in.close(); + } catch (IOException ee) { + // nothing } } } - return osnameAliasTable; } /** @@ -66,16 +49,8 @@ public class AliasMapper { * @param processor Input name * @return aliased name (if any) */ - public String aliasProcessor(String processor) { - processor = processor.toLowerCase(); - Map<String, Object> aliases = getProcessorAliasTable(); - if (aliases != null) { - String alias = (String) aliases.get(processor); - if (alias != null) { - processor = alias; - } - } - return processor; + public Collection<String> getProcessorAliases(String processor) { + return getAlias(processor.toLowerCase(), processorAliasTable); } /** @@ -84,20 +59,29 @@ public class AliasMapper { * @param osname Input name * @return aliased name (if any) */ - public Object aliasOSName(String osname) { - osname = osname.toLowerCase(); - Map<String, Object> aliases = getOSNameAliasTable(); + public Collection<String> getOSNameAliases(String osname) { + return getAlias(osname.toLowerCase(), osnameAliasTable); + } + + public String getCanonicalOSName(String osname) { + String result = osnameCanonicalTable.get(osname.toLowerCase()); + return result == null ? osname : result; + } + + public String getCanonicalProcessor(String processor) { + String result = processorCanonicalTable.get(processor).toLowerCase(); + return result == null ? processor : result; + } + + private Collection<String> getAlias(String name, Map<String, Collection<String>> aliasMap) { + if (name == null) { + return Collections.emptyList(); + } + Collection<String> aliases = aliasMap == null ? null : aliasMap.get(name); if (aliases != null) { - Object aliasObject = aliases.get(osname); - //String alias = (String) osnameAliasTable.get(osname); - if (aliasObject != null) - if (aliasObject instanceof String) { - osname = (String) aliasObject; - } else { - return aliasObject; - } + return Collections.unmodifiableCollection(aliases); } - return osname; + return Collections.singletonList(name.toLowerCase()); } /** @@ -106,8 +90,7 @@ public class AliasMapper { * @param in InputStream from which to read alias data. * @return Map of aliases. */ - protected static Map<String, Object> initAliases(InputStream in) { - Map<String, Object> aliases = new HashMap<String, Object>(37); + protected static Map<String, Collection<String>> initAliases(InputStream in, Map<String, Collection<String>> aliasTable, Map<String, String> canonicalTable) { try { BufferedReader br; try { @@ -123,25 +106,35 @@ public class AliasMapper { Tokenizer tokenizer = new Tokenizer(line); String master = tokenizer.getString("# \t"); //$NON-NLS-1$ if (master != null) { - aliases.put(master.toLowerCase(), master); + String masterLower = master.toLowerCase(); + canonicalTable.put(masterLower, master); + Collection<String> aliasLine = new ArrayList<String>(1); + aliasLine.add(masterLower); parseloop: while (true) { String alias = tokenizer.getString("# \t"); //$NON-NLS-1$ if (alias == null) { break parseloop; } - String lowerCaseAlias = alias.toLowerCase(); - Object storedMaster = aliases.get(lowerCaseAlias); - if (storedMaster == null) { - aliases.put(lowerCaseAlias, master); - } else if (storedMaster instanceof String) { - List<String> newMaster = new ArrayList<String>(); - newMaster.add((String) storedMaster); - newMaster.add(master); - aliases.put(lowerCaseAlias, newMaster); + String aliasLower = alias.toLowerCase(); + aliasLine.add(aliasLower); + if (!canonicalTable.containsKey(aliasLower)) { + canonicalTable.put(aliasLower, master); + } else { + // the alias has multiple masters just make its canonical name be the alias + canonicalTable.put(aliasLower, alias); + } + } + for (String alias : aliasLine) { + Collection<String> aliases = aliasTable.get(alias); + if (aliases == null) { + aliases = new ArrayList<String>(aliasLine); + aliasTable.put(alias, aliases); } else { - @SuppressWarnings("unchecked") - List<String> newMaster = ((List<String>) storedMaster); - newMaster.add(master); + for (String aliasToAdd : aliasLine) { + if (!aliases.contains(aliasToAdd)) { + aliases.add(aliasToAdd); + } + } } } } @@ -149,6 +142,6 @@ public class AliasMapper { } catch (IOException e) { Debug.printStackTrace(e); } - return aliases; + return aliasTable; } } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxConfiguration.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxConfiguration.java index e4c3ad11f..97fcc1ead 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxConfiguration.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxConfiguration.java @@ -631,26 +631,18 @@ public class EquinoxConfiguration implements EnvironmentInfo { if (value == null) { value = System.getProperty(PROP_JVM_OS_ARCH); if (value != null) { - configuration.put(org.osgi.framework.Constants.FRAMEWORK_PROCESSOR, aliasMapper.aliasProcessor(value)); + configuration.put(org.osgi.framework.Constants.FRAMEWORK_PROCESSOR, aliasMapper.getCanonicalProcessor(value)); } } + value = configuration.getProperty(org.osgi.framework.Constants.FRAMEWORK_OS_NAME); if (value == null) { value = System.getProperty(PROP_JVM_OS_NAME); - try { - String canonicalValue = (String) aliasMapper.aliasOSName(value); - if (canonicalValue != null) { - value = canonicalValue; - } - } catch (ClassCastException ex) { - //A vector was returned from the alias mapper. - //The alias mapped to more than one canonical value - //such as "win32" for example - } if (value != null) { - configuration.put(org.osgi.framework.Constants.FRAMEWORK_OS_NAME, value); + configuration.put(org.osgi.framework.Constants.FRAMEWORK_OS_NAME, aliasMapper.getCanonicalOSName(value)); } } + value = configuration.getProperty(org.osgi.framework.Constants.FRAMEWORK_OS_VERSION); if (value == null) { value = System.getProperty(PROP_JVM_OS_VERSION); diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/OSGiFrameworkHooks.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/OSGiFrameworkHooks.java index ac0629743..7c49560da 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/OSGiFrameworkHooks.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/OSGiFrameworkHooks.java @@ -15,7 +15,7 @@ import java.security.PrivilegedAction; import java.util.*; import org.eclipse.osgi.container.Module; import org.eclipse.osgi.container.ModuleCollisionHook; -import org.eclipse.osgi.container.namespaces.EquinoxNativeCodeNamespace; +import org.eclipse.osgi.container.namespaces.EquinoxNativeEnvironmentNamespace; import org.eclipse.osgi.framework.internal.core.Msg; import org.eclipse.osgi.internal.baseadaptor.ArrayMap; import org.eclipse.osgi.internal.debug.Debug; @@ -285,8 +285,8 @@ class OSGiFrameworkHooks { } private void filterNativeSelectionFilter(BundleRequirement requirement, Collection<BundleCapability> candidates) { - if (EquinoxNativeCodeNamespace.EQUINOX_NATIVECODE_NAMESPACE.equals(requirement.getNamespace())) { - String filterSpec = requirement.getDirectives().get(EquinoxNativeCodeNamespace.REQUIREMENT_SELECTION_FILTER_DIRECTIVE); + if (EquinoxNativeEnvironmentNamespace.NATIVE_ENVIRONMENT_NAMESPACE.equals(requirement.getNamespace())) { + String filterSpec = requirement.getDirectives().get(EquinoxNativeEnvironmentNamespace.REQUIREMENT_SELECTION_FILTER_DIRECTIVE); if (filterSpec != null) { try { Filter f = FilterImpl.newInstance(filterSpec); diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/NativeCodeFinder.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/NativeCodeFinder.java index 2ffbc3043..1708f5d74 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/NativeCodeFinder.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/NativeCodeFinder.java @@ -14,7 +14,7 @@ package org.eclipse.osgi.storage; import java.io.File; import java.util.*; import org.eclipse.osgi.container.*; -import org.eclipse.osgi.container.namespaces.EquinoxNativeCodeNamespace; +import org.eclipse.osgi.container.namespaces.EquinoxNativeEnvironmentNamespace; import org.eclipse.osgi.internal.debug.Debug; import org.eclipse.osgi.internal.hookregistry.ClassLoaderHook; import org.eclipse.osgi.storage.BundleInfo.Generation; @@ -163,7 +163,7 @@ public class NativeCodeFinder { } } - List<ModuleWire> nativeCode = wiring.getRequiredModuleWires(EquinoxNativeCodeNamespace.EQUINOX_NATIVECODE_NAMESPACE); + List<ModuleWire> nativeCode = wiring.getRequiredModuleWires(EquinoxNativeEnvironmentNamespace.NATIVE_ENVIRONMENT_NAMESPACE); if (nativeCode.isEmpty()) { return Collections.emptyList(); } @@ -172,7 +172,7 @@ public class NativeCodeFinder { for (ModuleWire moduleWire : nativeCode) { if (moduleWire.getRequirement().getRevision().equals(revision)) { @SuppressWarnings("unchecked") - List<String> result = (List<String>) nativeCode.get(0).getRequirement().getAttributes().get(EquinoxNativeCodeNamespace.REQUIREMENT_NATIVE_PATHS_ATTRIBUTE); + List<String> result = (List<String>) nativeCode.get(0).getRequirement().getAttributes().get(EquinoxNativeEnvironmentNamespace.REQUIREMENT_NATIVE_PATHS_ATTRIBUTE); if (result != null) return result; } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java index a1e901de3..03ace286f 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java @@ -20,7 +20,7 @@ import org.eclipse.osgi.container.*; import org.eclipse.osgi.container.ModuleRevisionBuilder.GenericInfo; import org.eclipse.osgi.container.builders.OSGiManifestBuilderFactory; import org.eclipse.osgi.container.namespaces.EclipsePlatformNamespace; -import org.eclipse.osgi.container.namespaces.EquinoxNativeCodeNamespace; +import org.eclipse.osgi.container.namespaces.EquinoxNativeEnvironmentNamespace; import org.eclipse.osgi.framework.log.FrameworkLogEntry; import org.eclipse.osgi.framework.util.*; import org.eclipse.osgi.internal.baseadaptor.AdaptorMsg; @@ -509,16 +509,36 @@ public class Storage { language = language == null ? null : language.toLowerCase(); result.append(", "); //$NON-NLS-1$ - result.append(EquinoxNativeCodeNamespace.EQUINOX_NATIVECODE_NAMESPACE).append("; "); //$NON-NLS-1$ - result.append(EquinoxNativeCodeNamespace.CAPABILITY_OS_NAME_ATTRIBUTE).append("=").append(osName).append("; "); //$NON-NLS-1$ //$NON-NLS-2$ - result.append(EquinoxNativeCodeNamespace.CAPABILITY_PROCESSOR_ATTRIBUTE).append("=").append(processor).append("; "); //$NON-NLS-1$ //$NON-NLS-2$ - result.append(EquinoxNativeCodeNamespace.CAPABILITY_OS_VERSION_ATTRIBUTE + ":Version").append("=").append(osVersion).append("; "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - result.append(EquinoxNativeCodeNamespace.CAPABILITY_LANGUAGE_ATTRIBUTE).append("=").append(language); //$NON-NLS-1$ + result.append(EquinoxNativeEnvironmentNamespace.NATIVE_ENVIRONMENT_NAMESPACE).append("; "); //$NON-NLS-1$ + if (osName != null) { + osName = getAliasList(equinoxConfig.getAliasMapper().getOSNameAliases(osName)); + result.append(EquinoxNativeEnvironmentNamespace.CAPABILITY_OS_NAME_ATTRIBUTE).append(":List<String>=").append(osName).append("; "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + } + if (processor != null) { + processor = getAliasList(equinoxConfig.getAliasMapper().getProcessorAliases(processor)); + result.append(EquinoxNativeEnvironmentNamespace.CAPABILITY_PROCESSOR_ATTRIBUTE).append(":List<String>=").append(processor).append("; "); //$NON-NLS-1$ //$NON-NLS-2$ + } + result.append(EquinoxNativeEnvironmentNamespace.CAPABILITY_OS_VERSION_ATTRIBUTE).append(":Version").append("=").append(osVersion).append("; "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + result.append(EquinoxNativeEnvironmentNamespace.CAPABILITY_LANGUAGE_ATTRIBUTE).append("=").append(language); //$NON-NLS-1$ // TODO need a way to configure in arbitrary native code matching attributes return result.toString(); } + String getAliasList(Collection<String> aliases) { + if (aliases.isEmpty()) { + return null; + } + StringBuilder builder = new StringBuilder(); + builder.append('"'); + for (String alias : aliases) { + builder.append(alias).append(','); + } + builder.setLength(builder.length() - 1); + builder.append('"'); + return builder.toString(); + } + private String getSystemExtraPackages() { EquinoxConfiguration equinoxConfig = equinoxContainer.getConfiguration(); StringBuilder result = new StringBuilder(); |