How do I create a "greedy" requirement?

Hi,

I am trying to write an OSGi requirement for -runrequires that will match every candidate on the runtime classpath. I thought that adding cardinality:=multiple would do the trick, but even that still stops after only the first match.

Basically, I am trying to identify every bundle whose com.foo capability has value bar:

-runrequires:
    com.foo;filter:='(com.foo=bar)';cardinality:=multiple

Does OSGi’s Requirement / Capability model support what I am trying to do here, please?

Thanks,
Chris

Hi Chris,

This can be achieved with the findproviders macro:

bars : ${findproviders;com.foo;(com.foo=bar)}
-runrequires : ${template;bars;osgi.identity;filter:='(osgi.identity=${@})'}

Regards,

Arnoud

1 Like

Hi, thanks for the reply. And yes, that worked :slight_smile:, although I have finally settled on:

-runrequires: ${template;bars;bnd.identity;id='${@}'}

for consistency with the rest of my .bndrun file.

Thanks again,
Cheers,
Chris

1 Like