servicemix-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sergey Shcherbakov" <>
Subject RE: Simple service instancing question
Date Wed, 07 Oct 2009 09:07:31 GMT
Thank you, Gerd, for a detailed answer. I'll definitely look through the
presentation you sent a link to.

But if we would talk exclusively about what is available in the
Servicemix distribution, would the following excerpt from the
Knopflerfish tutorial I mentioned at the beginning still be true?

"An OSGi service factory is a special class ServiceFactory, which can
create individual instances of service objects for different bundles.
... Note: The framework will cache generated service objects. Thus, at
most one service can be generated per client bundle."

Best Regards,
Sergey Shcherbakov.

-----Original Message-----
From: Gert Vanthienen [] 
Sent: Tuesday, October 06, 2009 9:45 PM
Subject: Re: Simple service instancing question


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
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


Gert Vanthienen
Open Source SOA:

2009/10/6 Sergey Shcherbakov <>:
> 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
> new service object instance by each call to a
>> ?
> As I understand, according to this tutorial article:
> 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.

View raw message