Debian Codegraph @

src/org/osgi/annotation/bundle/Requirement.java

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
•1 /*******************************************************************************
2 * Copyright (c) Contributors to the Eclipse Foundation
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 * SPDX-License-Identifier: Apache-2.0
17 *******************************************************************************/
18
19 package org.osgi.annotation.bundle;
20
21 import java.lang.annotation.Documented;
22 import java.lang.annotation.ElementType;
23 import java.lang.annotation.Repeatable;
24 import java.lang.annotation.Retention;
25 import java.lang.annotation.RetentionPolicy;
26 import java.lang.annotation.Target;
27
28 /**
29 * Define a requirement for a bundle.
30 * <p>
31 * For example:
32 *
33 * <pre>
34 * &#64;Requirement(namespace=ExtenderNamespace.EXTENDER_NAMESPACE,
35 * name="osgi.component", version="1.3.0")
36 * </pre>
37 * <p>
38 * This annotation is not retained at runtime. It is for use by tools to
39 * generate bundle manifests or otherwise process the a package.
40 * <p>
41 * This annotation can be used to annotate an annotation.
42 *
43 * @author $Id: 8acf269bcf8de7a1b533c4ffcfb01856232b6c9f $
44 */
45 @Documented
46 @Retention(RetentionPolicy.CLASS)
47 @Target({
48 ElementType.TYPE, ElementType.PACKAGE
49 })
50 @Repeatable(Requirements.class)
51 public @interface Requirement {
52
53 /**
54 * The namespace of this requirement.
55 */
56 String namespace();
57
58 /**
59 * The name of this requirement within the namespace.
60 * <p>
61 * If specified, adds an expression, using the {@code &} operator with any
62 * specified {@link #filter()}, to the requirement's filter directive to
63 * test that an attribute with the name of the namespace is equal to the
64 * value of the specified name.
65 */
66 String name() default "";
67
68 /**
69 * The floor version of the version range for this requirement.
70 * <p>
71 * If specified, adds a version range expression, using the {@code &}
72 * operator with any specified {@link #filter()}, to the requirement's
73 * filter directive. The ceiling version of the version range is the next
74 * major version from the floor version. For example, if the specified
75 * version is {@code 1.3}, then the version range expression is
76 * {@code (&(version>=1.3)(!(version>=2.0)))}.
77 * <p>
78 * The specified version must be a valid OSGi version string.
79 */
80 String version() default "";
81
82 /**
83 * The filter expression of this requirement, if any.
84 */
85 String filter() default "";
86
87 /**
88 * The effective time of this requirement.
89 * <p>
90 * Specifies the time the requirement is available. The OSGi framework
91 * resolver only considers requirement without an effective directive or
92 * effective:=resolve. Requirements with other values for the effective
93 * directive can be considered by an external agent.
94 * <p>
95 * If not specified, the {@code effective} directive is omitted from the
96 * requirement clause.
97 */
98 String effective() default "resolve"; // Namespace.EFFECTIVE_RESOLVE
99
100 /**
101 * A list of attribute or directive names and values.
102 * <p>
103 * Each string should be specified in the form:
104 * <ul>
105 * <li>{@code "name=value"} for attributes.</li>
106 * <li>{@code "name:type=value"} for typed attributes.</li>
107 * <li>{@code "name:=value"} for directives.</li>
108 * </ul>
109 * These are added, separated by semicolons, to the requirement clause.
110 */
111 String[] attribute() default {};
112
113 /**
114 * The cardinality of this requirement.
115 * <p>
116 * Indicates if this requirement can be wired a single time or multiple
117 * times.
118 * <p>
119 * If not specified, the {@code cardinality} directive is omitted from the
120 * requirement clause.
121 */
122 String cardinality() default Cardinality.SINGLE;
123
124 /**
125 * Cardinality for this requirement.
126 */
127 public final class Cardinality {
128 private Cardinality() {
129 }
130 /**
131 * Indicates if the requirement can only be wired a single time.
132 */
133 public static final String SINGLE = "SINGLE"; // Namespace.CARDINALITY_SINGLE
134
135 /**
136 * Indicates if the requirement can be wired multiple times.
137 */
138 public static final String MULTIPLE = "MULTIPLE"; // Namespace.CARDINALITY_MULTIPLE
139 }
140
141 /**
142 * The resolution policy of this requirement.
143 * <p>
144 * A mandatory requirement forbids the bundle to resolve when this
145 * requirement is not satisfied; an optional requirement allows a bundle to
146 * resolve even if this requirement is not satisfied.
147 * <p>
148 * If not specified, the {@code resolution} directive is omitted from the
149 * requirement clause.
150 */
151 String resolution() default Resolution.MANDATORY;
152
153 /**
154 * Resolution for this requirement.
155 */
156 public final class Resolution {
157 private Resolution() {
158 }
159 /**
160 * A mandatory requirement forbids the bundle to resolve when the
161 * requirement is not satisfied.
162 */
163 public static final String MANDATORY = "MANDATORY"; // Namespace.RESOLUTION_MANDATORY
164
165 /**
166 * An optional requirement allows a bundle to resolve even if the
167 * requirement is not satisfied.
168 */
169 public static final String OPTIONAL = "OPTIONAL"; // Namespace.RESOLUTION_OPTIONAL
170 }
171 }