Closed juergen-albert closed 2 years ago
This is slightly more complex than other cases because of the relationship between the objectclass attribute and the uses constraint directive.
the uses constraint directive
Yes, I was going to point out that the example Capability
lacks the uses
element.
uses={foo.bar.Service.class,fizz.buzz.AnotherService.class}
It seems to me that this is just sugar and not additional functionality.
I was able to author my own ServiceCapability
annotation using existing Bnd function:
@Retention(RetentionPolicy.CLASS)
@Target({
ElementType.TYPE, ElementType.PACKAGE
})
@Capability(namespace = ServiceNamespace.SERVICE_NAMESPACE, //
attribute = {
ServiceNamespace.CAPABILITY_OBJECTCLASS_ATTRIBUTE + ":List<String>=\"${uniq;${#value}}\"", //
Namespace.CAPABILITY_USES_DIRECTIVE + ":=\"${uniq;${replace;${#value};(.*)\\.[^.]+;$1}}\""
})
public @interface ServiceCapability {
Class<?>[] value() default Target.class;
}
To be done in the Bnd annotations project.
DS Annotations conveniently result in Requirements and Capabilities for Services. This often causes resolver problems, when a DS Components references a Service that is registered manually and the usual solution is to add the Capability manually with something like
@Capability(namespace = ServiceNamespace.SERVICE_NAMESPACE, attribute = ServiceNamespace.CAPABILITY_OBJECTCLASS_ATTRIBUTE + ":List<String>=\"foo.bar.Service,fizz.buzz.AnotherService\"")
.Thus it would be great to provide a more Specific Annotation like
@ServiceCapability({Service.class, AnotherService.class})