Debian Codegraph @

src/aQute/bnd/annotation/service/ServiceCapability.java

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
•1 package aQute.bnd.annotation.service;
2
3 import static aQute.bnd.annotation.spi.Constants.ATTRIBUTE_MACRO;
4
5 import java.lang.annotation.ElementType;
6 import java.lang.annotation.Repeatable;
7 import java.lang.annotation.Retention;
8 import java.lang.annotation.RetentionPolicy;
9 import java.lang.annotation.Target;
10
11 import org.osgi.annotation.bundle.Capability;
12 import org.osgi.namespace.service.ServiceNamespace;
13 import org.osgi.resource.Namespace;;
14
15 /**
16 * Adds a ProvideCapability for a service. This is useful to the resolver, when
17 * a service is registered manually. It can annotate a class or a package. If it
18 * annotates a class without specifying a value, the class will be named as the
19 * registered service. Uses constraints will be calculated automatically.
20 */
21 @Retention(RetentionPolicy.CLASS)
22 @Target({
23 ElementType.TYPE, ElementType.PACKAGE
24 })
25 @Repeatable(ServiceCapabilities.class)
26 @Capability(namespace = ServiceNamespace.SERVICE_NAMESPACE, //
27 attribute = {
28 ServiceNamespace.CAPABILITY_OBJECTCLASS_ATTRIBUTE + ":List<String>=\"${uniq;${#value}}\"", //
29 Namespace.CAPABILITY_USES_DIRECTIVE
30 + ":=\"${if;${size;${#uses}};${#uses};${uniq;${replace;${#value};(.*)\\.[^.]+;$1}}}\"",
31 ATTRIBUTE_MACRO
32 })
33 public @interface ServiceCapability {
34 /**
35 * The service <em>type</em>.
36 *
37 * @return the service type
38 */
39 Class<?> value() default Target.class;
40
41 /**
42 * A list of classes whose packages are inspected to calculate the
43 * {@code uses} directive for this capability.
44 * <p>
45 * If not specified, the {@code uses} directive is omitted from the
46 * capability clause.
47 */
48 Class<?>[] uses() default {};
49
50 /**
51 * A list of attribute or directive names and values.
52 * <p>
53 * Each string should be specified in the form:
54 * <ul>
55 * <li>{@code "name=value"} for attributes.</li>
56 * <li>{@code "name:type=value"} for typed attributes.</li>
57 * <li>{@code "name:=value"} for directives.</li>
58 * </ul>
59 * These are added, separated by semicolons, to the
60 * {@code osgi.serviceloader} capability. Non-standard
61 * {@code osgi.serviceloader} attributes will be included as service
62 * properties to the published service.
63 */
64 String[] attribute() default {};
65 }