问题
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.
来源:https://stackoverflow.com/questions/38322981/how-to-override-bnd-require-capability-generated-from-ds-annotation