Can -runrequires specify service references?


I have already learnt that -runsystemcapabilities can declare dynamic services for the sake of Bnd’s resolver, e.g.

-resolve.effective: resolve,active
-runsystemcapabilities: osgi.service;objectClass:List<String>='org.testing.Function1';effective:=active

I would also like to add dynamic service requirements to the resolver. However, I am not having any success using -runrequires like this:

-runrequires: osgi.service;objectClass:List<String>='org.testing.Function2';effective:=active

Have I made a syntax error here please? Or does Bnd simply not support doing this?


You can do that! However, you need to change your syntax so that your -runrequires contains a collection of requirements. Requirements use filter: directive. Like so:

-runrequires: osgi.service;filter:='(objectClass=org.testing.Function2)'

OK, thanks. Does the effective=active clause also become another filter condition please? Or doesn’t it matter?

effectiveness only means something on the provider (a.k.a. capability) side of the equation, therefore you do not apply it at all on the requirement side.