diff options
9 files changed, 114 insertions, 97 deletions
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataParser.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataParser.java index a1ff60596..90e27da4b 100644 --- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataParser.java +++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataParser.java @@ -16,8 +16,7 @@ import java.net.URI; import java.util.*; import java.util.Map.Entry; import org.eclipse.equinox.internal.p2.core.helpers.OrderedProperties; -import org.eclipse.equinox.internal.p2.metadata.ArtifactKey; -import org.eclipse.equinox.internal.p2.metadata.InstallableUnit; +import org.eclipse.equinox.internal.p2.metadata.*; import org.eclipse.equinox.internal.p2.persistence.XMLParser; import org.eclipse.equinox.p2.metadata.*; import org.eclipse.equinox.p2.metadata.MetadataFactory.*; @@ -533,6 +532,7 @@ public abstract class MetadataParser extends XMLParser implements XMLConstants { this.version = checkVersion(PROVIDED_CAPABILITY_ELEMENT, VERSION_ATTRIBUTE, values[2]); } + @Override public void startElement(String elem, Attributes attributes) { if (elem.equals(CAPABILITY_ATTRIBUTES_ELEMENT)) { this.attributesHandler = new ProvidedCapabilityAttributesHandler(this, attributes); @@ -541,13 +541,14 @@ public abstract class MetadataParser extends XMLParser implements XMLConstants { } } + @Override protected void finished() { Map<String, Object> capAttrs = (attributesHandler != null) ? attributesHandler.getAttributes() - : new HashMap<String, Object>(); + : new HashMap<>(); - capAttrs.put(NAME_ATTRIBUTE, name); - capAttrs.put(VERSION_ATTRIBUTE, version); + capAttrs.put(namespace, name); + capAttrs.put(ProvidedCapability.ATTRIBUTE_VERSION, version); IProvidedCapability cap = MetadataFactory.createProvidedCapability(namespace, capAttrs); capabilities.add(cap); } @@ -559,13 +560,14 @@ public abstract class MetadataParser extends XMLParser implements XMLConstants { public ProvidedCapabilityAttributesHandler(AbstractHandler parentHandler, Attributes attributes) { super(parentHandler, CAPABILITY_ATTRIBUTES_ELEMENT); // TODO add getOptionalSize(attributes, 4) - this.capAttributes = new HashMap<String, Object>(); + this.capAttributes = new HashMap<>(); } public Map<String, Object> getAttributes() { return capAttributes; } + @Override public void startElement(String name, Attributes attributes) { if (name.equals(CAPABILITY_ATTRIBUTE_ELEMENT)) { new ProvidedCapabilityAttributeHandler(this, attributes, capAttributes); @@ -600,7 +602,7 @@ public abstract class MetadataParser extends XMLParser implements XMLConstants { private List<Object> parseList(String type, String value) { String elType = type.substring(ATTR_TYPE_LIST_HEAD.length(), type.length() - 1); - List<Object> res = new ArrayList<Object>(); + List<Object> res = new ArrayList<>(); for (String el : value.split("\\s*,\\s*")) { //$NON-NLS-1$ res.add(parseScalar(elType, el)); } diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataWriter.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataWriter.java index 37559a7b9..2b7686e35 100644 --- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataWriter.java +++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataWriter.java @@ -17,6 +17,7 @@ import java.util.*; import java.util.Map.Entry; import org.eclipse.core.runtime.*; import org.eclipse.equinox.internal.p2.core.helpers.LogHelper; +import org.eclipse.equinox.internal.p2.metadata.ProvidedCapability; import org.eclipse.equinox.internal.p2.metadata.RequiredCapability; import org.eclipse.equinox.internal.p2.metadata.repository.Activator; import org.eclipse.equinox.internal.p2.persistence.XMLWriter; @@ -167,8 +168,8 @@ public class MetadataWriter extends XMLWriter implements XMLConstants { attribute(VERSION_ATTRIBUTE, capability.getVersion()); Map<String, Object> attrs = new HashMap<>(capability.getAttributes()); - attrs.remove(NAME_ATTRIBUTE); - attrs.remove(VERSION_ATTRIBUTE); + attrs.remove(capability.getNamespace()); + attrs.remove(ProvidedCapability.ATTRIBUTE_VERSION); if (!attrs.isEmpty()) { start(CAPABILITY_ATTRIBUTES_ELEMENT); @@ -185,7 +186,7 @@ public class MetadataWriter extends XMLWriter implements XMLConstants { Collection<?> coll = (Collection<?>) val; String elType = coll.iterator().next().getClass().getSimpleName(); - type = "List<" + elType + ">"; //$NON-NLS-1$ //$NON-NLS-2$ + type = String.format("List<%s>", elType); //$NON-NLS-1$ StringBuilder valBuff = new StringBuilder(); for (Iterator<?> iter = coll.iterator(); iter.hasNext();) { diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/ProvidedCapability.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/ProvidedCapability.java index 2c68d5ecc..5d36a1913 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/ProvidedCapability.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/ProvidedCapability.java @@ -25,9 +25,18 @@ import org.eclipse.osgi.util.NLS; * Describes a capability as exposed or required by an installable unit */ public class ProvidedCapability implements IProvidedCapability, IMemberProvider { + /** Used for fast access from P2 queries to the {@link #getNamespace} method */ + public static final String MEMBER_NAMESPACE = "namespace"; //$NON-NLS-1$ + /** Used for fast access from P2 queries to the {@link #getName} method */ public static final String MEMBER_NAME = "name"; //$NON-NLS-1$ + /** Used for fast access from P2 queries to the {@link #getVersion} method */ public static final String MEMBER_VERSION = "version"; //$NON-NLS-1$ - public static final String MEMBER_NAMESPACE = "namespace"; //$NON-NLS-1$ + /** Used for fast access from P2 queries to the {@link #getAttributes} method */ + public static final String MEMBER_ATTRIBUTES = "attributes"; //$NON-NLS-1$ + + // TODO Move this to IProvidedCapability? + // The "version" attribute is part of the public contract of getVersion() and getAttributes() + public static final String ATTRIBUTE_VERSION = "version"; //$NON-NLS-1$ private final String namespace; private final Map<String, Object> attributes; @@ -38,26 +47,19 @@ public class ProvidedCapability implements IProvidedCapability, IMemberProvider Assert.isNotNull(attrs); Assert.isTrue(!attrs.isEmpty()); - Assert.isTrue(!attrs.containsKey(MEMBER_NAMESPACE)); + this.attributes = new HashMap<>(attrs); - if (!attributes.containsKey(MEMBER_NAME)) { - // It is common for a capability to have a main attribute under a key - // with value the same as the capability namespace. Use as "name" if present. - Assert.isTrue(attributes.containsKey(namespace)); - attributes.put(MEMBER_NAME, attributes.get(namespace)); - } + // Verify the name + Assert.isTrue(attributes.containsKey(namespace) && (attributes.get(namespace) instanceof String), + NLS.bind(Messages.provided_capability_name_not_defined, namespace)); - Object version = attributes.get(MEMBER_VERSION); - if (version == null) { - attributes.put(MEMBER_VERSION, Version.emptyVersion); - } else if (version instanceof org.osgi.framework.Version) { - org.osgi.framework.Version osgiVer = (org.osgi.framework.Version) version; - attributes.put( - MEMBER_VERSION, - Version.createOSGi(osgiVer.getMajor(), osgiVer.getMinor(), osgiVer.getMicro(), osgiVer.getQualifier())); + // Verify the version + Object version = attributes.get(ATTRIBUTE_VERSION); + if (version != null) { + Assert.isTrue(attributes.get(ATTRIBUTE_VERSION) instanceof Version); } else { - Assert.isTrue(version instanceof Version); + attributes.put(ATTRIBUTE_VERSION, Version.emptyVersion); } } @@ -66,8 +68,8 @@ public class ProvidedCapability implements IProvidedCapability, IMemberProvider Assert.isNotNull(name, NLS.bind(Messages.provided_capability_name_not_defined, namespace)); this.namespace = namespace; this.attributes = new HashMap<>(); - attributes.put(MEMBER_NAME, name); - attributes.put(MEMBER_VERSION, version == null ? Version.emptyVersion : version); + attributes.put(namespace, name); + attributes.put(ATTRIBUTE_VERSION, version == null ? Version.emptyVersion : version); } public boolean equals(Object other) { @@ -92,18 +94,16 @@ public class ProvidedCapability implements IProvidedCapability, IMemberProvider return true; } - public String getName() { - // There is always a "name" member, but it may not always be a string. - // Convert it here so that it is still possible to get the real type via getAttributes(). - return attributes.get(MEMBER_NAME).toString(); - } - public String getNamespace() { return namespace; } + public String getName() { + return (String) attributes.get(namespace); + } + public Version getVersion() { - return (Version) attributes.get(MEMBER_VERSION); + return (Version) attributes.get(ATTRIBUTE_VERSION); } public Map<String, Object> getAttributes() { @@ -129,11 +129,19 @@ public class ProvidedCapability implements IProvidedCapability, IMemberProvider return str.toString(); } + @Override public Object getMember(String memberName) { - Object res = memberName.equals(MEMBER_NAMESPACE) ? namespace : attributes.get(memberName); - if (res == null) { - throw new IllegalArgumentException("No such member: " + memberName); //$NON-NLS-1$ + switch (memberName) { + case MEMBER_NAMESPACE : + return namespace; + case MEMBER_NAME : + return attributes.get(namespace); + case MEMBER_VERSION : + return attributes.get(ATTRIBUTE_VERSION); + case MEMBER_ATTRIBUTES : + return attributes; + default : + throw new IllegalArgumentException("No such member: " + memberName); //$NON-NLS-1$ } - return res; } } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/MemberProvider.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/MemberProvider.java index 4eaa4814b..dccb00397 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/MemberProvider.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/MemberProvider.java @@ -12,8 +12,6 @@ package org.eclipse.equinox.internal.p2.metadata.expression; import java.util.*; import java.util.Map.Entry; -import org.eclipse.equinox.internal.p2.metadata.ProvidedCapability; -import org.eclipse.equinox.p2.metadata.IProvidedCapability; import org.eclipse.equinox.p2.metadata.expression.IMemberProvider; import org.osgi.framework.ServiceReference; @@ -137,14 +135,6 @@ public abstract class MemberProvider implements IMemberProvider { return caseInsensitive ? new CIDictionaryMemberProvider((Dictionary<String, ?>) value) : new DictionaryMemberProvider((Dictionary<String, ?>) value); if (value instanceof ServiceReference) return new ServiceRefMemberProvider((ServiceReference<?>) value); - // TODO Should there be a clause in Matches.match() instead? - if (value instanceof IProvidedCapability) { - IProvidedCapability cap = (IProvidedCapability) value; - Map<String, Object> attrs = new HashMap<String, Object>(); - attrs.put(ProvidedCapability.MEMBER_NAMESPACE, cap.getNamespace()); - attrs.putAll(cap.getAttributes()); - return caseInsensitive ? new CIMapMemberProvider(attrs) : new MapMemberProvider(attrs); - } throw new IllegalArgumentException(); } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/IProvidedCapability.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/IProvidedCapability.java index 47aa3ee51..a1c0f3af8 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/IProvidedCapability.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/IProvidedCapability.java @@ -28,24 +28,23 @@ import java.util.Map; * @see IRequirement */ public interface IProvidedCapability { - /** * - * @return String the String representation of the special "name" attribute of this capability. + * @return String the namespace of this capability. * @noreference This method is not intended to be referenced by clients. */ - public String getName(); + public String getNamespace(); /** * - * @return String the namespace of this capability. + * @return String the attribute stored under a key equal to {@link #getNamespace()} attribute of this capability. * @noreference This method is not intended to be referenced by clients. */ - public String getNamespace(); + public String getName(); /** * - * @return String the special "version" attribute of this capability. + * @return String the special <code>version</code> attribute of this capability. * @noreference This method is not intended to be referenced by clients. */ public Version getVersion(); @@ -54,6 +53,7 @@ public interface IProvidedCapability { * * @return A full description of this capability * @noreference This method is not intended to be referenced by clients. + * @since 2.4 */ public Map<String, Object> getAttributes(); @@ -63,9 +63,8 @@ public interface IProvidedCapability { * This method returns <i>true</i> if: * <ul> * <li> Both this object and the given object are of type IProvidedCapability - * <li> The result of <b>getName()</b> on both objects are equal * <li> The result of <b>getNamespace()</b> on both objects are equal - * <li> The result of <b>getVersion()</b> on both objects are equal + * <li> The result of <b>getAttributes()</b> on both objects are equal * </ul> */ public boolean equals(Object other); diff --git a/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/p2/publisher/eclipse/BundlesAction.java b/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/p2/publisher/eclipse/BundlesAction.java index 925f082eb..95777c848 100644 --- a/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/p2/publisher/eclipse/BundlesAction.java +++ b/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/p2/publisher/eclipse/BundlesAction.java @@ -22,7 +22,6 @@ import org.eclipse.core.runtime.*; import org.eclipse.equinox.frameworkadmin.BundleInfo; import org.eclipse.equinox.internal.p2.core.helpers.LogHelper; import org.eclipse.equinox.internal.p2.metadata.ArtifactKey; -import org.eclipse.equinox.internal.p2.metadata.ProvidedCapability; import org.eclipse.equinox.internal.p2.publisher.Messages; import org.eclipse.equinox.internal.p2.publisher.eclipse.GeneratorBundleInfo; import org.eclipse.equinox.p2.metadata.*; @@ -79,6 +78,7 @@ public class BundlesAction extends AbstractPublisherAction { public static final String OSGI_BUNDLE_CLASSIFIER = "osgi.bundle"; //$NON-NLS-1$ public static final String CAPABILITY_NS_OSGI_BUNDLE = "osgi.bundle"; //$NON-NLS-1$ public static final String CAPABILITY_NS_OSGI_FRAGMENT = "osgi.fragment"; //$NON-NLS-1$ + public static final String CAPABILITY_ATTR_VERSION = "version"; //$NON-NLS-1$ public static final IProvidedCapability BUNDLE_CAPABILITY = MetadataFactory.createProvidedCapability(PublisherHelper.NAMESPACE_ECLIPSE_TYPE, TYPE_ECLIPSE_BUNDLE, Version.createOSGi(1, 0, 0)); public static final IProvidedCapability SOURCE_BUNDLE_CAPABILITY = MetadataFactory.createProvidedCapability(PublisherHelper.NAMESPACE_ECLIPSE_TYPE, TYPE_ECLIPSE_SOURCE, Version.createOSGi(1, 0, 0)); @@ -218,30 +218,13 @@ public class BundlesAction extends AbstractPublisherAction { // Bug 360659, Bug 525368. E.g. with IProvidedCapability.getDirectives() // TODO - // The "osgi.wiring.bundle" capability seems equal to p2 "osgi.bundle" capability. - // It may be better to derive it at runtime. - - // TODO // It may be possible map the "osgi.identity" capability to elements of the IU like the id, the license, etc. // It may be better to derive it at runtime. - int numCapName = 0; + int capNo = 0; for (GenericDescription genericCap : bd.getGenericCapabilities()) { - String capNs = genericCap.getType(); - - Map<String, Object> capAttrs = genericCap.getDeclaredAttributes(); - - // Some capabilities do not follow the OSGi convention to have an attribute with a key equal to their namespace (e.g. "osgi.service") - // In such cases synthesize a unique name - if (!capAttrs.containsKey(capNs)) { - capAttrs = new HashMap<>(capAttrs); - capAttrs.put( - ProvidedCapability.MEMBER_NAME, - String.format("%s_%s-%s", iu.getId(), iu.getVersion(), numCapName++)); //$NON-NLS-1$ - numCapName++; - } - - providedCapabilities.add(MetadataFactory.createProvidedCapability(capNs, capAttrs)); + addGenericCapability(providedCapabilities, genericCap, iu, capNo); + capNo++; } // Add capability to describe the type of bundle @@ -318,11 +301,12 @@ public class BundlesAction extends AbstractPublisherAction { } // TODO Handle all attributes and directives somehow? Especially the "effective" directive. - // TODO Make these optional and greedy for backward compatibility? protected void addGenericRequirement(List<IRequirement> reqsDeps, GenericSpecification requireCapSpec, ManifestElement[] rawRequiresPackageHeader) { + String ns = requireCapSpec.getType(); String ldap = requireCapSpec.getMatchingFilter(); - ldap = "(&(namespace=" + requireCapSpec.getType() + ")" + ldap + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - IExpression expr = ExpressionUtil.parse("providedCapabilities.exists(pc | pc ~= filter('" + ldap + "'))"); //$NON-NLS-1$ //$NON-NLS-2$ + String matcher = "providedCapabilities.exists(pc | pc.namespace == '" + ns + "' && pc.attributes ~= filter('" + ldap + "'))"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + + IExpression expr = ExpressionUtil.parse(matcher); IMatchExpression<IInstallableUnit> matchExpr = ExpressionUtil.getFactory().matchExpression(expr); // Optional and greedy in order to be backward compatible. @@ -341,6 +325,40 @@ public class BundlesAction extends AbstractPublisherAction { reqsDeps.add(MetadataFactory.createRequirement(CAPABILITY_NS_OSGI_BUNDLE, requiredBundle.getName(), PublisherHelper.fromOSGiVersionRange(requiredBundle.getVersionRange()), null, optional ? 0 : 1, 1, greedy)); } + protected void addGenericCapability(List<IProvidedCapability> caps, GenericDescription provideCapDesc, InstallableUnitDescription iu, int capNo) { + String capNs = provideCapDesc.getType(); + Map<String, Object> capAttrs = new HashMap<>(provideCapDesc.getDeclaredAttributes()); + + // Resolve the p2 name + // By convention OSGi capabilities have an attribute named like the capability namespace. + // If this is not the case synthesize a unique name (e.g. "osgi.service" has an "objectClass" attribute instead). + // TODO If present but not a String log a warning somehow that it is ignored? Or fail the publication? + capAttrs.compute( + capNs, + (k, v) -> (v instanceof String) ? v : String.format("%s_%s-%s", iu.getId(), iu.getVersion(), capNo)); //$NON-NLS-1$ + + // Convert all OSGi versions to P2 versions + for (String key : new HashSet<>(capAttrs.keySet())) { + Object val = capAttrs.get(key); + if (!(val instanceof org.osgi.framework.Version)) { + continue; + } + org.osgi.framework.Version osgiVer = (org.osgi.framework.Version) val; + Version p2Ver = Version.createOSGi(osgiVer.getMajor(), osgiVer.getMinor(), osgiVer.getMicro(), osgiVer.getQualifier()); + capAttrs.put(key, p2Ver); + } + + // Resolve the version + // By convention versioned OSGi capabilities have a "version" attribute containing the OSGi Version object + // If this is not the case use an empty version (e.g. "osgi.ee" has a list of versions). + // TODO If present but not a Version log a warning somehow that it is ignored? Or fail the publication? + capAttrs.compute( + CAPABILITY_ATTR_VERSION, + (k, v) -> (v instanceof Version) ? v : Version.emptyVersion); + + caps.add(MetadataFactory.createProvidedCapability(capNs, capAttrs)); + } + static VersionRange computeUpdateRange(org.osgi.framework.Version base) { VersionRange updateRange = null; if (!base.equals(org.osgi.framework.Version.emptyVersion)) { diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/JREAction.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/JREAction.java index baacf2e3b..26a1b0da3 100644 --- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/JREAction.java +++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/JREAction.java @@ -41,6 +41,7 @@ public class JREAction extends AbstractPublisherAction { private static final String PROFILE_SYSTEM_PACKAGES = "org.osgi.framework.system.packages"; //$NON-NLS-1$ public static final String NAMESPACE_OSGI_EE = "osgi.ee"; //$NON-NLS-1$ + public static final String VERSION_OSGI_EE = "version"; //$NON-NLS-1$ private File jreLocation; private String environment; @@ -224,7 +225,7 @@ public class JREAction extends AbstractPublisherAction { // complete record -> store Map<String, Object> capAttrs = new HashMap<>(); capAttrs.put(NAMESPACE_OSGI_EE, eeName); - capAttrs.put("version", parsedVersion); //$NON-NLS-1$ + capAttrs.put(VERSION_OSGI_EE, parsedVersion); parsingResult.add(MetadataFactory.createProvidedCapability(NAMESPACE_OSGI_EE, capAttrs)); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/SPIMetadataRepositoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/SPIMetadataRepositoryTest.java index 752e1606b..6f067c02f 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/SPIMetadataRepositoryTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/SPIMetadataRepositoryTest.java @@ -176,7 +176,6 @@ public class SPIMetadataRepositoryTest extends AbstractProvisioningTest { } class SPIProvidedCapability implements IProvidedCapability { - String namespace; Map<String, Object> attributes; @@ -184,14 +183,12 @@ public class SPIMetadataRepositoryTest extends AbstractProvisioningTest { this.namespace = namespace; this.attributes = new HashMap<>(); - attributes.put(ProvidedCapability.MEMBER_NAME, name); - attributes.put(ProvidedCapability.MEMBER_VERSION, version); + attributes.put(namespace, name); + attributes.put(ProvidedCapability.ATTRIBUTE_VERSION, version); } @Override public boolean equals(Object other) { - if (other == null) - return false; if (!(other instanceof IProvidedCapability)) return false; IProvidedCapability otherCapability = (IProvidedCapability) other; @@ -203,22 +200,23 @@ public class SPIMetadataRepositoryTest extends AbstractProvisioningTest { } @Override + public String toString() { + return namespace + "; " + attributes; + } + + @Override public String getName() { - return (String) attributes.get(ProvidedCapability.MEMBER_NAME); + return (String) attributes.get(namespace); } @Override public String getNamespace() { - return this.namespace; + return namespace; } @Override public Version getVersion() { - return (Version) attributes.get(ProvidedCapability.MEMBER_VERSION); - } - - public boolean satisfies(IRequirement candidate) { - return false; + return (Version) attributes.get(ProvidedCapability.ATTRIBUTE_VERSION); } @Override diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/BundlesActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/BundlesActionTest.java index 75eef92d0..f943a7862 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/BundlesActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/BundlesActionTest.java @@ -42,8 +42,8 @@ public class BundlesActionTest extends ActionTest { private static final String OSGI = PublisherHelper.OSGI_BUNDLE_CLASSIFIER; private static final String OSGI_IDENTITY = "osgi.identity"; private static final String JAVA_PACKAGE = "java.package";//$NON-NLS-1$ - private static final String JAVA_EE_1_4_REQ = "providedCapabilities.exists(pc | pc ~= filter('(&(namespace=osgi.ee)(|(&(osgi.ee=JavaSE)(version=1.4))(&(osgi.ee=CDC/Foundation)(version=1.1))))'))"; - private static final String JAVA_EE_1_6_REQ = "providedCapabilities.exists(pc | pc ~= filter('(&(namespace=osgi.ee)(&(osgi.ee=JavaSE)(version=1.6)))'))"; + private static final String JAVA_EE_1_4_REQ = "providedCapabilities.exists(pc | pc.namespace == 'osgi.ee' && pc.attributes ~= filter('(|(&(osgi.ee=JavaSE)(version=1.4))(&(osgi.ee=CDC/Foundation)(version=1.1)))'))"; + private static final String JAVA_EE_1_6_REQ = "providedCapabilities.exists(pc | pc.namespace == 'osgi.ee' && pc.attributes ~= filter('(&(osgi.ee=JavaSE)(version=1.6))'))"; private static final String TEST1_IUD_NAME = "iud";//$NON-NLS-1$ private static final String TEST1_PROVZ_NAME = "iuz";//$NON-NLS-1$ |