开发者

Services provider and consumer in Spring DM

开发者 https://www.devze.com 2023-03-12 04:28 出处:网络
I have a bundle that should provide and consum a service. My application context is: <bean id=\"dbConsumer\" class=\"service.User\">

I have a bundle that should provide and consum a service. My application context is:

<bean id="dbConsumer" class="service.User">
    <property name="db" ref="DBservice"></property>
</bean> 

<osgi:reference id="DBservice">
    <osgi:interfaces>
        <value>com.db.manager.DatabaseManager</value>
    </osgi:interfaces>
</osgi:reference>

<bean name="ServicioZB" id="zbservice" class="service.ZBService"/>

<osgi:service  ref="zbservice">
    <osgi:interfaces>
        <value>service.IZBService</value>
    </osgi:interfaces>
</osgi:service>

The problem is when I deploy. I work on Equinox and if I watch services I can see that the bundle consums DBservice. However, the service is noy exposed. But if I remove the reference tag, my service is exposed.开发者_如何学JAVA It is to say, I have 3 bundles (A,B,C). B exports a service that is consumed by A. Also, C exports a service which is consumed by B Then, my question is: Can not the tags be together? How could I develop a bundle to consum and provide services?

Thanks in advance!

Regards!


If you are only using publishing one interface, try to use the interface property instead of the interfaces-tag. So replace

 <osgi:service ref="zbservice">
     <osgi:interfaces>
         <value>service.IZBService</value>
     </osgi:interfaces>
 </osgi:service>

with

 <osgi:service ref="zbservice" interface="service.IZBService"/>

I had a similar issue one time and this approach did work for me.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号