1

I have a bundle with an "optional" Component : It should be started if at leat one service of type X exist, and deactivated when the last service is unregistered.

This component is "optional": It doesn't matter if X is registered or not, or if my component is activated or not. It's just an helper for managing instances of X.

My component is declared like this :

@Component
public class MyManager {

  @Reference(cardinality=AT_LEAST_ONE)
  public void addService(X service) { .. }
}

However, bnd generate a Require-Capability for at least one service X.

How can I tell bnd that my component is optional, and all it dependencies are optionals ? I can change the implementation of my component to add lazynes "by hand", but I would rather use DS capabilities.

Jérémie B
  • 10,611
  • 1
  • 26
  • 43
  • If you make the cardinality MULTIPLE then you get an optional dependency. We had a discussion to change even AT_LEAST_ONE to optional but surprisingly opinions differed. – Peter Kriens Jul 12 '16 at 09:50
  • 1
    https://github.com/bndtools/bnd/issues/1364 requests a way to disable generation of the osgi.service capabilities and requirements for DS components. You may want to add a comment with your interest there. – BJ Hargrave Jul 12 '16 at 16:18

0 Answers0