Skip to main content



      Home
Home » Eclipse Projects » Equinox » OSGi Service Listener
OSGi Service Listener [message #116379] Thu, 21 August 2008 20:07 Go to next message
Eclipse UserFriend
Is there a way in Equinox OSGi to listen to when services are registered, and de-registered, start being used, and stop being used?

I am dynamically trying to determine what services each bundle uses, and since there is no meta-data associated with their service use (except in things like DS or Spring-OSGi), I have to harvest it. At the moment I am just polling the service registry looking for changes, but that is slow annoying and listeners are better.
Re: OSGi Service Listener [message #116383 is a reply to message #116379] Thu, 21 August 2008 20:31 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: equinox-group.hengames.de

You can use either a ServiceListener or a ServiceTracker to deal with
service registration/de-registration. If you own the service provider
but not the consumer, you could use a ServiceFactory that will be able
to track service retrieval.

Note that the framework does not keep up any connection to the retrieved
service, thus there are no start/stop usage events. Services in OSGi are
simply pojos and retrieving a service from the registry does not give
you any hint whether and when it will actually be used.

HTH, Hendrik

Graham Jenson wrote:
> Is there a way in Equinox OSGi to listen to when services are registered, and de-registered, start being used, and stop being used?
>
> I am dynamically trying to determine what services each bundle uses, and since there is no meta-data associated with their service use (except in things like DS or Spring-OSGi), I have to harvest it. At the moment I am just polling the service registry looking for changes, but that is slow annoying and listeners are better.
Re: OSGi Service Listener [message #116387 is a reply to message #116379] Thu, 21 August 2008 22:32 Go to previous message
Eclipse UserFriend
Graham

As Hendrik mentioned, you can register a ServiceListener or use a
ServiceTracker, both of which can employ LDAP filters to listen for
specific services.

If you are only interested in particular bundles, you can use the Bundle
API getServicesInUse(). You can also find out the services registered
by a bundle using the Bundle API getRegisteredServices().

Other relationship information is also available from the PackageAdmin
service.

I hope this helps,

Simon
Previous Topic:Rally Basic Equinox/Servlet Bridge Problem
Next Topic:[Equinox Security] The bundle could not be resolved
Goto Forum:
  


Current Time: Mon Jun 09 09:46:46 EDT 2025

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

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

Back to the top