Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 349618 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/equinox/internal/region/hook/RegionResolverHookTests.java (+32 lines)
Lines 403-408 Link Here
403
		}
403
		}
404
404
405
		@Override
405
		@Override
406
		public BundleRevision getResource() {
407
			return getRevision();
408
		}
409
410
		@Override
406
		public BundleRevision getRevision() {
411
		public BundleRevision getRevision() {
407
			return new StubBundleRevision(bundle(this.bundleSymbolicName));
412
			return new StubBundleRevision(bundle(this.bundleSymbolicName));
408
		}
413
		}
Lines 481-486 Link Here
481
		}
486
		}
482
487
483
		@Override
488
		@Override
489
		public BundleRevision getResource() {
490
			return getRevision();
491
		}
492
493
		@Override
484
		public BundleRevision getRevision() {
494
		public BundleRevision getRevision() {
485
			return new StubBundleRevision(bundle(this.bundleSymbolicName));
495
			return new StubBundleRevision(bundle(this.bundleSymbolicName));
486
		}
496
		}
Lines 543-548 Link Here
543
		}
553
		}
544
554
545
		@Override
555
		@Override
556
		public BundleRevision getResource() {
557
			return getRevision();
558
		}
559
560
		@Override
546
		public BundleRevision getRevision() {
561
		public BundleRevision getRevision() {
547
			return this.bundleRevision;
562
			return this.bundleRevision;
548
		}
563
		}
Lines 552-557 Link Here
552
			throw new UnsupportedOperationException();
567
			throw new UnsupportedOperationException();
553
		}
568
		}
554
569
570
		@Override
571
		public boolean matches(Capability capability) {
572
			if (!(capability instanceof BundleCapability))
573
				return false;
574
			return matches((BundleCapability) capability);
575
		}
555
	}
576
	}
556
577
557
	final class StubBundleRevision implements BundleRevision {
578
	final class StubBundleRevision implements BundleRevision {
Lines 597-602 Link Here
597
			throw new UnsupportedOperationException();
618
			throw new UnsupportedOperationException();
598
		}
619
		}
599
620
621
		@SuppressWarnings({"cast", "unchecked", "rawtypes"})
622
		@Override
623
		public List<Capability> getCapabilities(String namespace) {
624
			return (List<Capability>) (List) getDeclaredCapabilities(namespace);
625
		}
626
627
		@SuppressWarnings({"cast", "unchecked", "rawtypes"})
628
		@Override
629
		public List<Requirement> getRequirements(String namespace) {
630
			return (List<Requirement>) (List) getDeclaredRequirements(namespace);
631
		}
600
	}
632
	}
601
633
602
}
634
}
(-)osgi/src/org/osgi/framework/wiring/BundleCapability.java (-2 / +5 lines)
Lines 18-32 Link Here
18
18
19
import java.util.Map;
19
import java.util.Map;
20
20
21
21
/**
22
/**
22
 * A capability that has been declared from a {@link BundleRevision bundle
23
 * A capability that has been declared from a {@link BundleRevision bundle
23
 * revision}.
24
 * revision}.
24
 * 
25
 * 
25
 * @ThreadSafe
26
 * @ThreadSafe
26
 * @noimplement
27
 * @noimplement
27
 * @version $Id: 0fde13c3228af1aa97872b37ccf0aa6e23123b11 $
28
 * @version $Id: 6bbc1e645f927531d40fb245c95f5d26ad189db3 $
28
 */
29
 */
29
public interface BundleCapability {
30
public interface BundleCapability extends Capability{
30
	/**
31
	/**
31
	 * Returns the name space of this capability.
32
	 * Returns the name space of this capability.
32
	 * 
33
	 * 
Lines 58-61 Link Here
58
	 * @return The bundle revision declaring this capability.
59
	 * @return The bundle revision declaring this capability.
59
	 */
60
	 */
60
	BundleRevision getRevision();
61
	BundleRevision getRevision();
62
63
	BundleRevision getResource();
61
}
64
}
(-)osgi/src/org/osgi/framework/wiring/BundleRequirement.java (-2 / +8 lines)
Lines 18-32 Link Here
18
18
19
import java.util.Map;
19
import java.util.Map;
20
20
21
21
/**
22
/**
22
 * A requirement that has been declared from a {@link BundleRevision bundle
23
 * A requirement that has been declared from a {@link BundleRevision bundle
23
 * revision}.
24
 * revision}.
24
 * 
25
 * 
25
 * @ThreadSafe
26
 * @ThreadSafe
26
 * @noimplement
27
 * @noimplement
27
 * @version $Id: 659132c1fac7526240df377ead0e1bc8d4af2e77 $
28
 * @version $Id: 3ee254a3c0d5516b56affaa66544c892f3d522cb $
28
 */
29
 */
29
public interface BundleRequirement {
30
public interface BundleRequirement extends Requirement{
30
	/**
31
	/**
31
	 * Returns the name space of this requirement.
32
	 * Returns the name space of this requirement.
32
	 * 
33
	 * 
Lines 60-65 Link Here
60
	BundleRevision getRevision();
61
	BundleRevision getRevision();
61
62
62
	/**
63
	/**
64
	 * {@inheritDoc}
65
	 */
66
	BundleRevision getResource();
67
68
	/**
63
	 * Returns whether the specified capability matches this requirement.
69
	 * Returns whether the specified capability matches this requirement.
64
	 * 
70
	 * 
65
	 * @param capability The capability to match to this requirement.
71
	 * @param capability The capability to match to this requirement.
(-)osgi/src/org/osgi/framework/wiring/BundleRevision.java (-5 / +5 lines)
Lines 47-55 Link Here
47
 * 
47
 * 
48
 * @ThreadSafe
48
 * @ThreadSafe
49
 * @noimplement
49
 * @noimplement
50
 * @version $Id: 139b3046ebd46c48b03dda8d36f2f9d79e2e616d $
50
 * @version $Id: 2eb450f15fc9d4fe1b611dc55e2238b972b4c486 $
51
 */
51
 */
52
public interface BundleRevision extends BundleReference {
52
public interface BundleRevision extends BundleReference, Resource {
53
	/**
53
	/**
54
	 * Returns the symbolic name for this bundle revision.
54
	 * Returns the symbolic name for this bundle revision.
55
	 * 
55
	 * 
Lines 137-143 Link Here
137
	 * package wires required by a bundle wiring may change as the bundle wiring
137
	 * package wires required by a bundle wiring may change as the bundle wiring
138
	 * may dynamically import additional packages.
138
	 * may dynamically import additional packages.
139
	 */
139
	 */
140
	String	PACKAGE_NAMESPACE	= "osgi.wiring.package";
140
	String	PACKAGE_NAMESPACE	= ResourceConstants.WIRING_PACKAGE_NAMESPACE;
141
141
142
	/**
142
	/**
143
	 * Name space for bundle capabilities and requirements.
143
	 * Name space for bundle capabilities and requirements.
Lines 175-181 Link Here
175
	 * {@link Constants#BUNDLE_MANIFESTVERSION Bundle-ManifestVersion}
175
	 * {@link Constants#BUNDLE_MANIFESTVERSION Bundle-ManifestVersion}
176
	 * {@literal <} 2) must not provide a bundle capability.
176
	 * {@literal <} 2) must not provide a bundle capability.
177
	 */
177
	 */
178
	String	BUNDLE_NAMESPACE	= "osgi.wiring.bundle";
178
	String	BUNDLE_NAMESPACE	= ResourceConstants.WIRING_BUNDLE_NAMESPACE;
179
179
180
	/**
180
	/**
181
	 * Name space for host capabilities and requirements.
181
	 * Name space for host capabilities and requirements.
Lines 216-222 Link Here
216
	 * {@link Constants#BUNDLE_MANIFESTVERSION Bundle-ManifestVersion}
216
	 * {@link Constants#BUNDLE_MANIFESTVERSION Bundle-ManifestVersion}
217
	 * {@literal <} 2) must not provide a host capability.
217
	 * {@literal <} 2) must not provide a host capability.
218
	 */
218
	 */
219
	String	HOST_NAMESPACE		= "osgi.wiring.host";
219
	String	HOST_NAMESPACE		= ResourceConstants.WIRING_HOST_NAMESPACE;
220
220
221
	/**
221
	/**
222
	 * Returns the special types of this bundle revision. The bundle revision
222
	 * Returns the special types of this bundle revision. The bundle revision
(-)osgi/src/org/osgi/framework/wiring/BundleWire.java (-2 / +13 lines)
Lines 16-29 Link Here
16
16
17
package org.osgi.framework.wiring;
17
package org.osgi.framework.wiring;
18
18
19
19
/**
20
/**
20
 * A wire connecting a {@link BundleCapability} to a {@link BundleRequirement}.
21
 * A wire connecting a {@link BundleCapability} to a {@link BundleRequirement}.
21
 * 
22
 * 
22
 * @ThreadSafe
23
 * @ThreadSafe
23
 * @noimplement
24
 * @noimplement
24
 * @version $Id: 4f936a84065762ec3267a44f86ae01b0150e44ce $
25
 * @version $Id: aca8642cea91995d0b178129cba1131ed327c7e7 $
25
 */
26
 */
26
public interface BundleWire {
27
public interface BundleWire extends Wire {
27
	/**
28
	/**
28
	 * Returns the {@link BundleCapability} for this wire.
29
	 * Returns the {@link BundleCapability} for this wire.
29
	 * 
30
	 * 
Lines 69-72 Link Here
69
	 *         returned.
70
	 *         returned.
70
	 */
71
	 */
71
	BundleWiring getRequirerWiring();
72
	BundleWiring getRequirerWiring();
73
74
	/**
75
	 * {@inheritDoc}
76
	 */
77
	BundleRevision getProvider();
78
79
	/**
80
	 * {@inheritDoc}
81
	 */
82
	BundleRevision getRequirer();
72
}
83
}
(-)osgi/src/org/osgi/framework/wiring/Capability.java (+82 lines)
Added Link Here
1
/*
2
 * Copyright (c) OSGi Alliance (2010, 2011). All Rights Reserved.
3
 * 
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *      http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
17
package org.osgi.framework.wiring;
18
19
import java.util.Map;
20
21
/**
22
 * A capability that has been declared from a {@link Resource}.
23
 * 
24
 * @ThreadSafe
25
 * @version $Id: f8bd10002691537806e4bc3cf08f3fce37510121 $
26
 */
27
public interface Capability {
28
29
	/**
30
	 * Returns the name space of this capability.
31
	 * 
32
	 * @return The name space of this capability.
33
	 */
34
	String getNamespace();
35
36
	/**
37
	 * Returns the directives of this capability. Only the following list of
38
	 * directives have semantic meaning in the returned {@link Map map} of
39
	 * directives:
40
	 * <ul>
41
	 * <li> {@link ResourceConstants#CAPABILITY_EFFECTIVE_DIRECTIVE effective}
42
	 * <li> {@link ResourceConstants#CAPABILITY_USES_DIRECTIVE uses}
43
	 * <li> {@link ResourceConstants#CAPABILITY_MANDATORY_DIRECTIVE mandatory} -
44
	 * only recognized for the
45
	 * {@link ResourceConstants#WIRING_BUNDLE_NAMESPACE osgi.wiring.bundle} and
46
	 * {@link ResourceConstants#WIRING_PACKAGE_NAMESPACE osgi.wiring.package}
47
	 * name spaces.
48
	 * <li> {@link ResourceConstants#CAPABILITY_EXCLUDE_DIRECTIVE exclude} -
49
	 * only recognized for the
50
	 * {@link ResourceConstants#WIRING_PACKAGE_NAMESPACE osgi.wiring.package}
51
	 * name space.
52
	 * <li> {@link ResourceConstants#CAPABILITY_INCLUDE_DIRECTIVE include} -
53
	 * only recognized for the
54
	 * {@link ResourceConstants#WIRING_PACKAGE_NAMESPACE osgi.wiring.package}
55
	 * name space.
56
	 * </ul>
57
	 * All other directive are considered extra user defined information that
58
	 * has no semantic meaning. OSGi Alliance reserves the right to extend the
59
	 * set of directives which have semantic meaning.
60
	 * 
61
	 * @return An unmodifiable map of directive names to directive values for
62
	 *         this capability, or an empty map if this capability has no
63
	 *         directives.
64
	 */
65
	Map<String, String> getDirectives();
66
67
	/**
68
	 * Returns the attributes of this capability.
69
	 * 
70
	 * @return An unmodifiable map of attribute names to attribute values for
71
	 *         this capability, or an empty map if this capability has no
72
	 *         attributes.
73
	 */
74
	Map<String, Object> getAttributes();
75
76
	/**
77
	 * The resource that declares this capability.
78
	 * 
79
	 * @return the resource
80
	 */
81
	Resource getResource();
82
}
(-)osgi/src/org/osgi/framework/wiring/Requirement.java (+104 lines)
Added Link Here
1
/*
2
 * Copyright (c) OSGi Alliance (2010, 2011). All Rights Reserved.
3
 * 
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *      http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
17
package org.osgi.framework.wiring;
18
19
import java.util.Map;
20
21
import org.osgi.framework.Constants;
22
23
/**
24
 * A requirement that has been declared from a {@link Resource} .
25
 * 
26
 * @ThreadSafe
27
 * @version $Id: 6a5c3253e257d6f503a39d94563d7d656ce05e1d $
28
 */
29
public interface Requirement {
30
	/**
31
	 * Returns the name space of this requirement.
32
	 * 
33
	 * @return The name space of this requirement.
34
	 */
35
	String getNamespace();
36
37
	/**
38
	 * Returns the directives of this requirement. Only the following list of
39
	 * directives have semantic meaning in the returned {@link Map map} of
40
	 * directives:
41
	 * <ul>
42
	 * <li> {@link ResourceConstants#REQUIREMENT_EFFECTIVE_DIRECTIVE effective}
43
	 * <li> {@link ResourceConstants#REQUIREMENT_FILTER_DIRECTIVE filter}
44
	 * <li> {@link ResourceConstants#REQUIREMENT_CARDINALITY_DIRECTIVE
45
	 * cardinality}
46
	 * <li> {@link ResourceConstants#REQUIREMENT_RESOLUTION_DIRECTIVE resolution}
47
	 * <li> {@link ResourceConstants#REQUIREMENT_VISIBILITY_DIRECTIVE visibility}
48
	 * - only recognized for the
49
	 * {@link ResourceConstants#WIRING_BUNDLE_NAMESPACE osgi.wiring.bundle} name
50
	 * space.
51
	 * </ul>
52
	 * All other directive are considered extra user defined information that
53
	 * has no semantic meaning. OSGi Alliance reserves the right to extend the
54
	 * set of directives which have semantic meaning.
55
	 * 
56
	 * @return An unmodifiable map of directive names to directive values for
57
	 *         this requirement, or an empty map if this requirement has no
58
	 *         directives.
59
	 */
60
	Map<String, String> getDirectives();
61
62
	/**
63
	 * Returns the attributes of this requirement. Requirement attributes have
64
	 * no semantic meaning and are considered extra user defined information.
65
	 * 
66
	 * @return An unmodifiable map of attribute names to attribute values for
67
	 *         this requirement, or an empty map if this requirement has no
68
	 *         attributes.
69
	 */
70
	Map<String, Object> getAttributes();
71
72
	/**
73
	 * Returns the resource declaring this requirement.
74
	 * 
75
	 * @return The resource declaring this requirement.
76
	 */
77
	Resource getResource();
78
79
	/**
80
	 * Returns whether the specified capability matches this requirement. A
81
	 * capability matches this requirement when all of the following are true:
82
	 * <ul>
83
	 * <li>The specified capability has the same {@link #getNamespace() name
84
	 * space} as this requirement.
85
	 * <li>The filter specified by the {@link Constants#FILTER_DIRECTIVE filter}
86
	 * directive of this requirement matches the
87
	 * {@link Capability#getAttributes() attributes of the specified capability}.
88
	 * <li>The {@link #getDirectives() requirement directives} and the
89
	 * {@link Capability#getDirectives() capability directives} that apply to
90
	 * the name space are satisfied.
91
	 * </ul>
92
	 * 
93
	 * 
94
	 * @param capability
95
	 *            The capability to match to this requirement.
96
	 * @return {@code true} if the specified capability matches this this
97
	 *         requirement. {@link #getNamespace() name space} as this
98
	 *         requirement and the filter for this requirement matches the
99
	 *         {@link BundleCapability#getAttributes() attributes of the
100
	 *         specified capability}; {@code false} otherwise.
101
	 */
102
	// TODO much debate on the placement and need for this method.
103
	boolean matches(Capability capability);
104
}
(-)osgi/src/org/osgi/framework/wiring/Resource.java (+46 lines)
Added Link Here
1
package org.osgi.framework.wiring;
2
3
import java.util.List;
4
5
6
/**
7
 * A resource is the representation of a uniquely identified and typed data.
8
 * 
9
 * A resources can be wired together via capabilities and requirements.
10
 * 
11
 * TODO decide on identity characteristics of a revision. Given in OSGi multiple
12
 * bundles can be installed with same bsn/version this cannot be used as a key.
13
 * 
14
 * What then is identity of a resource? Object identity? URI (needs getter
15
 * method?)
16
 * 
17
 * @ThreadSafe
18
 * @version $Id: 0d09cf5655002b7b2f1d37d413788892ad2dfedf $
19
 */
20
public interface Resource {
21
	/**
22
	 * Returns the capabilities declared by this resource.
23
	 * 
24
	 * @param namespace
25
	 *            The name space of the declared capabilities to return or
26
	 *            {@code null} to return the declared capabilities from all name
27
	 *            spaces.
28
	 * @return A list containing a snapshot of the declared {@link Capability}s,
29
	 *         or an empty list if this resource declares no capabilities in the
30
	 *         specified name space.
31
	 */
32
	List<Capability> getCapabilities(String namespace);
33
34
	/**
35
	 * Returns the requirements declared by this bundle resource.
36
	 * 
37
	 * @param namespace
38
	 *            The name space of the declared requirements to return or
39
	 *            {@code null} to return the declared requirements from all name
40
	 *            spaces.
41
	 * @return A list containing a snapshot of the declared {@link Requirement}
42
	 *         s, or an empty list if this resource declares no requirements in
43
	 *         the specified name space.
44
	 */
45
	List<Requirement> getRequirements(String namespace);
46
}
(-)osgi/src/org/osgi/framework/wiring/ResourceConstants.java (+364 lines)
Added Link Here
1
/*
2
 * Copyright (c) OSGi Alliance (2011). All Rights Reserved.
3
 * 
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *      http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
package org.osgi.framework.wiring;
17
18
import org.osgi.framework.Constants;
19
import org.osgi.framework.Version;
20
21
/**
22
 * Defines standard names for the attributes, directives and name spaces for
23
 * resources, capabilities and requirements.
24
 * 
25
 * <p>
26
 * The values associated with these keys are of type {@code String}, unless
27
 * otherwise indicated.
28
 * 
29
 * @version $Id: 6a0df41f82a587eb72c0c513fdd0411f18564586 $
30
 */
31
public final class ResourceConstants {
32
33
	private ResourceConstants() {
34
		// keep others from creating objects of this type.
35
	}
36
37
	/**
38
	 * Name space for the identity capability.  Each {@link Resource resource} 
39
	 * should provide an identity capability that can be used to identify the
40
	 * resource.
41
	 * 
42
	 * For identity capability attributes the following applies:
43
	 * <ul>
44
	 * <li>The
45
	 * <q>osgi.identity</q> attribute contains the symbolic name of the
46
	 * resource.
47
	 * <li>The {@link #IDENTITY_VERSION_ATTRIBUTE version} attribute contains
48
	 * the {@link Version} of the resource.
49
	 * <li>The {@link #IDENTITY_TYPE_ATTRIBUTE type} attribute contains the
50
	 * resource type.
51
	 * </ul>
52
	 * <p>
53
	 * A resource with a symbolic name provides exactly one <sup>&#8224;</sup> identity
54
	 * {@link Resource#getCapabilities(String) capability}.
55
	 * <p>
56
	 * &#8224; A resource with no symbolic name must not provide an identity
57
	 * capability.
58
	 */
59
	public static final String IDENTITY_NAMESPACE = "osgi.identity";
60
61
	/**
62
	 * An {@link #IDENTITY_NAMESPACE identity} capability attribute identifying the
63
	 * {@link Version version} of the resource.  This attribute must be set to a value of
64
	 * type {@link Version}.  If the resource has no version then the value 
65
	 * {@link Version#emptyVersion 0.0.0} must be used for the attribute.
66
	 */
67
	public static final String IDENTITY_VERSION_ATTRIBUTE = Constants.VERSION_ATTRIBUTE;
68
69
	/**
70
	 * An {@link #IDENTITY_NAMESPACE identity} capability attribute identifying the
71
	 * resource type.  This attribute must be set to a value of type {@link String}.
72
	 * if the resource has no type then the value 
73
	 * {@link ResourceConstants#IDENTITY_TYPE_UNKNOWN unknown} must be used for the
74
	 * attribute.
75
	 */
76
	public static final String IDENTITY_TYPE_ATTRIBUTE = "type";
77
78
	/**
79
	 * An {@link #IDENTITY_NAMESPACE identity} capability {@link #IDENTITY_TYPE_ATTRIBUTE type}
80
	 * attribute value identifying the resource type as an OSGi bundle.
81
	 */
82
	public static final String IDENTITY_TYPE_BUNDLE = "osgi.bundle";
83
84
	/**
85
	 * An {@link #IDENTITY_NAMESPACE identity} capability {@link #IDENTITY_TYPE_ATTRIBUTE type}
86
	 * attribute value identifying the resource type as an OSGi fragment.
87
	 */
88
	public static final String IDENTITY_TYPE_FRAGMENT = "osgi.fragment";
89
90
	/**
91
	 * An {@link #IDENTITY_NAMESPACE identity} capability {@link #IDENTITY_TYPE_ATTRIBUTE type}
92
	 * attribute value identifying the resource type as unknown.
93
	 */
94
	public static final String IDENTITY_TYPE_UNKNOWN = "unknown";
95
96
	/**
97
	 * An {@link #IDENTITY_NAMESPACE identity} capability {@link Requirement#getDirectives() directive}
98
	 * identifying if the resource is a singleton.  A {@link String} value of &quot;true&quot; indicates
99
	 * the resource is a singleton; any other value or <code>null</code> indicates the resource is not a 
100
	 * singleton.
101
	 */
102
	public static final String IDENTITY_SINGLETON_DIRECTIVE = Constants.SINGLETON_DIRECTIVE;
103
104
	/**
105
	 * Name space for package capabilities and requirements.
106
	 * 
107
	 * For capability attributes the following applies:
108
	 * <ul>
109
	 * <li>The
110
	 * <q>osgi.wiring.package</q> attribute contains the name of the package.
111
	 * <li>The {@link Constants#VERSION_ATTRIBUTE version} attribute contains
112
	 * the the {@link Version} of the package if one is specified or
113
	 * {@link Version#emptyVersion} if not specified.
114
	 * <li>The {@link Constants#BUNDLE_SYMBOLICNAME_ATTRIBUTE
115
	 * bundle-symbolic-name} attribute contains the symbolic name of the
116
	 * resource providing the package if one is specified.
117
	 * <li>The {@link Constants#BUNDLE_VERSION_ATTRIBUTE bundle-version}
118
	 * attribute contains the {@link Version} of resource providing the package
119
	 * if one is specified or {@link Version#emptyVersion} if not specified.
120
	 * <li>All other attributes are of type {@link String} and are used as
121
	 * arbitrary matching attributes for the capability.
122
	 * </ul>
123
	 * <p>
124
	 * A resource provides zero or more package
125
	 * {@link Resource#getCapabilities(String) capabilities} (this is, exported
126
	 * packages) and requires zero or more package
127
	 * {@link Resource#getRequirements(String) requirements} (that is, imported
128
	 * packages).
129
	 */
130
	public static final String WIRING_PACKAGE_NAMESPACE = "osgi.wiring.package";
131
132
	/**
133
	 * Name space for bundle capabilities and requirements.
134
	 * 
135
	 * For capability attributes the following applies:
136
	 * <ul>
137
	 * <li>The
138
	 * <q>osgi.wiring.bundle</q> attribute contains the symbolic name of the
139
	 * bundle.
140
	 * <li>The {@link Constants#BUNDLE_VERSION_ATTRIBUTE bundle-version}
141
	 * attribute contains the {@link Version} of the bundle if one is specified
142
	 * or {@link Version#emptyVersion} if not specified.
143
	 * <li>All other attributes are of type {@link String} and are used as
144
	 * arbitrary matching attributes for the capability.
145
	 * </ul>
146
	 * <p>
147
	 * A non-fragment resource with the {@link #IDENTITY_TYPE_BUNDLE
148
	 * osgi.bundle} type {@link #IDENTITY_TYPE_ATTRIBUTE identity} provides 
149
	 * exactly one <sup>&#8224;</sup> bundle
150
	 * {@link Resource#getCapabilities(String) capability} (that is, the bundle
151
	 * can be required by another bundle). A fragment resource with the 
152
	 * {@link #IDENTITY_TYPE_FRAGMENT osgi.fragment} type 
153
	 * {@link #IDENTITY_TYPE_ATTRIBUTE identity} must not declare
154
	 * a bundle capability. A resource requires zero or more bundle
155
	 * {@link Resource#getRequirements(String) requirements} (that is, required
156
	 * bundles).
157
	 * <p>
158
	 * &#8224; A resource with no symbolic name must not provide a bundle
159
	 * capability.
160
	 */
161
	public static final String WIRING_BUNDLE_NAMESPACE = "osgi.wiring.bundle";
162
163
	/**
164
	 * Name space for host capabilities and requirements.
165
	 * 
166
	 * For capability attributes the following applies:
167
	 * <ul>
168
	 * <li>The
169
	 * <q>osgi.wiring.host</q> attribute contains the symbolic name of the
170
	 * bundle.
171
	 * <li>The {@link Constants#BUNDLE_VERSION_ATTRIBUTE bundle-version}
172
	 * attribute contains the {@link Version} of the bundle if one is specified
173
	 * or {@link Version#emptyVersion} if not specified.
174
	 * <li>All other attributes are of type {@link String} and are used as
175
	 * arbitrary matching attributes for the capability.
176
	 * </ul>
177
	 * <p>
178
	 * <p>
179
	 * A non-fragment resource with the with the {@link #IDENTITY_TYPE_BUNDLE
180
	 * osgi.bundle} type {@link #IDENTITY_TYPE_ATTRIBUTE identity} provides 
181
	 * zero or one <sup>&#8224;</sup> host
182
	 * {@link Resource#getCapabilities(String) capabilities}. 
183
	 * A fragment resource with the 
184
	 * {@link #IDENTITY_TYPE_FRAGMENT osgi.fragment} type 
185
	 * {@link #IDENTITY_TYPE_ATTRIBUTE identity} must not declare
186
	 * a host capability and must 
187
	 * {@link Resource#getRequirements(String) declare} exactly one host
188
	 * requirement.
189
	 * <p>
190
	 * &#8224; A resource with no bundle symbolic name must not provide a host
191
	 * capability.
192
	 */
193
	public static final String WIRING_HOST_NAMESPACE = "osgi.wiring.host";
194
195
	/**
196
	 * A requirement {@link Requirement#getDirectives() directive} used to
197
	 * specify a capability filter. This filter is used to match against a
198
	 * capability's {@link Capability#getAttributes() attributes}.
199
	 */
200
	public final static String REQUIREMENT_FILTER_DIRECTIVE = Constants.FILTER_DIRECTIVE;
201
202
	/**
203
	 * A requirement {@link Requirement#getDirectives() directive} used to
204
	 * specify the resolution type for a requirement. The default value is
205
	 * {@link #REQUIREMENT_RESOLUTION_MANDATORY mandatory}.
206
	 * 
207
	 * @see #REQUIREMENT_RESOLUTION_MANDATORY mandatory
208
	 * @see #REQUIREMENT_RESOLUTION_OPTIONAL optional
209
	 */
210
	public final static String REQUIREMENT_RESOLUTION_DIRECTIVE = Constants.RESOLUTION_DIRECTIVE;
211
	/**
212
	 * A directive value identifying a mandatory
213
	 * {@link Resource#getRequirements(String) requirement} resolution type. A
214
	 * mandatory resolution type indicates that the requirement must be resolved
215
	 * when the {@link Resource resource} is resolved. If such requirement
216
	 * cannot be resolved, the resource fails to resolve.
217
	 * 
218
	 * @see #REQUIREMENT_RESOLUTION_DIRECTIVE
219
	 */
220
	public final static String REQUIREMENT_RESOLUTION_MANDATORY = Constants.RESOLUTION_MANDATORY;
221
222
	/**
223
	 * A directive value identifying an optional
224
	 * {@link Resource#getRequirements(String) requirement} resolution type. An
225
	 * optional resolution type indicates that the requirement is optional and
226
	 * the {@link Resource resource} may be resolved without requirement being
227
	 * resolved.
228
	 * 
229
	 * @see #REQUIREMENT_RESOLUTION_DIRECTIVE
230
	 */
231
	public final static String REQUIREMENT_RESOLUTION_OPTIONAL = Constants.RESOLUTION_OPTIONAL;
232
233
	/**
234
	 * A requirement {@link Requirement#getDirectives() directive} used to
235
	 * specify the effective time for the requirement. The default value is
236
	 * {@link #EFFECTIVE_RESOLVE resolve}.
237
	 * 
238
	 * @see #EFFECTIVE_RESOLVE resolve
239
	 * @see #EFFECTIVE_ACTIVE active
240
	 */
241
	public final static String REQUIREMENT_EFFECTIVE_DIRECTIVE = Constants.EFFECTIVE_DIRECTIVE;
242
243
	/**
244
	 * A directive value identifying a {@link #CAPABILITY_EFFECTIVE_DIRECTIVE
245
	 * capability} or {@link #REQUIREMENT_EFFECTIVE_DIRECTIVE requirement} that
246
	 * is effective at resolve time. Capabilities and requirements with an
247
	 * effective time of resolve are the only capabilities which are processed
248
	 * while resolving a resource.
249
	 * 
250
	 * @see #REQUIREMENT_EFFECTIVE_DIRECTIVE
251
	 * @see #CAPABILITY_EFFECTIVE_DIRECTIVE
252
	 */
253
	public final static String EFFECTIVE_RESOLVE = Constants.EFFECTIVE_RESOLVE;
254
255
	/**
256
	 * A directive value identifying a {@link #CAPABILITY_EFFECTIVE_DIRECTIVE
257
	 * capability} or {@link #REQUIREMENT_EFFECTIVE_DIRECTIVE requirement} that
258
	 * is effective at active time. Capabilities and requirements with an
259
	 * effective time of active are ignored while resolving a resource.
260
	 * 
261
	 * @see #REQUIREMENT_EFFECTIVE_DIRECTIVE
262
	 * @see #CAPABILITY_EFFECTIVE_DIRECTIVE
263
	 */
264
	public final static String EFFECTIVE_ACTIVE = Constants.EFFECTIVE_ACTIVE;
265
266
	/**
267
	 * A requirement {@link Requirement#getDirectives() directive} used to
268
	 * specify the visibility type for a requirement. The default value is
269
	 * {@link #REQUIREMENT_VISIBILITY_PRIVATE private}. This directive must only
270
	 * be used for requirements with the require
271
	 * {@link #WIRING_BUNDLE_NAMESPACE bundle} name space.
272
	 * 
273
	 * @see #REQUIREMENT_VISIBILITY_PRIVATE private
274
	 * @see #REQUIREMENT_VISIBILITY_REEXPORT reexport
275
	 */
276
	public final static String REQUIREMENT_VISIBILITY_DIRECTIVE = Constants.VISIBILITY_DIRECTIVE;
277
278
	/**
279
	 * A directive value identifying a private
280
	 * {@link #REQUIREMENT_VISIBILITY_DIRECTIVE visibility} type. A private
281
	 * visibility type indicates that any {@link #WIRING_PACKAGE_NAMESPACE
282
	 * packages} that are exported by the required
283
	 * {@link #WIRING_BUNDLE_NAMESPACE bundle} are not made visible on the
284
	 * export signature of the requiring {@link #WIRING_BUNDLE_NAMESPACE bundle}
285
	 * .
286
	 * 
287
	 * @see #REQUIREMENT_VISIBILITY_DIRECTIVE
288
	 */
289
	public final static String REQUIREMENT_VISIBILITY_PRIVATE = Constants.VISIBILITY_PRIVATE;
290
291
	/**
292
	 * A directive value identifying a reexport
293
	 * {@link #REQUIREMENT_VISIBILITY_DIRECTIVE visibility} type. A reexport
294
	 * visibility type indicates any {@link #WIRING_PACKAGE_NAMESPACE packages}
295
	 * that are exported by the required {@link #WIRING_BUNDLE_NAMESPACE bundle}
296
	 * are re-exported by the requiring {@link #WIRING_BUNDLE_NAMESPACE bundle}.
297
	 */
298
	public final static String REQUIREMENT_VISIBILITY_REEXPORT = Constants.VISIBILITY_REEXPORT;
299
300
	/**
301
	 * A requirement {@link Requirement#getDirectives() directive} used to
302
	 * specify the cardinality for a requirement. The default value is
303
	 * {@link #REQUIREMENT_CARDINALITY_SINGULAR singular}.
304
	 * 
305
	 * @see #REQUIREMENT_CARDINALITY_MULTIPLE multiple
306
	 * @see #REQUIREMENT_CARDINALITY_SINGULAR singular
307
	 */
308
	public final static String REQUIREMENT_CARDINALITY_DIRECTIVE = "cardinality";
309
310
	/**
311
	 * A directive value identifying a multiple
312
	 * {@link #REQUIREMENT_CARDINALITY_DIRECTIVE cardinality} type.
313
	 */
314
	public final static String REQUIREMENT_CARDINALITY_MULTIPLE = "multiple";
315
316
	/**
317
	 * A directive value identifying a singular
318
	 * {@link #REQUIREMENT_CARDINALITY_DIRECTIVE cardinality} type.
319
	 */
320
	public final static String REQUIREMENT_CARDINALITY_SINGULAR = "singular";
321
322
	/**
323
	 * A capability {@link Capability#getDirectives() directive} used to specify
324
	 * the comma separated list of {@link #WIRING_PACKAGE_NAMESPACE package}
325
	 * names a capability uses.
326
	 */
327
	public final static String CAPABILITY_USES_DIRECTIVE = Constants.USES_DIRECTIVE;
328
329
	/**
330
	 * A capability {@link Capability#getDirectives() directive} used to specify
331
	 * the effective time for the capability. The default value is
332
	 * {@link #EFFECTIVE_RESOLVE resolve}.
333
	 * 
334
	 * @see #EFFECTIVE_RESOLVE resolve
335
	 * @see #EFFECTIVE_ACTIVE active
336
	 */
337
	public final static String CAPABILITY_EFFECTIVE_DIRECTIVE = Constants.EFFECTIVE_DIRECTIVE;
338
339
	/**
340
	 * A capability {@link Capability#getDirectives() directive} used to specify
341
	 * the comma separated list of mandatory attributes which must be specified
342
	 * in the {@link #REQUIREMENT_FILTER_DIRECTIVE filter} of a requirement in
343
	 * order for the capability to match the requirement. This directive must
344
	 * only be used for capabilities with the {@link #WIRING_PACKAGE_NAMESPACE
345
	 * package} name space.
346
	 */
347
	public final static String CAPABILITY_MANDATORY_DIRECTIVE = "mandatory";
348
349
	/**
350
	 * A capability {@link Capability#getDirectives() directive} used to specify
351
	 * the comma separated list of classes which must be allowed to be exported.
352
	 * This directive must only be used for capabilities with the
353
	 * {@link #WIRING_PACKAGE_NAMESPACE package} name space.
354
	 */
355
	public final static String CAPABILITY_INCLUDE_DIRECTIVE = "include";
356
357
	/**
358
	 * A capability {@link Capability#getDirectives() directive} used to specify
359
	 * the comma separated list of classes which must not be allowed to be
360
	 * exported. This directive must only be used for capabilities with the
361
	 * {@link #WIRING_PACKAGE_NAMESPACE package} name space.
362
	 */
363
	public final static String CAPABILITY_EXCLUDE_DIRECTIVE = "exclude";
364
}
(-)osgi/src/org/osgi/framework/wiring/Wire.java (+57 lines)
Added Link Here
1
/*
2
 * Copyright (c) OSGi Alliance (2011). All Rights Reserved.
3
 * 
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *      http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
17
package org.osgi.framework.wiring;
18
19
/**
20
 * A wire connecting a {@link Capability} to a {@link Requirement}.
21
 * 
22
 * @ThreadSafe
23
 * @version $Id: 328ede0f8ddf3795594a8e0fc2cb11bbe7fa38fc $
24
 */
25
public interface Wire {
26
	/**
27
	 * Returns the {@link Capability} for this wire.
28
	 * 
29
	 * @return The {@link Capability} for this wire.
30
	 */
31
	Capability getCapability();
32
33
	/**
34
	 * Return the {@link Requirement} for this wire.
35
	 * 
36
	 * @return The {@link Requirement} for this wire.
37
	 */
38
	Requirement getRequirement();
39
40
	/**
41
	 * Return the providing {@link Resource resource} of the {@link #getCapability() capability}.
42
	 * <p>
43
	 * The resource returned may differ from the resource referenced by the {@link #getCapability()
44
	 * capability}.
45
	 * @return the providing {@link Resource resource}.
46
	 */
47
	Resource getProvider();
48
49
	/**
50
	 * Return the requiring {@link Resource resource} of the {@link #getRequirement() requirement}.
51
	 * <p>
52
	 * The resource returned my differ from the resource referenced by the {@link #getRequirement()
53
	 * requirement}
54
	 * @return the requiring {@link Resource resource}.
55
	 */
56
	Resource getRequirer();
57
}
(-)resolver/src/org/eclipse/osgi/internal/resolver/BaseDescriptionImpl.java (+4 lines)
Lines 156-160 Link Here
156
		public String toString() {
156
		public String toString() {
157
			return getNamespace() + BaseDescriptionImpl.toString(getAttributes(), false) + BaseDescriptionImpl.toString(getDirectives(), true);
157
			return getNamespace() + BaseDescriptionImpl.toString(getAttributes(), false) + BaseDescriptionImpl.toString(getDirectives(), true);
158
		}
158
		}
159
160
		public BundleRevision getResource() {
161
			return getRevision();
162
		}
159
	}
163
	}
160
}
164
}
(-)resolver/src/org/eclipse/osgi/internal/resolver/BundleDescriptionImpl.java (+18 lines)
Lines 1031-1036 Link Here
1031
		public String toString() {
1031
		public String toString() {
1032
			return getRequirement() + " -> " + getCapability(); //$NON-NLS-1$
1032
			return getRequirement() + " -> " + getCapability(); //$NON-NLS-1$
1033
		}
1033
		}
1034
1035
		public BundleRevision getProvider() {
1036
			return getCapability().getRevision();
1037
		}
1038
1039
		public BundleRevision getRequirer() {
1040
			return getRequirement().getRevision();
1041
		}
1034
	}
1042
	}
1035
1043
1036
	// Note that description wiring are identity equality based
1044
	// Note that description wiring are identity equality based
Lines 1230-1233 Link Here
1230
			return BundleDescriptionImpl.this.toString();
1238
			return BundleDescriptionImpl.this.toString();
1231
		}
1239
		}
1232
	}
1240
	}
1241
1242
	@SuppressWarnings({"cast", "unchecked", "rawtypes"})
1243
	public List<Capability> getCapabilities(String namespace) {
1244
		return (List<Capability>) (List) getDeclaredCapabilities(namespace);
1245
	}
1246
1247
	@SuppressWarnings({"cast", "unchecked", "rawtypes"})
1248
	public List<Requirement> getRequirements(String namespace) {
1249
		return (List<Requirement>) (List) getDeclaredRequirements(namespace);
1250
	}
1233
}
1251
}
(-)resolver/src/org/eclipse/osgi/internal/resolver/StateBuilder.java (-3 / +29 lines)
Lines 19-24 Link Here
19
import org.eclipse.osgi.util.ManifestElement;
19
import org.eclipse.osgi.util.ManifestElement;
20
import org.eclipse.osgi.util.NLS;
20
import org.eclipse.osgi.util.NLS;
21
import org.osgi.framework.*;
21
import org.osgi.framework.*;
22
import org.osgi.framework.wiring.ResourceConstants;
22
23
23
/**
24
/**
24
 * This class builds bundle description objects from manifests
25
 * This class builds bundle description objects from manifests
Lines 118-124 Link Here
118
		result.setGenericRequires(createGenericRequires(genericRequires, osgiRequires));
119
		result.setGenericRequires(createGenericRequires(genericRequires, osgiRequires));
119
		ManifestElement[] genericCapabilities = getGenericCapabilities(manifest, genericAliases);
120
		ManifestElement[] genericCapabilities = getGenericCapabilities(manifest, genericAliases);
120
		ManifestElement[] osgiCapabilities = ManifestElement.parseHeader(Constants.PROVIDE_CAPABILITY, manifest.get(Constants.PROVIDE_CAPABILITY));
121
		ManifestElement[] osgiCapabilities = ManifestElement.parseHeader(Constants.PROVIDE_CAPABILITY, manifest.get(Constants.PROVIDE_CAPABILITY));
121
		result.setGenericCapabilities(createGenericCapabilities(genericCapabilities, osgiCapabilities));
122
		result.setGenericCapabilities(createGenericCapabilities(genericCapabilities, osgiCapabilities, result));
122
		ManifestElement[] nativeCode = ManifestElement.parseHeader(Constants.BUNDLE_NATIVECODE, manifest.get(Constants.BUNDLE_NATIVECODE));
123
		ManifestElement[] nativeCode = ManifestElement.parseHeader(Constants.BUNDLE_NATIVECODE, manifest.get(Constants.BUNDLE_NATIVECODE));
123
		result.setNativeCodeSpecification(createNativeCode(nativeCode));
124
		result.setNativeCodeSpecification(createNativeCode(nativeCode));
124
		return result;
125
		return result;
Lines 554-565 Link Here
554
		return results;
555
		return results;
555
	}
556
	}
556
557
557
	private static GenericDescription[] createGenericCapabilities(ManifestElement[] equinoxCapabilities, ManifestElement[] osgiCapabilities) {
558
	private static GenericDescription[] createGenericCapabilities(ManifestElement[] equinoxCapabilities, ManifestElement[] osgiCapabilities, BundleDescription description) {
558
		List<GenericDescription> result = createEquinoxCapabilities(equinoxCapabilities);
559
		List<GenericDescription> result = createEquinoxCapabilities(equinoxCapabilities);
559
		result = createOSGiCapabilities(osgiCapabilities, result);
560
		result = createOSGiCapabilities(osgiCapabilities, result, description);
560
		return result == null ? null : result.toArray(new GenericDescription[result.size()]);
561
		return result == null ? null : result.toArray(new GenericDescription[result.size()]);
561
	}
562
	}
562
563
564
	private static List<GenericDescription> createOSGiCapabilities(ManifestElement[] osgiCapabilities, List<GenericDescription> result, BundleDescription description) {
565
		if (result == null)
566
			result = new ArrayList<GenericDescription>(osgiCapabilities == null ? 10 : osgiCapabilities.length + 1);
567
		// Always have an osgi.identity capability.
568
		result.add(createOsgiIdentityCapability(description));
569
		return createOSGiCapabilities(osgiCapabilities, result);
570
	}
571
563
	static List<GenericDescription> createOSGiCapabilities(ManifestElement[] osgiCapabilities, List<GenericDescription> result) {
572
	static List<GenericDescription> createOSGiCapabilities(ManifestElement[] osgiCapabilities, List<GenericDescription> result) {
564
		if (osgiCapabilities == null)
573
		if (osgiCapabilities == null)
565
			return result;
574
			return result;
Lines 570-575 Link Here
570
			String[] namespaces = element.getValueComponents();
579
			String[] namespaces = element.getValueComponents();
571
			types: for (String namespace : namespaces) {
580
			types: for (String namespace : namespaces) {
572
				String effective = element.getDirective(Constants.EFFECTIVE_DIRECTIVE);
581
				String effective = element.getDirective(Constants.EFFECTIVE_DIRECTIVE);
582
				// Any declared osgi.identity capability with an effective directive value of "resolve" will be overridden.
573
				if (effective != null && !Constants.EFFECTIVE_RESOLVE.equals(effective))
583
				if (effective != null && !Constants.EFFECTIVE_RESOLVE.equals(effective))
574
					break types; // ignore any namespace that is not effective at resolve time.
584
					break types; // ignore any namespace that is not effective at resolve time.
575
				GenericDescriptionImpl desc = new GenericDescriptionImpl();
585
				GenericDescriptionImpl desc = new GenericDescriptionImpl();
Lines 748-751 Link Here
748
			throw new BundleException(message + " : " + NLS.bind(StateMsg.HEADER_EXTENSION_ERROR, hostName), BundleException.MANIFEST_ERROR); //$NON-NLS-1$
758
			throw new BundleException(message + " : " + NLS.bind(StateMsg.HEADER_EXTENSION_ERROR, hostName), BundleException.MANIFEST_ERROR); //$NON-NLS-1$
749
		}
759
		}
750
	}
760
	}
761
762
	private static GenericDescription createOsgiIdentityCapability(BundleDescription description) {
763
		GenericDescriptionImpl result = new GenericDescriptionImpl();
764
		result.setType(ResourceConstants.IDENTITY_NAMESPACE);
765
		Dictionary<String, Object> attributes = new Hashtable<String, Object>();
766
		attributes.put(ResourceConstants.IDENTITY_NAMESPACE, description.getSymbolicName());
767
		attributes.put(ResourceConstants.IDENTITY_TYPE_ATTRIBUTE, description.getHost() == null ? ResourceConstants.IDENTITY_TYPE_BUNDLE : ResourceConstants.IDENTITY_TYPE_FRAGMENT);
768
		attributes.put(ResourceConstants.IDENTITY_VERSION_ATTRIBUTE, description.getVersion());
769
		result.setAttributes(attributes);
770
		Map<String, String> directives = new HashMap<String, String>();
771
		directives.put(ResourceConstants.IDENTITY_SINGLETON_DIRECTIVE, String.valueOf(description.isSingleton()));
772
		// The effective directive needs to be set to anything but "resolve".
773
		directives.put(ResourceConstants.CAPABILITY_EFFECTIVE_DIRECTIVE, ResourceConstants.EFFECTIVE_ACTIVE);
774
		result.setDirectives(directives);
775
		return result;
776
	}
751
}
777
}
(-)resolver/src/org/eclipse/osgi/internal/resolver/VersionConstraintImpl.java (+10 lines)
Lines 156-161 Link Here
156
		public String toString() {
156
		public String toString() {
157
			return getNamespace() + BaseDescriptionImpl.toString(getAttributes(), false) + BaseDescriptionImpl.toString(getDirectives(), true);
157
			return getNamespace() + BaseDescriptionImpl.toString(getAttributes(), false) + BaseDescriptionImpl.toString(getDirectives(), true);
158
		}
158
		}
159
160
		public boolean matches(Capability capability) {
161
			if (!(capability instanceof BundleCapability))
162
				return false;
163
			return matches((BundleCapability) capability);
164
		}
165
166
		public BundleRevision getResource() {
167
			return getRevision();
168
		}
159
	}
169
	}
160
170
161
	static StringBuffer addFilterAttributes(StringBuffer filter, Map<String, ?> attributes) {
171
	static StringBuffer addFilterAttributes(StringBuffer filter, Map<String, ?> attributes) {
(-)src/org/eclipse/osgi/tests/services/resolver/GenericCapabilityTest.java (-7 / +19 lines)
Lines 255-261 Link Here
255
		required.append("foo; selection-filter=\"(version>=1.3.0)\",");
255
		required.append("foo; selection-filter=\"(version>=1.3.0)\",");
256
		required.append("bar:bartype; selection-filter=\"(attr1=value1)\",");
256
		required.append("bar:bartype; selection-filter=\"(attr1=value1)\",");
257
		required.append("test.types:testtype; selection-filter=\"(&(aVersion>=2.0.0)(aLong>=5555)(aDouble>=1.00)(aUri=file:/test)(aSet=c)(aString=someString))\",");
257
		required.append("test.types:testtype; selection-filter=\"(&(aVersion>=2.0.0)(aLong>=5555)(aDouble>=1.00)(aUri=file:/test)(aSet=c)(aString=someString))\",");
258
		required.append("fragmentStuff");
258
		required.append("*:osgi.identity; selection-filter=\"(&(osgi.identity=genericCapablity)(version=1.0.0)(type=osgi.bundle))\",");
259
		required.append("fragmentStuff,");
260
		required.append("*:osgi.identity; selection-filter=\"(&(osgi.identity=genericCapability.frag1)(version=1.0.0)(type=osgi.fragment))\"");
259
		manifest.put(GENERIC_REQUIRE, required.toString());
261
		manifest.put(GENERIC_REQUIRE, required.toString());
260
		BundleDescription genReq = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME), bundleID++);
262
		BundleDescription genReq = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME), bundleID++);
261
263
Lines 269-276 Link Here
269
		assertTrue("1.2", genCapFrag.isResolved());
271
		assertTrue("1.2", genCapFrag.isResolved());
270
		GenericSpecification[] genSpecs = genReq.getGenericRequires();
272
		GenericSpecification[] genSpecs = genReq.getGenericRequires();
271
		GenericDescription[] selectedCapabilities = genCap.getSelectedGenericCapabilities();
273
		GenericDescription[] selectedCapabilities = genCap.getSelectedGenericCapabilities();
272
		assertTrue("2.0", genSpecs.length == 4);
274
		assertTrue("2.0", genSpecs.length == 6);
273
		assertEquals("Wrong number of selected capabilities", 4, selectedCapabilities.length);
275
		assertEquals("Wrong number of selected capabilities", 6, selectedCapabilities.length);
274
		assertTrue("2.1", genSpecs[0].isResolved());
276
		assertTrue("2.1", genSpecs[0].isResolved());
275
		assertEquals("2.1.1", genSpecs[0].getSupplier(), selectedCapabilities[0]);
277
		assertEquals("2.1.1", genSpecs[0].getSupplier(), selectedCapabilities[0]);
276
		assertTrue("2.2", genSpecs[1].isResolved());
278
		assertTrue("2.2", genSpecs[1].isResolved());
Lines 279-284 Link Here
279
		assertEquals("2.3.1", genSpecs[2].getSupplier(), selectedCapabilities[2]);
281
		assertEquals("2.3.1", genSpecs[2].getSupplier(), selectedCapabilities[2]);
280
		assertTrue("2.4", genSpecs[3].isResolved());
282
		assertTrue("2.4", genSpecs[3].isResolved());
281
		assertEquals("2.4.1", genSpecs[3].getSupplier(), selectedCapabilities[3]);
283
		assertEquals("2.4.1", genSpecs[3].getSupplier(), selectedCapabilities[3]);
284
		assertTrue("2.5", genSpecs[4].isResolved());
285
		assertEquals("2.5.1", genSpecs[4].getSupplier(), selectedCapabilities[4]);
286
		assertTrue("2.6", genSpecs[5].isResolved());
287
		assertEquals("2.6.1", genSpecs[5].getSupplier(), selectedCapabilities[5]);
282
	}
288
	}
283
289
284
	public void testGenericsIntraFrags() throws BundleException {
290
	public void testGenericsIntraFrags() throws BundleException {
Lines 304-310 Link Here
304
		manifest.put(Constants.BUNDLE_SYMBOLICNAME, "org.eclipse.equinox.generic.frag.b");
310
		manifest.put(Constants.BUNDLE_SYMBOLICNAME, "org.eclipse.equinox.generic.frag.b");
305
		manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
311
		manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
306
		manifest.put(Constants.FRAGMENT_HOST, "org.eclipse.equinox.generic.host;bundle-version=\"1.0.0\"");
312
		manifest.put(Constants.FRAGMENT_HOST, "org.eclipse.equinox.generic.host;bundle-version=\"1.0.0\"");
307
		manifest.put("Eclipse-GenericRequire", "frag.a");
313
		StringBuffer required = new StringBuffer();
314
		required.append("*:osgi.identity; selection-filter=\"(&(osgi.identity=org.eclipse.equinox.generic.host)(version=1.0.0)(type=osgi.bundle))\",");
315
		required.append("frag.a,");
316
		required.append("*:osgi.identity; selection-filter=\"(&(osgi.identity=org.eclipse.equinox.generic.frag.a)(version=1.0.0)(type=osgi.fragment))\"");
317
		manifest.put(GENERIC_REQUIRE, required.toString());
308
		BundleDescription genFragB = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME), bundleID++);
318
		BundleDescription genFragB = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME), bundleID++);
309
319
310
		state.addBundle(genHost);
320
		state.addBundle(genHost);
Lines 317-326 Link Here
317
		assertTrue("1.2", genFragB.isResolved());
327
		assertTrue("1.2", genFragB.isResolved());
318
		GenericSpecification[] genSpecs = genFragB.getGenericRequires();
328
		GenericSpecification[] genSpecs = genFragB.getGenericRequires();
319
		GenericDescription[] selected = genHost.getSelectedGenericCapabilities();
329
		GenericDescription[] selected = genHost.getSelectedGenericCapabilities();
320
		assertEquals("Wrong number of selected", 1, selected.length);
330
		assertEquals("Wrong number of selected", 3 + 1, selected.length); // + 1 for fragB osgi.identity cap
321
		assertTrue("2.0", genSpecs.length == 1);
331
		assertTrue("2.0", genSpecs.length == 3);
322
		assertTrue("2.1", genSpecs[0].isResolved());
332
		assertTrue("2.1", genSpecs[0].isResolved());
323
		assertEquals("2.1.1", genSpecs[0].getSupplier(), selected[0]);
333
		assertEquals("2.1.1", genSpecs[0].getSupplier(), selected[0]);
334
		assertEquals("2.1.2", genSpecs[1].getSupplier(), selected[1]);
335
		assertEquals("2.1.3", genSpecs[2].getSupplier(), selected[2]);
324
	}
336
	}
325
337
326
	public void testGenericsAliases() throws BundleException {
338
	public void testGenericsAliases() throws BundleException {
Lines 481-487 Link Here
481
		GenericSpecification[] genSpecs = genReq.getGenericRequires();
493
		GenericSpecification[] genSpecs = genReq.getGenericRequires();
482
		GenericDescription[] selected = genCap.getSelectedGenericCapabilities();
494
		GenericDescription[] selected = genCap.getSelectedGenericCapabilities();
483
		assertTrue("2.0", genSpecs.length == 4);
495
		assertTrue("2.0", genSpecs.length == 4);
484
		assertEquals("Wrong number of selected", 4, selected.length);
496
		assertEquals("Wrong number of selected", 4 + 2, selected.length); // + 2 for host and frag osgi.identity caps
485
		assertTrue("2.1", genSpecs[0].isResolved());
497
		assertTrue("2.1", genSpecs[0].isResolved());
486
		assertEquals("2.1.1", genSpecs[0].getSupplier(), selected[0]);
498
		assertEquals("2.1.1", genSpecs[0].getSupplier(), selected[0]);
487
		assertTrue("2.2", genSpecs[1].isResolved());
499
		assertTrue("2.2", genSpecs[1].isResolved());
(-)test_files/genericCapability/c1.osgi.MF (-1 / +3 lines)
Lines 17-20 Link Here
17
  filter:="(&(rank>=100)(!(rank>=200))
17
  filter:="(&(rank>=100)(!(rank>=200))
18
          (percent>=0.1)(!(percent>=0.2))
18
          (percent>=0.1)(!(percent>=0.2))
19
          (test.version>=1.0)(!(test.version>=2.0))
19
          (test.version>=1.0)(!(test.version>=2.0))
20
          (test.string~=abc))"
20
          (test.string~=abc))",
21
 osgi.identity;
22
  filter:="(&(osgi.identity=p1.osgi)(version=1.0)(type=osgi.bundle))"
(-)test_files/genericCapability/c2.osgi.MF (-1 / +3 lines)
Lines 17-20 Link Here
17
  filter:="(&(rank>=200)(!(rank>=300))
17
  filter:="(&(rank>=200)(!(rank>=300))
18
          (percent>=0.2)(!(percent>=0.3))
18
          (percent>=0.2)(!(percent>=0.3))
19
          (test.version>=2.0)(!(test.version>=3.0))
19
          (test.version>=2.0)(!(test.version>=3.0))
20
          (test.string~=abc))"
20
          (test.string~=abc))",
21
 osgi.identity;
22
  filter:="(&(osgi.identity=p2.osgi)(version=1.0)(type=osgi.bundle))"
(-)test_files/genericCapability/c3.osgi.MF (-1 / +3 lines)
Lines 17-20 Link Here
17
  filter:="(&(rank>=300)(!(rank>=400))
17
  filter:="(&(rank>=300)(!(rank>=400))
18
          (percent>=0.3)(!(percent>=0.4))
18
          (percent>=0.3)(!(percent>=0.4))
19
          (test.version>=3.0)(!(test.version>=4.0))
19
          (test.version>=3.0)(!(test.version>=4.0))
20
          (test.string~=abc))"
20
          (test.string~=abc))",
21
 osgi.identity;
22
  filter:="(&(osgi.identity=p3.osgi)(version=1.0)(type=osgi.bundle))"

Return to bug 349618