Debian Codegraph @

src/aQute/bnd/annotation/spi/ServiceProvider.java

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
•1 package aQute.bnd.annotation.spi;
2
3 import static aQute.bnd.annotation.Constants.EFFECTIVE_MACRO;
4 import static aQute.bnd.annotation.Constants.RESOLUTION_MACRO;
5 import static aQute.bnd.annotation.Constants.USES_MACRO;
6 import static aQute.bnd.annotation.spi.Constants.ATTRIBUTE_MACRO;
7 import static aQute.bnd.annotation.spi.Constants.REGISTER_MACRO;
8 import static aQute.bnd.annotation.spi.Constants.SERVICELOADER_REGISTRAR;
9 import static aQute.bnd.annotation.spi.Constants.SERVICELOADER_VERSION;
10 import static aQute.bnd.annotation.spi.Constants.SERVICE_MACRO;
11 import static aQute.bnd.annotation.spi.Constants.VALUE_MACRO;
12 import static java.lang.annotation.ElementType.PACKAGE;
13 import static java.lang.annotation.ElementType.TYPE;
14 import static java.lang.annotation.RetentionPolicy.CLASS;
15 import static org.osgi.namespace.extender.ExtenderNamespace.EXTENDER_NAMESPACE;
16 import static org.osgi.namespace.service.ServiceNamespace.SERVICE_NAMESPACE;
17 import static org.osgi.resource.Namespace.EFFECTIVE_ACTIVE;
18 import static org.osgi.service.serviceloader.ServiceLoaderNamespace.SERVICELOADER_NAMESPACE;
19
20 import java.lang.annotation.Repeatable;
21 import java.lang.annotation.Retention;
22 import java.lang.annotation.Target;
23
24 import org.osgi.annotation.bundle.Capability;
25 import org.osgi.annotation.bundle.Requirement;
26
27 import aQute.bnd.annotation.Resolution;
28
29 /**
30 * Annotation used to generate requirements and capabilities necessary for
31 * supporting the provider side of the <em>Service Loader Mediator</em>
32 * specification.
33 * <p>
34 * Also results in the automatic generation of service descriptor files (a.k.a.
35 * {@code META-INF/services}).
36 *
37 * @see <a href=
38 * "https://osgi.org/specification/osgi.cmpn/7.0.0/service.loader.html">Service
39 * Loader Mediator</a>
40 */
41 @Retention(CLASS)
42 @Target({
43 PACKAGE, TYPE
44 })
45 @Repeatable(ServiceProviders.class)
46 @Capability(name = VALUE_MACRO, namespace = SERVICELOADER_NAMESPACE, attribute = {
47 REGISTER_MACRO, USES_MACRO, ATTRIBUTE_MACRO
48 })
49 @Capability(namespace = SERVICE_NAMESPACE, attribute = {
50 SERVICE_MACRO, USES_MACRO, ATTRIBUTE_MACRO
51 }, effective = EFFECTIVE_ACTIVE)
52 @Requirement(name = SERVICELOADER_REGISTRAR, namespace = EXTENDER_NAMESPACE, version = SERVICELOADER_VERSION, attribute = {
53 EFFECTIVE_MACRO, RESOLUTION_MACRO
54 })
55 public @interface ServiceProvider {
56 /**
57 * The service <em>type</em>.
58 *
59 * @return the service type
60 */
61 Class<?> value();
62
63 /**
64 * The effective time of the {@code osgi.extender} requirement.
65 * <p>
66 * Specifies the time the {@code osgi.extender} requirements are available.
67 * The OSGi framework resolver only considers requirements without an
68 * effective directive or {@code effective:=resolve}. Requirements with
69 * other values for the effective directive can be considered by an external
70 * agent.
71 * <p>
72 * If not specified, the {@code effective} directive is omitted from the
73 * requirement clause.
74 */
75 String effective() default "";
76
77 /**
78 * A list of classes whose packages are inspected to calculate the
79 * {@code uses} directive for this capability.
80 * <p>
81 * If not specified, the {@code uses} directive is omitted from the
82 * capability clause.
83 */
84 Class<?>[] uses() default {};
85
86 /**
87 * A list of attribute or directive names and values.
88 * <p>
89 * Each string should be specified in the form:
90 * <ul>
91 * <li>{@code "name=value"} for attributes.</li>
92 * <li>{@code "name:type=value"} for typed attributes.</li>
93 * <li>{@code "name:=value"} for directives.</li>
94 * </ul>
95 * These are added, separated by semicolons, to the
96 * {@code osgi.serviceloader} capability. Non-standard
97 * {@code osgi.serviceloader} attributes will be included as service
98 * properties to the published service.
99 */
100 String[] attribute() default {};
101
102 /**
103 * The resolution policy of the {@code osgi.extender} requirement.
104 * <p>
105 * A mandatory requirement forbids the bundle to resolve when this
106 * requirement is not satisfied; an optional requirement allows a bundle to
107 * resolve even if this requirement is not satisfied.
108 * <p>
109 * If not specified, the {@code resolution} directive is omitted from the
110 * requirement clause.
111 */
112 String resolution() default Resolution.DEFAULT;
113
114 /**
115 * The type to register as the provider.
116 * <p>
117 * If the annotation used on a package, then {@link #register()} must be
118 * set. It is optional when used on a type using the type as the value.
119 * <p>
120 * The {@code register} directive is omitted from the requirement clause.
121 */
122 Class<?> register() default Target.class;
123
124 }