OSGi Service Listener [message #116379] |
Thu, 21 August 2008 20:07  |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.03415 seconds