You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Andrei Petru Mura <ma...@gmail.com> on 2021/09/21 08:44:30 UTC

Referencing service via component-name

I have my own bundle deployed in karaf 4.3.2.

In my blueprint.xml, I have declared a few services, like this:

<service id="serviceName" interface="some.InterfaceName"
ref="importedSpringBeanName" />

If I list the services in karaf, I can see that this services are available.

In another bundle, I want to use this services via reference. Like this:

  <reference id="referencedServiceName" component-name="serviceName"
interface="some.InterfaceName" />

But when I deploy my second bundle in karaf, I get this:
Unable to start container for blueprint bundle my-second-bundle/0.0.1 due
to unresolved dependencies
[(&(objectClass=some.InterfaceName)(osgi.service.blueprint.compname=serviceName))]

Am I missing something? Is there a way to reference a service via its ID?

Thanks,
Andrei

Re: Referencing service via component-name

Posted by Jean-Baptiste Onofre <jb...@nanthrax.net>.
Hi Andrei,

Service and reference are decoupled as they are in different bundles (most of the time).

If you want to « link » via serviceName, just use properties and filter:

<service ….>
	<service-properties>
           <entry key=“id” value=“serviceName”/>
	</service-properties>
</service>

Then:

<reference … filter=“(id=serviceName)”/>

Regards
JB

> Le 21 sept. 2021 à 10:44, Andrei Petru Mura <ma...@gmail.com> a écrit :
> 
> I have my own bundle deployed in karaf 4.3.2.
> 
> In my blueprint.xml, I have declared a few services, like this:
> 
> <service id="serviceName" interface="some.InterfaceName" ref="importedSpringBeanName" />
> 
> If I list the services in karaf, I can see that this services are available.
> 
> In another bundle, I want to use this services via reference. Like this:
> 
>   <reference id="referencedServiceName" component-name="serviceName" interface="some.InterfaceName" />
> 
> But when I deploy my second bundle in karaf, I get this:
> Unable to start container for blueprint bundle my-second-bundle/0.0.1 due to unresolved dependencies [(&(objectClass=some.InterfaceName)(osgi.service.blueprint.compname=serviceName))]
> 
> Am I missing something? Is there a way to reference a service via its ID?
> 
> Thanks,
> Andrei