servicemix-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sergey Shcherbakov" <sshcherba...@echelon.de>
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 [mailto:gert.vanthienen@gmail.com] 
Sent: Tuesday, October 06, 2009 9:45 PM
To: users@servicemix.apache.org
Subject: Re: Simple service instancing question

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 <sshcherbakov@echelon.de>:
> 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.
>
>

Mime
View raw message