Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » Why we need to use ServiceFactory?
Why we need to use ServiceFactory? [message #71619] Sat, 05 August 2006 10:03 Go to next message
Eclipse UserFriend
Originally posted by: nickylavignevn.gmail.com

Hi all,
We can register a service by bundleContext or by serviceFactory. But i
couldnt understand the advantages of serviceFactory and when to use it.
Do u have any suggest ?
Re: Why we need to use ServiceFactory? [message #71640 is a reply to message #71619] Sat, 05 August 2006 10:30 Go to previous messageGo to next message
Harald Niesche is currently offline Harald NiescheFriend
Messages: 23
Registered: July 2009
Junior Member
Nicky wrote:
> Hi all,
> We can register a service by bundleContext or by serviceFactory. But i
> couldnt understand the advantages of serviceFactory and when to use it.
> Do u have any suggest ?

You can use the ServiceFactory if you want to have a different instance
of your service for each bundle using the service.

A plain vanilla service has no way of knowing which bundle is using it,
a ServiceFactory gets the Bundle object for the bundle that called
getService and can pass that along to the service instance it creates.

Maybe an example will make this clearer: The ConfigurationAdmin service
is implemented using a ServiceFactory because it needs to check the
calling bundle's permissions. So the actual ConfigurationAdmin keeps a
reference to the bundle it was created for and checks permissions using
that reference.

Another reason mentioned in the spec is resource management: A service
could allocate some resources for every bundle that is using the
service. When the using bundle is stopped, the service can release all
resources associated with serving that bundle.

HTH

Harald
Re: Why we need to use ServiceFactory? [message #71857 is a reply to message #71640] Wed, 09 August 2006 01:51 Go to previous message
Eclipse UserFriend
Originally posted by: nickylavignevn.gmail.com

I got it Harald
Thanks so much,
Previous Topic:How To: Get full path from a BundleDescriptor
Next Topic:Equinox beginner
Goto Forum:
  


Current Time: Fri Apr 26 07:20:58 GMT 2024

Powered by FUDForum. Page generated in 0.03135 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top