How to configure Spring-DM OSGi service for new instance per call?

Posted by Bhav on Stack Overflow See other posts from Stack Overflow or by Bhav
Published on 2010-06-16T21:08:28Z Indexed on 2010/06/16 21:12 UTC
Read the original article Hit count: 223

Filed under:

I'm starting to delve into using Spring DM and OSGi services in an RCP application. I've created a service which is used by another bundle in the RCP application. It does a lookup of the service via calls to getBundleContext().getServiceReference() using the explicit bundle names and service class names. I'm not using DI anywhere yet. The issue I'm running into is that the service that is returned in the requesting bundle is a singleton. At times I notice a threading issue since it is a "stateful" service. How do I configure the application to get back a new service instance with each call?

Here is my spring xml file contents which registers the service:

<bean id="myServBean" class="com.xyz.ClassImpl"/>
<osgi:service ref="myServBean" class="com.xyz.Class"/>

© Stack Overflow or respective owner

Related posts about osgi