Description
When using OSGi Declarative Services (DS) you can express interest in an OSGi service through an XML descriptor, like this one (from the samples/ds demo):
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="DS Consumer Sample" activate="start"> <implementation class="org.apache.cxf.dosgi.samples.ds.consumer.AdderConsumer"/> <reference interface="org.apache.cxf.dosgi.samples.ds.AdderService" name="AdderService" cardinality="1..1" policy="dynamic" bind="bindAdder" unbind="unbindAdder"/> </scr:component>
The declarative services implementation will then inject your service into your component.
With CXF-DOSGi a remote service is always registered on-the-fly when a service is requested. This is done through a ListenerHook. The listenerhook gets called with the filter of services that are looked up by a consumer, e.g. what the consumer passed in to a ServiceTracker.
It seems like the DS implementation uses a single tracker or listener for all the services it's interested in, which probably uses an empty filter. This is currently ignored by the CXF-DOSGi listener hook implementation, which means that the AdderService proxy is not automatically injected in the component.
There is a workaround. Simply create a bundle (any bundle) in the consumer that registers a service tracker to listen for the service that you want to be discovered remotely.