Sergey,

You can always register a factory for your Service in the OSGi
registry.  That way, you can get a reference to the service factory
and create a new object instance using the factory.  If you're
building applications for ServiceMix 4, I would really recommend you
to look into Spring DM or (even better) Blueprint services to ease the
effort to register new services and consume them afterwards.

Guillaume has made an excellent introduction presentation on Blueprint
available on Slideshare
(http://www.slideshare.net/gnodet/osgi-blueprint-services-1622424),
which shows how you can get a service reference (or in your case, a
reference to the service factory) and then use that object as a
factory for creating new instances and injecting them in some other
bean.

Regards,

Gert Vanthienen
------------------------
Open Source SOA: http://fusesource.com
Blog: http://gertvanthienen.blogspot.com/



2009/10/6 Sergey Shcherbakov <[email protected]>:
> Hi all,
>
>
>
> I am new to Servicemix and OSGi therefore sorry for a probably stupid
> question.
>
> Do I understand correctly that a service within a Servicemix container
> is in essence a single object instance serving a given contract
> (interface[s])?
>
> I mean, is that correct that it is not possible (by design) to obtain a
> new service object instance by each call to a BundleContext.getService()
> <http://www.knopflerfish.org/releases/current/docs/javadoc/org/osgi/fram
> ework/BundleContext.html#getService(org.osgi.framework.ServiceReference)
>> ?
>
> As I understand, according to this tutorial article:
> http://www.knopflerfish.org/osgi_service_tutorial.html this is not
> possible.
>
> At maximum, I get can a list of service objects registered in the
> container and select a needed one by myself or I can get a separate
> service object "per bundle", but I cannot make the service factory to
> instantiate a new service instance every time my bundle wants to call
> it?
>
>
>
> Best Regards,
>
> Sergey Shcherbakov.
>
>

Reply via email to