Not quite sure what you mean here. But you can certainly
register/unregister OSGi services dynamically in response to JNDI service
changes. Alas I know little about JNDI, but I would imagine that
some form of event notification is available to which you could subscribe.
Just use the OSGi BundleContext and ServiceRegistration interfaces
to register/unregister OSGi services.
>>Ideally, I would like to just try to get a service
from the registry, and have the framework (or some bundle) try to look
it up through JNDI behind the scenes.
Getting a service from the OSGi registry is a two step
process. First you must get a ServiceReference to the service, then
de-reference the ServiceReference to get the service. OSGi offers
at least two ways to track services: First there is the ServiceListener/ServiceEvent
approach where you register for changes in the service registry (with an
optional LDAP filter). Secondly there is the ServiceTracker, which
is simply an abstraction that is supposed to make it easier to handle
changes in the service registry. Frankly I prefer the ServierListener/ServiceEvent
approach, but I must confess that this is partly due to my using it long
before the ServiceTracker was available. So I suggest starting with
the ServiceListener/ServiceEvent approach.
I hope this helps,
<tom.huybrechts@xxxxxxxxx> Sent by: equinox-dev-bounces@xxxxxxxxxxx
10/14/2006 06:25 PM
Please respond to
Equinox development mailing list <equinox-dev@xxxxxxxxxxx>
"Equinox development mailing list"
[equinox-dev] getting remote services
from the registry
I'm working on an application that uses remote services which are acquired
using JNDI. I would like to hide the use of JNDI, by exposing these services
through the OSGi service registry. For the moment, I'm doing this by asking
for a list of services when the platform starts, and registering service
factories for all of them. However this ignores the fact that remote services
might disappear or be added, which is one of the nice features o OSGi.
What would be a better way of handling this ? Ideally, I would like to
just try to get a service from the registry, and have the framework (or
some bundle) try to look it up through JNDI behind the scenes.
equinox-dev mailing list